-
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.
Merge pull request #47 from salute-developers/SPEED-1579-eslint-9-sup…
…port eslint flat config support
- Loading branch information
Showing
9 changed files
with
427 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
'use strict'; | ||
|
||
import eslintRecommended from '@eslint/js'; | ||
import tsEslintRecommended from '@typescript-eslint/eslint-plugin'; | ||
import tsEslintParser from '@typescript-eslint/parser'; | ||
import importPlugin from 'eslint-plugin-import'; | ||
|
||
/** @type {import("eslint").Linter.Config[]} */ | ||
export default [ | ||
{ | ||
files: ['*.ts', '*.tsx'], | ||
languageOptions: { | ||
parser: tsEslintParser, | ||
}, | ||
plugins: { | ||
'@typescript-eslint': tsEslintRecommended, | ||
import: importPlugin, | ||
}, | ||
rules: { | ||
...eslintRecommended.configs.recommended.rules, | ||
...tsEslintRecommended.configs['eslint-recommended'].rules, | ||
...tsEslintRecommended.configs.recommended.rules, | ||
...importPlugin.configs.recommended.rules, | ||
|
||
'@typescript-eslint/no-empty-function': 'off', | ||
'no-restricted-syntax': 'off', // В for...of циклах ничего плохого нет | ||
'spaced-comment': ['error', 'always', { markers: ['/'] }], // разрешаем ts-require directive | ||
'comma-dangle': ['error', 'always-multiline'], | ||
'arrow-parens': ['error', 'always'], | ||
|
||
'space-before-function-paren': [ | ||
'error', | ||
{ | ||
anonymous: 'never', | ||
named: 'never', | ||
asyncArrow: 'always', | ||
}, | ||
], | ||
indent: 'off', | ||
'max-len': [ | ||
'error', | ||
120, | ||
2, | ||
{ | ||
ignoreUrls: true, | ||
ignoreComments: false, | ||
ignoreRegExpLiterals: true, | ||
ignoreStrings: true, | ||
ignoreTemplateLiterals: true, | ||
}, | ||
], | ||
'padding-line-between-statements': [ | ||
'error', | ||
{ blankLine: 'always', prev: '*', next: 'return' }, | ||
{ blankLine: 'always', prev: '*', next: 'if' }, | ||
], | ||
'implicit-arrow-linebreak': 'off', | ||
'no-plusplus': 'off', | ||
'max-classes-per-file': 'off', | ||
'operator-linebreak': 'off', | ||
'object-curly-newline': 'off', | ||
'class-methods-use-this': 'off', | ||
'no-confusing-arrow': 'off', | ||
'function-paren-newline': 'off', | ||
'no-param-reassign': 'off', | ||
'no-shadow': 'warn', | ||
'consistent-return': 'off', | ||
|
||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
|
||
'import/prefer-default-export': 'off', // @grape: https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/ | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: [['builtin', 'external'], 'internal', 'parent', 'sibling', 'index'], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
'import/no-unresolved': 'off', | ||
'import/extensions': 'off', | ||
'import/no-extraneous-dependencies': ['off'], | ||
'arrow-body-style': 'off', | ||
'no-unused-expressions': 'off', | ||
}, | ||
}, | ||
]; |
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,71 @@ | ||
export default { | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:import/recommended', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint'], | ||
rules: { | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'no-restricted-syntax': 'off', // В for...of циклах ничего плохого нет | ||
'spaced-comment': ['error', 'always', { markers: ['/'] }], /// разрешаем ts-require directive | ||
'comma-dangle': ['error', 'always-multiline'], | ||
'arrow-parens': ['error', 'always'], | ||
|
||
'space-before-function-paren': [ | ||
'error', | ||
{ | ||
anonymous: 'never', | ||
named: 'never', | ||
asyncArrow: 'always', | ||
}, | ||
], | ||
indent: 'off', | ||
'max-len': [ | ||
'error', | ||
120, | ||
2, | ||
{ | ||
ignoreUrls: true, | ||
ignoreComments: false, | ||
ignoreRegExpLiterals: true, | ||
ignoreStrings: true, | ||
ignoreTemplateLiterals: true, | ||
}, | ||
], | ||
'padding-line-between-statements': [ | ||
'error', | ||
{ blankLine: 'always', prev: '*', next: 'return' }, | ||
{ blankLine: 'always', prev: '*', next: 'if' }, | ||
], | ||
'implicit-arrow-linebreak': 'off', | ||
'no-plusplus': 'off', | ||
'max-classes-per-file': 'off', | ||
'operator-linebreak': 'off', | ||
'object-curly-newline': 'off', | ||
'class-methods-use-this': 'off', | ||
'no-confusing-arrow': 'off', | ||
'function-paren-newline': 'off', | ||
'no-param-reassign': 'off', | ||
'no-shadow': 'warn', | ||
'consistent-return': 'off', | ||
|
||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
|
||
'import/prefer-default-export': 'off', // @grape: https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/ | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: [['builtin', 'external'], 'internal', 'parent', 'sibling', 'index'], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
'import/no-unresolved': 'off', | ||
'import/extensions': 'off', | ||
'import/no-extraneous-dependencies': ['off'], | ||
'arrow-body-style': 'off', | ||
'no-unused-expressions': 'off', | ||
}, | ||
}; |
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 |
---|---|---|
|
@@ -8,6 +8,13 @@ | |
"url": "git+https://github.com/salute-developers/grail.git" | ||
}, | ||
"author": "Salute Frontend Team <[email protected]>", | ||
"exports": { | ||
".": { | ||
"require": "./index.js", | ||
"import": "./index.mjs" | ||
}, | ||
"./flat": "./flat/index.mjs" | ||
}, | ||
"main": "index.js", | ||
"peerDependencies": { | ||
"@typescript-eslint/eslint-plugin": ">=8", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
'use strict'; | ||
|
||
import eslintConfigBase from '@salutejs/eslint-config-base'; | ||
import reactPlugin from 'eslint-plugin-react'; | ||
import reactHooksPlugin from 'eslint-plugin-react-hooks'; | ||
import reactPerfPlugin from 'eslint-plugin-react-perf'; | ||
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'; | ||
import saluteRulesPlugin from 'eslint-plugin-salute-rules'; | ||
import prettierPlugin from 'eslint-plugin-prettier'; | ||
import prettierConfig from '@salutejs/prettier-config'; | ||
|
||
/** @type {import("eslint").Linter.Config[]} */ | ||
export default [ | ||
eslintConfigBase[0], | ||
|
||
{ | ||
plugins: { | ||
react: reactPlugin, | ||
}, | ||
languageOptions: { | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
}, | ||
rules: { | ||
...reactPlugin.configs.recommended.rules, | ||
'react/prop-types': 'off', | ||
'react/static-property-placement': 'off', | ||
'react/state-in-constructor': 'off', | ||
'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }], | ||
'react/jsx-one-expression-per-line': 'off', | ||
'react/jsx-indent': ['error', 4], | ||
'react/jsx-indent-props': ['error', 4], | ||
'react/display-name': 'error', | ||
'react/jsx-no-leaked-render': 'off', | ||
'react/jsx-props-no-spreading': 'off', | ||
'react/destructuring-assignment': 'off', | ||
'react/sort-comp': 'off', | ||
'react/no-array-index-key': 'off', | ||
'react/require-default-props': 'off', | ||
'react/function-component-definition': 'off', | ||
'react/jsx-no-useless-fragment': 'off', | ||
'react/no-unstable-nested-components': 'error', | ||
}, | ||
settings: { | ||
react: { | ||
version: '18.3.1', | ||
}, | ||
}, | ||
}, | ||
|
||
{ | ||
plugins: { | ||
'react-hooks': reactHooksPlugin, | ||
}, | ||
rules: { | ||
...reactHooksPlugin.configs.recommended.rules, | ||
}, | ||
}, | ||
|
||
{ | ||
plugins: { | ||
'react-perf': reactPerfPlugin, | ||
}, | ||
rules: { | ||
...reactPerfPlugin.configs.recommended.rules, | ||
}, | ||
}, | ||
|
||
{ | ||
plugins: { | ||
'jsx-a11y': jsxA11yPlugin, | ||
}, | ||
rules: { | ||
...jsxA11yPlugin.configs.recommended.rules, | ||
'jsx-a11y/no-static-element-interactions': 'off', | ||
'jsx-a11y/click-events-have-key-events': 'off', | ||
'jsx-a11y/no-noninteractive-tabindex': 'off', | ||
}, | ||
}, | ||
|
||
{ | ||
plugins: { | ||
'salute-rules': saluteRulesPlugin, | ||
}, | ||
rules: { | ||
...saluteRulesPlugin.configs.all.rules, | ||
}, | ||
}, | ||
|
||
{ | ||
plugins: { | ||
prettier: prettierPlugin, | ||
}, | ||
rules: { | ||
'prettier/prettier': ['error', prettierConfig], | ||
}, | ||
}, | ||
|
||
{ | ||
files: ['**/*.ts', '**/*.tsx'], | ||
rules: { | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
patterns: [ | ||
'@salutejs/plasma-ui/*', | ||
'@salutejs/plasma-tokens/*', | ||
'@salutejs/plasma-icons/*', | ||
'@salutejs/plasma-web/*', | ||
'@salutejs/plasma-b2c/*', | ||
], | ||
}, | ||
], | ||
'default-param-last': 'warn', | ||
'@typescript-eslint/member-ordering': [ | ||
'warn', | ||
{ | ||
default: { | ||
optionalityOrder: 'required-first', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
|
||
{ | ||
files: ['**/*.tsx'], | ||
languageOptions: { | ||
globals: { | ||
window: true, | ||
document: true, | ||
}, | ||
}, | ||
rules: { | ||
'react/no-unknown-property': 'error', | ||
}, | ||
}, | ||
]; |
Oops, something went wrong.