-
Notifications
You must be signed in to change notification settings - Fork 38
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 #579 from pixiv/chore/eslint-flatconfig
Migrate to Flatconfig and Clean Up ESLint Rules
- Loading branch information
Showing
22 changed files
with
801 additions
and
616 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,166 @@ | ||
// @ts-nocheck | ||
import eslint from '@eslint/js' | ||
import _import from 'eslint-plugin-import-x' | ||
import globals from 'globals' | ||
import path from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
import tseslint from 'typescript-eslint' | ||
import eslintPluginReact from 'eslint-plugin-react' | ||
import eslintPluginReactHook from 'eslint-plugin-react-hooks' | ||
import eslintPluginPrettierRecommended from 'eslint-config-prettier' | ||
import { fixupPluginRules } from '@eslint/compat' | ||
|
||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = path.dirname(__filename) | ||
|
||
const tseslintConfig = tseslint.config( | ||
...tseslint.configs.recommended, | ||
...tseslint.configs.recommendedTypeChecked, | ||
{ | ||
languageOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
parser: tseslint.parser, | ||
parserOptions: { | ||
ecmaFeatures: { jsx: true }, | ||
project: ['./tsconfig.json', 'packages/**/tsconfig.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
}, | ||
rules: { | ||
'@typescript-eslint/no-empty-function': 'error', | ||
'@typescript-eslint/adjacent-overload-signatures': 'error', | ||
'@typescript-eslint/no-empty-interface': 'error', | ||
'@typescript-eslint/no-inferrable-types': 'error', | ||
'@typescript-eslint/ban-ts-comment': 'error', | ||
'@typescript-eslint/prefer-namespace-keyword': 'error', | ||
'@typescript-eslint/no-unsafe-assignment': 'error', | ||
'@typescript-eslint/no-non-null-assertion': 'error', | ||
}, | ||
} | ||
) | ||
|
||
const typescriptConfig = [ | ||
...tseslintConfig, | ||
{ | ||
files: ['**/*.ts', '**/*.tsx'], | ||
plugins: { | ||
'@typescript-eslint': tseslint.plugin, | ||
import: _import, | ||
}, | ||
rules: { | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{ argsIgnorePattern: '^_', ignoreRestSiblings: true }, | ||
], | ||
'@typescript-eslint/no-unnecessary-condition': 'error', | ||
'@typescript-eslint/strict-boolean-expressions': 'error', | ||
'@typescript-eslint/consistent-type-definitions': 'off', | ||
'@typescript-eslint/no-empty-interface': 'off', | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
devDependencies: [ | ||
'*.config.ts', | ||
'**/*.config.ts', | ||
'**/*.test.ts', | ||
'**/*.test.tsx', | ||
'**/*.story.tsx', | ||
'**/_lib/**', | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.tsx', '**/*.ts'], | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
}, | ||
}, | ||
plugins: { | ||
react: eslintPluginReact, | ||
'react-hooks': fixupPluginRules(eslintPluginReactHook), | ||
}, | ||
rules: { | ||
...eslintPluginReact.configs.recommended.rules, | ||
...eslintPluginReactHook.configs.recommended.rules, | ||
'react/prop-types': 'off', | ||
'react/no-unknown-property': ['error', { ignore: ['css'] }], | ||
'react/jsx-uses-react': 'off', | ||
'react/react-in-jsx-scope': 'off', | ||
}, | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
}, | ||
] | ||
|
||
const config = [ | ||
eslint.configs.recommended, | ||
eslintPluginPrettierRecommended, | ||
...typescriptConfig, | ||
{ | ||
ignores: [ | ||
'**/dist/', | ||
'**/node_modules/', | ||
'**/__snapshots__/', | ||
'**/.yarn/', | ||
'public/', | ||
'storybook-static/', | ||
'coverage/', | ||
'**/.next/', | ||
'misc/', | ||
'packages/tailwind-diff/bin/tailwind-diff.js', | ||
'packages/icon-files/src/', | ||
'eslint.config.mjs', | ||
'.storybook', | ||
], | ||
}, | ||
{ | ||
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], | ||
rules: { | ||
'no-console': 'warn', | ||
'no-undef': 'off', | ||
'no-constant-condition': 'error', | ||
}, | ||
}, | ||
{ | ||
files: [ | ||
'**/*.test.ts', | ||
'**/*.test.tsx', | ||
'**/__tests__/**', | ||
'**/*.config.*', | ||
'*.config.*', | ||
'**/*.story.*', | ||
'.storybook/**', | ||
], | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
...globals.jest, | ||
}, | ||
}, | ||
plugins: { | ||
import: _import, | ||
}, | ||
rules: { | ||
'import/no-extraneous-dependencies': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['**/docs/**'], | ||
plugins: { | ||
import: _import, | ||
}, | ||
rules: { | ||
'import/no-extraneous-dependencies': 'off', | ||
}, | ||
}, | ||
] | ||
|
||
export default config |
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
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
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
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
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
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
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
Oops, something went wrong.