-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from djangoindia/eslint_config
Update to flatConfig and eslint v9
- Loading branch information
Showing
108 changed files
with
3,129 additions
and
2,420 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "all", | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'; | ||
import { FlatCompat } from '@eslint/eslintrc'; | ||
import js from '@eslint/js'; | ||
import typescriptEslint from '@typescript-eslint/eslint-plugin'; | ||
import tsParser from '@typescript-eslint/parser'; | ||
import react from 'eslint-plugin-react'; | ||
import reactHooks from 'eslint-plugin-react-hooks'; | ||
import tailwind from 'eslint-plugin-tailwindcss'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: js.configs.recommended, | ||
allConfig: js.configs.all, | ||
}); | ||
|
||
export default [ | ||
...tseslint.config({ | ||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}), | ||
js.configs.recommended, | ||
...tailwind.configs['flat/recommended'], | ||
...fixupConfigRules( | ||
compat.extends( | ||
'eslint:recommended', | ||
'plugin:react/recommended', | ||
'plugin:react-hooks/recommended', | ||
'plugin:prettier/recommended', | ||
'next', | ||
), | ||
), | ||
{ | ||
plugins: { | ||
'@typescript-eslint': fixupPluginRules(typescriptEslint), | ||
react: fixupPluginRules(react), | ||
'react-hooks': fixupPluginRules(reactHooks), | ||
}, | ||
|
||
languageOptions: { | ||
parser: tsParser, | ||
ecmaVersion: 2020, | ||
sourceType: 'module', | ||
|
||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
}, | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
'import/resolver': { | ||
typescript: { | ||
alwaysTryTypes: true, | ||
}, | ||
}, | ||
}, | ||
rules: { | ||
'import/named': 'error', | ||
'import/namespace': 'error', | ||
'import/default': 'error', | ||
'import/export': 'error', | ||
'prefer-const': 'warn', | ||
eqeqeq: 'error', | ||
'no-var': 'warn', | ||
'no-unused-vars': 'warn', | ||
'no-duplicate-imports': 'error', | ||
'object-shorthand': 'warn', | ||
'quote-props': ['warn', 'as-needed'], | ||
'react/prop-types': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/consistent-type-exports': 'error', | ||
'@typescript-eslint/consistent-type-imports': [ | ||
'error', | ||
{ | ||
disallowTypeAnnotations: false, | ||
fixStyle: 'separate-type-imports', | ||
prefer: 'type-imports', | ||
}, | ||
], | ||
'@typescript-eslint/no-explicit-any': 'error', | ||
'@typescript-eslint/no-import-type-side-effects': 'error', | ||
// 'no-restricted-imports': [ | ||
// 'warn', | ||
// { | ||
// patterns: [ | ||
// { | ||
// group: ['@/*'], | ||
// message: "Avoid using '@/'. Use '@' instead.", | ||
// }, | ||
// ], | ||
// }, | ||
// ], | ||
'sort-imports': [ | ||
'warn', | ||
{ | ||
ignoreCase: true, | ||
ignoreDeclarationSort: true, | ||
ignoreMemberSort: false, | ||
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], | ||
allowSeparatedGroups: false, | ||
}, | ||
], | ||
'import/order': [ | ||
'warn', | ||
{ | ||
groups: [ | ||
'builtin', | ||
'external', | ||
'internal', | ||
'parent', | ||
'sibling', | ||
'index', | ||
'object', | ||
'type', | ||
], | ||
pathGroups: [ | ||
{ | ||
pattern: 'react', | ||
group: 'external', | ||
position: 'before', | ||
}, | ||
{ | ||
pattern: '@**', | ||
group: 'internal', | ||
position: 'before', | ||
}, | ||
], | ||
pathGroupsExcludedImportTypes: ['react'], | ||
'newlines-between': 'always', | ||
alphabetize: { | ||
order: 'asc', | ||
caseInsensitive: true, | ||
}, | ||
}, | ||
], | ||
'react-hooks/rules-of-hooks': 'error', | ||
'react-hooks/exhaustive-deps': 'warn', | ||
'react/react-in-jsx-scope': 'off', | ||
'tailwindcss/no-custom-classname': 'warn', | ||
'tailwindcss/classnames-order': 'warn', | ||
'prettier/prettier': 'warn', | ||
}, | ||
}, | ||
]; |
Oops, something went wrong.