-
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.
added new flat config for salutejs eslint
- Loading branch information
Showing
8 changed files
with
5,501 additions
and
3,338 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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/conf/eslint-recommended'; | ||
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.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 |
---|---|---|
|
@@ -9,6 +9,10 @@ | |
}, | ||
"author": "Salute Frontend Team <[email protected]>", | ||
"main": "index.js", | ||
"exports": { | ||
".": "./index.js", | ||
"./flat": "./index.mjs" | ||
}, | ||
"peerDependencies": { | ||
"@typescript-eslint/eslint-plugin": ">=8", | ||
"@typescript-eslint/parser": ">=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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
"use strict"; | ||
|
||
module.exports = [ | ||
{ | ||
files: ["**/*.ts", "**/*.tsx"], | ||
languageOptions: { | ||
parser: require("@typescript-eslint/parser"), | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
}, | ||
plugins: { | ||
"@typescript-eslint": require("@typescript-eslint/eslint-plugin"), | ||
import: require("eslint-plugin-import"), | ||
}, | ||
rules: { | ||
"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", | ||
}, | ||
], | ||
"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" }, | ||
], | ||
"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", | ||
"arrow-body-style": "off", | ||
"no-unused-expressions": "off", | ||
|
||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/explicit-function-return-type": "off", | ||
|
||
"import/prefer-default-export": "off", | ||
"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"], | ||
}, | ||
}, | ||
]; |
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,11 @@ | ||
const { version } = require("../package.json") | ||
|
||
//------------------------------------------------------------------------------ | ||
// Public Interface | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = [{ | ||
configs: { | ||
all: require("./configs/eslint-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,90 @@ | ||
"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, | ||
reactPlugin.configs.recommended, | ||
reactHooksPlugin.configs.recommended, | ||
reactPerfPlugin.configs.recommended, | ||
jsxA11yPlugin.configs.recommended, | ||
saluteRulesPlugin.configs.all, | ||
prettierPlugin.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', | ||
|
||
'jsx-a11y/no-static-element-interactions': 'off', | ||
'jsx-a11y/click-events-have-key-events': 'off', | ||
'jsx-a11y/no-noninteractive-tabindex': 'off', | ||
|
||
'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', | ||
}, | ||
}, | ||
], | ||
'prettier/prettier': ['error', prettierConfig], | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.tsx?'], | ||
languageOptions: { | ||
globals: { | ||
window: true, | ||
document: true, | ||
}, | ||
}, | ||
rules: { | ||
'react/no-unknown-property': 'error', | ||
}, | ||
}, | ||
], | ||
settings: { | ||
react: { | ||
version: '18.3.1', | ||
}, | ||
}, | ||
}, | ||
]; |
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