Skip to content

Commit

Permalink
refactored code and added new flat config for eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
pamellix committed Dec 24, 2024
1 parent 8707e62 commit 5b6b7e8
Show file tree
Hide file tree
Showing 12 changed files with 380 additions and 334 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,10 @@
"lerna": "8.1.8",
"prettier": "3.3.3",
"prettier-plugin-packagejson": "2.5.2"
},
"dependencies": {
"@salutejs/eslint-config": "2.9.4",
"@salutejs/eslint-config-base": "1.2.0",
"@salutejs/stylelint-config": "0.8.0"
}
}
86 changes: 86 additions & 0 deletions packages/eslint-config-base/flat/index.mjs
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',
},
},
];
149 changes: 67 additions & 82 deletions packages/eslint-config-base/index.mjs
Original file line number Diff line number Diff line change
@@ -1,86 +1,71 @@
"use strict"
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'],

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';
'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',

/** @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/explicit-function-return-type': 'off',

'@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',
},
'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',
},
];
};
7 changes: 5 additions & 2 deletions packages/eslint-config-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
"author": "Salute Frontend Team <[email protected]>",
"main": "index.js",
"exports": {
".": "./index.js",
"./flat": "./index.mjs"
".": {
"require": "./index.js",
"import": "./index.mjs"
},
"./flat": "./flat/index.mjs"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": ">=8",
Expand Down
79 changes: 0 additions & 79 deletions packages/eslint-config-base/src/configs/eslint-all.js

This file was deleted.

11 changes: 0 additions & 11 deletions packages/eslint-config-base/src/index.js

This file was deleted.

Loading

0 comments on commit 5b6b7e8

Please sign in to comment.