-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
387 additions
and
370 deletions.
There are no files selected for viewing
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,18 +1,60 @@ | ||
const { FlatCompat } = require('@eslint/eslintrc'); | ||
// eslint-disable-next-line import/extensions | ||
const jsxRuntime = require('eslint-plugin-react/configs/jsx-runtime.js'); | ||
const tseslint = require('typescript-eslint'); | ||
|
||
const { isInstalled } = require('./isInstalled.cjs'); | ||
|
||
const compat = new FlatCompat(); | ||
|
||
// https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb | ||
|
||
const legacyExtends = isInstalled('react') | ||
? ['eslint-config-airbnb', 'eslint-config-airbnb/hooks'] | ||
: ['eslint-config-airbnb/base']; | ||
|
||
module.exports = { | ||
compat: () => compat.extends(...legacyExtends), | ||
compat: (compat) => compat.extends(...legacyExtends), | ||
legacy: { | ||
extends: legacyExtends, | ||
}, | ||
recommended: tseslint.config( | ||
{ | ||
rules: { | ||
// Prohibit default export. | ||
// see. https://basarat.gitbook.io/typescript/main-1/defaultisbad | ||
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md | ||
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md | ||
'import/no-default-export': 'error', | ||
'import/prefer-default-export': 'off', | ||
|
||
// Use console.{warn,error} intentionally. So suppress the warning. | ||
// https://eslint.org/docs/rules/no-console | ||
'no-console': [ | ||
'warn', | ||
{ | ||
allow: ['warn', 'error', 'assert'], | ||
}, | ||
], | ||
|
||
...(isInstalled('react') | ||
? { | ||
// Fix airbnb default rule. | ||
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/label-has-associated-control.md | ||
'jsx-a11y/label-has-associated-control': [ | ||
'error', | ||
{ | ||
assert: 'either', // changed | ||
controlComponents: [], | ||
depth: 25, | ||
labelAttributes: [], | ||
labelComponents: [], | ||
}, | ||
], | ||
// Disable this rule if it conflicts with some rules. | ||
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md | ||
'react/function-component-definition': 'off', | ||
} | ||
: {}), | ||
}, | ||
}, | ||
...(isInstalled('react') && isInstalled('vite') ? [jsxRuntime] : []), | ||
...(isInstalled('react') && isInstalled('next') ? [jsxRuntime] : []), | ||
), | ||
}; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,15 +1,47 @@ | ||
const { FlatCompat } = require('@eslint/eslintrc'); | ||
const globals = require('globals'); | ||
const tseslint = require('typescript-eslint'); | ||
|
||
const config = require('./config.cjs'); | ||
const airbnbDefine = require('./airbnb.cjs'); | ||
const eslintCommentsDefine = require('./eslint-comments.cjs'); | ||
const perfectionistDefine = require('./perfectionist.cjs'); | ||
const prettierDefine = require('./prettier.cjs'); | ||
const reactRefreshDefine = require('./react-refresh.cjs'); | ||
const typescriptDefine = require('./typescript.cjs'); | ||
|
||
module.exports = { | ||
browser: [ | ||
{ | ||
languageOptions: { | ||
ecmaVersion: 'latest', | ||
globals: globals.browser, | ||
}, | ||
const compat = new FlatCompat(); | ||
const airbnb = [...airbnbDefine.compat(compat), ...airbnbDefine.recommended]; | ||
const typescript = [...typescriptDefine.compat(compat), ...typescriptDefine.recommended]; | ||
const reactRefresh = [...reactRefreshDefine.flat, ...reactRefreshDefine.recommended]; | ||
const eslintComments = [...eslintCommentsDefine.flat, ...eslintCommentsDefine.recommended]; | ||
const perfectionist = [...perfectionistDefine.flat, ...perfectionistDefine.recommended]; | ||
const prettier = [...prettierDefine.flat]; | ||
|
||
const all = [ | ||
...airbnb, | ||
...typescript, | ||
...reactRefresh, | ||
...eslintComments, | ||
...perfectionist, | ||
...prettier, | ||
]; | ||
const browser = tseslint.config( | ||
{ | ||
languageOptions: { | ||
ecmaVersion: 'latest', | ||
globals: globals.browser, | ||
}, | ||
...config, | ||
], | ||
}, | ||
...all, | ||
); | ||
|
||
module.exports = { | ||
airbnb, | ||
all, | ||
browser, | ||
eslintComments, | ||
perfectionist, | ||
prettier, | ||
reactRefresh, | ||
typescript, | ||
}; |
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,19 @@ | ||
const comments = require('@eslint-community/eslint-plugin-eslint-comments/configs'); | ||
const tseslint = require('typescript-eslint'); | ||
|
||
// https://eslint-community.github.io/eslint-plugin-eslint-comments/ | ||
|
||
module.exports = { | ||
flat: [comments.recommended], | ||
legacy: { | ||
extends: ['plugin:@eslint-community/eslint-comments/recommended'], | ||
}, | ||
recommended: tseslint.config({ | ||
rules: { | ||
// https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html | ||
'@eslint-community/eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }], | ||
// https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable.html | ||
'@eslint-community/eslint-comments/no-unused-disable': 'error', | ||
}, | ||
}), | ||
}; |
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.