-
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.
feat: correct eslint9 implementation, add config generator
- Loading branch information
Showing
20 changed files
with
6,998 additions
and
8,186 deletions.
There are no files selected for viewing
File renamed without changes.
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,2 @@ | ||
package-lock.json | ||
node_modules |
File renamed without changes.
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 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,13 @@ | ||
import plugin from 'eslint-plugin-jest'; | ||
import globals from 'globals'; | ||
|
||
export default [ | ||
{ | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
}, | ||
}, | ||
}, | ||
]; |
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,26 @@ | ||
import globals from 'globals'; | ||
|
||
import eslintPluginJest from 'eslint-plugin-jest'; | ||
|
||
export default [ | ||
eslintPluginJest.configs['flat/recommended'], | ||
{ | ||
rules: { | ||
'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }], | ||
}, | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
globals: { | ||
...globals.jest, | ||
}, | ||
}, | ||
}, | ||
{ | ||
files: ['**/jest.config.js'], | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
}, | ||
}, | ||
]; |
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,15 @@ | ||
import globals from 'globals'; | ||
|
||
import eslintPluginMocha from 'eslint-plugin-mocha'; | ||
|
||
export default [ | ||
eslintPluginMocha.configs.flat.recommended, | ||
{ | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
globals: { | ||
...globals.mocha, | ||
}, | ||
}, | ||
}, | ||
]; |
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,12 @@ | ||
import globals from 'globals'; | ||
|
||
export default [ | ||
{ | ||
files: ['**/*.ts'], | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
}, | ||
}, | ||
]; |
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,43 @@ | ||
import eslintPluginReact from 'eslint-plugin-react'; | ||
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'; | ||
|
||
export default [ | ||
{ | ||
...eslintPluginReact.configs.flat.recommended, | ||
settings: { | ||
...eslintPluginReact.configs.flat.recommended?.settings, | ||
react: { | ||
...eslintPluginReact.configs.flat.recommended?.settings?.react, | ||
version: 'detect', | ||
}, | ||
}, | ||
}, | ||
|
||
// https://github.com/facebook/react/issues/28313 | ||
// While waiting for eslint-plugin-react-hooks to support eslint9, manually configure it. | ||
// If you're reading this in 2025 or later, you probably can delete this and just use | ||
// the predefined flat config once this is merged and release: | ||
// https://github.com/facebook/react/pull/30774 | ||
{ | ||
files: ['**/*.{ts,tsx}'], | ||
plugins: { | ||
'react-hooks': eslintPluginReactHooks, | ||
}, | ||
rules: eslintPluginReactHooks.configs.recommended.rules, | ||
}, | ||
// General react config | ||
{ | ||
files: ['**/*.{ts,tsx}'], | ||
rules: { | ||
'react/react-in-jsx-scope': 'off', | ||
'react/jsx-uses-react': 'off', | ||
}, | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
globals: { | ||
React: 'readonly', | ||
JSX: 'readonly', | ||
}, | ||
}, | ||
}, | ||
]; |
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,122 @@ | ||
import eslintPluginImport from 'eslint-plugin-import'; | ||
import js from '@eslint/js'; | ||
import ts from 'typescript-eslint'; | ||
import globals from 'globals'; | ||
|
||
import plugin from '../plugin.js'; | ||
|
||
const sixriverJsRules = { | ||
// prettier owns most formatting rules now | ||
'max-len': ['warn', 120, 2], | ||
|
||
curly: ['error', 'all'], | ||
'prefer-const': ['error'], | ||
'no-console': ['error'], | ||
'no-fallthrough': ['error'], | ||
'no-undef': ['error'], | ||
'no-var': ['error'], | ||
strict: ['error', 'global'], | ||
'object-shorthand': 'error', | ||
'no-await-in-loop': 'error', | ||
eqeqeq: 'error', | ||
'require-jsdoc': 'off', | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: [['builtin'], ['external'], ['internal', 'parent', 'sibling', 'index']], | ||
'newlines-between': 'always', | ||
alphabetize: { | ||
order: 'asc', | ||
}, | ||
}, | ||
], | ||
'import/no-self-import': 'error', | ||
'import/newline-after-import': 'error', | ||
}; | ||
|
||
export default [ | ||
// Global ignore list, must only have this key | ||
// https://eslint.org/docs/latest/use/configure/configuration-files#globally-ignoring-files-with-ignores | ||
{ | ||
ignores: [ | ||
'.rush', | ||
'dist*/', | ||
'node_modules', | ||
'coverage/', | ||
'.prettierrc.js', | ||
'eslint.config.mjs', | ||
], | ||
}, | ||
|
||
// Typescript gives an array of rules, because why not | ||
...ts.configs.recommended, | ||
|
||
// Our rules, customize 6River stuff here | ||
{ | ||
name: 'eslint-plugin-6river-typescript', | ||
files: ['**/*.{ts,tsx}'], | ||
plugins: { | ||
'6river': plugin, | ||
import: eslintPluginImport, | ||
}, | ||
rules: { | ||
...sixriverJsRules, | ||
'@typescript-eslint/no-empty-object-type': ['off'], | ||
'@typescript-eslint/no-explicit-any': ['off'], | ||
'@typescript-eslint/no-floating-promises': 'error', | ||
'@typescript-eslint/no-namespace': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'@typescript-eslint/no-unnecessary-condition': 'off', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{ | ||
caughtErrors: 'none', | ||
argsIgnorePattern: '^_', | ||
ignoreRestSiblings: true, | ||
}, | ||
], | ||
'@typescript-eslint/triple-slash-reference': 'error', | ||
'6river/new-cap': ['error', { capIsNewExceptionPattern: '^@' }], | ||
'new-cap': 'off', | ||
'no-cond-assign': [2, 'always'], | ||
'no-undef': 'off', | ||
'no-unused-vars': 'off', | ||
'valid-jsdoc': 'off', | ||
'no-invalid-this': 'off', | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
node: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx'], | ||
}, | ||
}, | ||
}, | ||
linterOptions: { | ||
noInlineConfig: false, | ||
reportUnusedDisableDirectives: 'warn', | ||
}, | ||
}, | ||
|
||
{ | ||
name: 'eslint-plugin-6river-javascript', | ||
files: ['**/*.{js,jsx,mjs,cjs}'], | ||
plugins: { | ||
'6river': plugin, | ||
import: eslintPluginImport, | ||
}, | ||
rules: { | ||
...js.configs.recommended.rules, | ||
...sixriverJsRules, | ||
}, | ||
}, | ||
|
||
// Config file overrides | ||
{ | ||
files: ['.prettierrc.js'], | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
}, | ||
}, | ||
]; |
Oops, something went wrong.