Created
November 27, 2024 06:55
-
-
Save dovranJorayev/0ff7ff9940df7e25e418acfd85ada0d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nx from '@nx/eslint-plugin'; | |
import { FlatCompat } from '@eslint/eslintrc'; | |
import js from '@eslint/js'; | |
import * as tseslint from 'typescript-eslint'; | |
import * as reactHooks from 'eslint-plugin-react-hooks'; | |
import path from 'path'; | |
const __dirname = path.resolve(); | |
// Setup compatibility layer for legacy eslint plugins | |
const compat = new FlatCompat({ | |
baseDirectory: __dirname, | |
recommendedConfig: js.configs.recommended, | |
}); | |
function legacyPlugin(name, alias = name) { | |
const plugin = compat.plugins(name)[0]?.plugins?.[alias]; | |
if (!plugin) { | |
throw new Error(`Unable to resolve plugin ${name} and/or alias ${alias}`); | |
} | |
return plugin; // Removed fixupPluginRules as it's not needed | |
} | |
/** @type {import('eslint').Linter.Config[]} */ | |
export default [ | |
// Base configurations | |
...nx.configs['flat/base'], | |
...nx.configs['flat/typescript'], | |
...nx.configs['flat/javascript'], | |
js.configs.recommended, | |
...tseslint.configs.recommended, | |
// Global ignores | |
{ | |
ignores: ['**/dist'], | |
}, | |
// TypeScript specific configuration with effector | |
{ | |
files: ['**/*.ts', '**/*.tsx'], | |
languageOptions: { | |
ecmaVersion: 2020, | |
parser: tseslint.parser, | |
parserOptions: { | |
project: ['./tsconfig.json', './tsconfig.*.json'], | |
tsconfigRootDir: __dirname, | |
}, | |
}, | |
plugins: { | |
'@typescript-eslint': tseslint.plugin, | |
effector: legacyPlugin('eslint-plugin-effector', 'effector'), | |
}, | |
rules: { | |
...reactHooks.configs.recommended.rules, | |
// Naming conventions | |
'effector/enforce-store-naming-convention': 'error', | |
'effector/enforce-effect-naming-convention': 'error', | |
'effector/enforce-gate-naming-convention': 'error', | |
// Code structure and patterns | |
'effector/keep-options-order': 'error', | |
'effector/mandatory-scope-binding': 'error', | |
'effector/no-ambiguity-target': 'error', | |
'effector/no-duplicate-clock-or-source-array-values': 'error', | |
'effector/no-duplicate-on': 'error', | |
'effector/no-forward': 'error', | |
'effector/no-getState': 'error', | |
'effector/no-guard': 'error', | |
'effector/no-patronum-debug': 'error', | |
'effector/no-unnecessary-combination': 'error', | |
'effector/no-unnecessary-duplication': 'error', | |
'effector/no-useless-methods': 'error', | |
'effector/no-watch': 'error', | |
'effector/prefer-sample-over-forward-with-mapping': 'error', | |
'effector/prefer-useUnit': 'error', | |
'effector/require-pickup-in-persist': 'error', | |
'effector/strict-effect-handlers': 'error', | |
}, | |
}, | |
// React specific configuration | |
...nx.configs['flat/react'], | |
{ | |
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], | |
rules: {}, | |
}, | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// ... existing code ... | |
"dependencies": { | |
"effector": "^23.2.3", | |
"effector-react": "^23.2.1" | |
}, | |
"devDependencies": { | |
"@eslint/eslintrc": "^3.2.0", | |
"@eslint/js": "^9.15.0", | |
"@nx/eslint": "20.1.3", | |
"@nx/eslint-plugin": "20.1.3", | |
"@nx/workspace": "20.1.3", | |
"@typescript-eslint/eslint-plugin": "^8.16.0", | |
"@typescript-eslint/parser": "^8.16.0", | |
"eslint": "^9.8.0", | |
"eslint-config-prettier": "^9.0.0", | |
"eslint-plugin-effector": "^0.15.0", | |
"eslint-plugin-import": "2.31.0", | |
"eslint-plugin-jsx-a11y": "6.10.1", | |
"eslint-plugin-react": "7.35.0", | |
"eslint-plugin-react-hooks": "^5.0.0", | |
"nx": "20.1.3", | |
"typescript-eslint": "^8.0.0" | |
}, | |
// ... existing code ... | |
"overrides": { | |
"eslint-plugin-effector": { | |
"eslint": "^9.8.0" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment