arui-presets-lint 9.0.1 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -2
- package/V9_MIGRATION_GUIDE.md +8 -3
- package/eslint/index.ts +10 -14
- package/eslint/rules/best-practices.ts +0 -4
- package/eslint/rules/index.ts +8 -0
- package/package.json +6 -13
- package/stylelint/index.js +103 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
{
|
|
35
35
|
"prettier": "arui-presets-lint/prettier",
|
|
36
36
|
"stylelint": { "extends": "arui-presets-lint/stylelint" },
|
|
37
|
-
"commitlint": { "extends": "
|
|
37
|
+
"commitlint": { "extends": "arui-presets-lint/commitlint" }
|
|
38
38
|
}
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -70,6 +70,45 @@ export default defineConfig(eslintConfig, [
|
|
|
70
70
|
]);
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
Если в проекте есть файлы typescript, которые не добавлены в `tsconfig.json`, или исключены из него принудительно, то eslint выдаст ошибку `<filename> was not found by the project service. Consider either including it in the tsconfig.json or including it in allowDefaultProject`. Есть несколько способов решения этой проблемы:
|
|
74
|
+
|
|
75
|
+
- (Рекомендуется) Добавить нужные файлы через опцию allowDefaultProject:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { eslintConfig } from 'arui-presets-lint/eslint';
|
|
79
|
+
import { defineConfig } from 'arui-presets-lint/eslint/config';
|
|
80
|
+
|
|
81
|
+
export default defineConfig(eslintConfig, [
|
|
82
|
+
{
|
|
83
|
+
languageOptions: {
|
|
84
|
+
parserOptions: {
|
|
85
|
+
projectService: {
|
|
86
|
+
// Это позволит eslint линтить файлы, даже если они не указаны в tsconfig.json
|
|
87
|
+
// Обратите внимание, что включить '**' тут нельзя, влияет на производительность!
|
|
88
|
+
// https://typescript-eslint.io/packages/parser/#allowdefaultproject
|
|
89
|
+
// Конретно тут - разрешаем линтить все файлы с расширениями .ts, .mts и .cts в корневой директории проекта
|
|
90
|
+
allowDefaultProject: ['*.ts', '*.mts', '*.cts'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
files: ['**/*.{ts,tsx,mts,cts,mtsx,ctsx}'],
|
|
95
|
+
},
|
|
96
|
+
]);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- (НЕ рекомендуется) Добавить файлы в globalIgnores. В этом случае eslint не будет его проверять:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { eslintConfig } from 'arui-presets-lint/eslint';
|
|
103
|
+
import { defineConfig } from 'arui-presets-lint/eslint/config';
|
|
104
|
+
|
|
105
|
+
export default defineConfig(eslintConfig, [
|
|
106
|
+
{
|
|
107
|
+
globalIgnores(['eslint.config.mts', 'arui-scripts.config.ts', 'playwright.config.ts']),
|
|
108
|
+
},
|
|
109
|
+
]);
|
|
110
|
+
```
|
|
111
|
+
|
|
73
112
|
## Конфигурация скриптов для запуска в `package.json`:
|
|
74
113
|
|
|
75
114
|
```json
|
|
@@ -87,7 +126,12 @@ export default defineConfig(eslintConfig, [
|
|
|
87
126
|
|
|
88
127
|
Чтобы eslint / stylelint / prettier не проверял конкретные файлы и папки, можно исключить их с помощью файлов .stylelintignore / .prettierignore / .eslintignore Прописывать там файлы, которые уже есть в .gitignore не требуется!
|
|
89
128
|
|
|
90
|
-
> Вместо файла .eslintignore рекомендуется использовать
|
|
129
|
+
> Вместо файла .eslintignore рекомендуется использовать globalIgnores в конфиге eslint ([подробнее](https://eslint.org/docs/latest/use/configure/ignore)). Импортируем функцию globalIgnores из `arui-presets-lint` вот так:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { defineConfig, globalIgnores } from 'arui-presets-lint/eslint/config';
|
|
133
|
+
...
|
|
134
|
+
```
|
|
91
135
|
|
|
92
136
|
> Для запуска eslint/stylelint рекомендуется использовать флаг [--max-warnings](https://eslint.org/docs/latest/user-guide/command-line-interface#--max-warnings), который позволяет ограничить количество возникающих предупреждений.
|
|
93
137
|
|
package/V9_MIGRATION_GUIDE.md
CHANGED
|
@@ -55,16 +55,21 @@ export default defineConfig(eslintConfig, [
|
|
|
55
55
|
languageOptions: {
|
|
56
56
|
parserOptions: {
|
|
57
57
|
projectService: {
|
|
58
|
-
// Это позволит eslint линтить
|
|
59
|
-
//
|
|
60
|
-
|
|
58
|
+
// Это позволит eslint линтить файлы, даже если они не указаны в tsconfig.json
|
|
59
|
+
// Обратите внимание, что включить '**' тут нельзя, влияет на производительность!
|
|
60
|
+
// https://typescript-eslint.io/packages/parser/#allowdefaultproject
|
|
61
|
+
// Конретно тут - разрешаем линтить все файлы с расширениями .ts, .mts и .cts в корневой директории проекта
|
|
62
|
+
allowDefaultProject: ['*.ts', '*.mts', '*.cts'],
|
|
61
63
|
},
|
|
62
64
|
},
|
|
63
65
|
},
|
|
66
|
+
files: ['**/*.{ts,tsx,mts,cts,mtsx,ctsx}'],
|
|
64
67
|
},
|
|
65
68
|
]);
|
|
66
69
|
```
|
|
67
70
|
|
|
71
|
+
Так же можно исключить этот файл через globalIgnores (не рекомендуется), подробнее в README.md
|
|
72
|
+
|
|
68
73
|
3. import >> import-x
|
|
69
74
|
|
|
70
75
|
Нужно пробежаться по проекту и заменить подобные комментарии:
|
package/eslint/index.ts
CHANGED
|
@@ -3,15 +3,17 @@ import { type Linter } from 'eslint';
|
|
|
3
3
|
import gitignore from 'eslint-config-flat-gitignore';
|
|
4
4
|
import globals from 'globals';
|
|
5
5
|
|
|
6
|
-
import { bestPracticesConfig } from './rules/best-practices';
|
|
7
|
-
import { importsConfig } from './rules/imports';
|
|
8
|
-
import { nodeRulesConfig } from './rules/node';
|
|
9
|
-
import { reactConfig } from './rules/react';
|
|
10
|
-
import { reactA11yConfig } from './rules/react-a11y';
|
|
11
|
-
import { testsConfig } from './rules/tests';
|
|
12
|
-
import { typescriptConfig } from './rules/typescript';
|
|
13
|
-
import { variablesConfig } from './rules/variables';
|
|
14
6
|
import { globalIgnores } from './config';
|
|
7
|
+
import {
|
|
8
|
+
bestPracticesConfig,
|
|
9
|
+
importsConfig,
|
|
10
|
+
nodeRulesConfig,
|
|
11
|
+
reactA11yConfig,
|
|
12
|
+
reactConfig,
|
|
13
|
+
testsConfig,
|
|
14
|
+
typescriptConfig,
|
|
15
|
+
variablesConfig,
|
|
16
|
+
} from './rules';
|
|
15
17
|
|
|
16
18
|
export const eslintConfig = [
|
|
17
19
|
gitignore({
|
|
@@ -38,12 +40,6 @@ export const eslintConfig = [
|
|
|
38
40
|
sourceType: 'module',
|
|
39
41
|
parserOptions: {
|
|
40
42
|
ecmaFeatures: { jsx: true },
|
|
41
|
-
projectService: {
|
|
42
|
-
// Разрешаем линтить файлы в корне проекта, даже если они не включены в tsconfig.json
|
|
43
|
-
// ⛔️ Внимание, включить '**' тут нельзя, влияет на производительность!
|
|
44
|
-
// https://typescript-eslint.io/packages/parser/#allowdefaultproject
|
|
45
|
-
allowDefaultProject: ['*.js', '*.ts', '*.mjs', '*.mts', '*.cts', '*.cjs'],
|
|
46
|
-
},
|
|
47
43
|
},
|
|
48
44
|
globals: {
|
|
49
45
|
...globals.es2022,
|
|
@@ -93,10 +93,6 @@ export const bestPracticesConfig: TSESLint.FlatConfig.Config = {
|
|
|
93
93
|
// https://eslint.org/docs/rules/no-bitwise
|
|
94
94
|
'no-bitwise': 'error',
|
|
95
95
|
|
|
96
|
-
// Запрещает оператор continue
|
|
97
|
-
// https://eslint.org/docs/rules/no-continue
|
|
98
|
-
'no-continue': 'error',
|
|
99
|
-
|
|
100
96
|
// Запрещает if как единственный оператор в блоке else
|
|
101
97
|
// https://eslint.org/docs/rules/no-lonely-if
|
|
102
98
|
'no-lonely-if': 'error',
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { bestPracticesConfig } from './best-practices';
|
|
2
|
+
export { importsConfig } from './imports';
|
|
3
|
+
export { nodeRulesConfig } from './node';
|
|
4
|
+
export { reactA11yConfig } from './react-a11y';
|
|
5
|
+
export { reactConfig } from './react';
|
|
6
|
+
export { testsConfig } from './tests';
|
|
7
|
+
export { typescriptConfig } from './typescript';
|
|
8
|
+
export { variablesConfig } from './variables';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arui-presets-lint",
|
|
3
|
-
"version": "9.0
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "Config files for arui-apps",
|
|
5
5
|
"author": "core-ds contributors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@commitlint/config-conventional": "20.4.1",
|
|
17
17
|
"@eslint/js": "9.39.2",
|
|
18
18
|
"@types/eslint-plugin-jsx-a11y": "6.10.1",
|
|
19
|
-
"@typescript-eslint/utils": "8.
|
|
19
|
+
"@typescript-eslint/utils": "8.55.0",
|
|
20
20
|
"eslint": "9.39.2",
|
|
21
21
|
"eslint-config-flat-gitignore": "2.1.0",
|
|
22
22
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"eslint-plugin-react": "7.37.5",
|
|
28
28
|
"eslint-plugin-react-hooks": "7.0.1",
|
|
29
29
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
30
|
-
"eslint-plugin-unicorn": "
|
|
30
|
+
"eslint-plugin-unicorn": "63.0.0",
|
|
31
31
|
"execa": "^9.6.1",
|
|
32
32
|
"globals": "^17.0.0",
|
|
33
33
|
"jiti": "^2.6.1",
|
|
34
|
-
"lefthook": "2.1.
|
|
34
|
+
"lefthook": "2.1.1",
|
|
35
35
|
"prettier": "3.8.1",
|
|
36
36
|
"stylelint": "16.26.1",
|
|
37
|
-
"typescript-eslint": "8.
|
|
37
|
+
"typescript-eslint": "8.55.0"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=18.18.0"
|
|
@@ -71,14 +71,7 @@
|
|
|
71
71
|
"exports": {
|
|
72
72
|
"./eslint": "./eslint/index.ts",
|
|
73
73
|
"./eslint/config": "./eslint/config.ts",
|
|
74
|
-
"./eslint/
|
|
75
|
-
"./eslint/imports": "./eslint/imports.ts",
|
|
76
|
-
"./eslint/node": "./eslint/node.ts",
|
|
77
|
-
"./eslint/react-a11y": "./eslint/react-a11y.ts",
|
|
78
|
-
"./eslint/react": "./eslint/react.ts",
|
|
79
|
-
"./eslint/tests": "./eslint/tests.ts",
|
|
80
|
-
"./eslint/typescript": "./eslint/typescript.ts",
|
|
81
|
-
"./eslint/variables": "./eslint/variables.ts",
|
|
74
|
+
"./eslint/rules": "./eslint/rules/index.ts",
|
|
82
75
|
"./prettier": "./prettier/index.js",
|
|
83
76
|
"./commitlint": "./commitlint/index.js",
|
|
84
77
|
"./stylelint": "./stylelint/index.js"
|
package/stylelint/index.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
rules: {
|
|
3
|
+
// Запрещает пустые блоки
|
|
4
|
+
// https://stylelint.io/user-guide/rules/block-no-empty
|
|
3
5
|
'block-no-empty': true,
|
|
6
|
+
|
|
7
|
+
// Требует короткую форму hex-цветов
|
|
8
|
+
// https://stylelint.io/user-guide/rules/color-hex-length
|
|
4
9
|
'color-hex-length': 'short',
|
|
10
|
+
|
|
11
|
+
// Запрещает невалидные hex-цвета
|
|
12
|
+
// https://stylelint.io/user-guide/rules/color-no-invalid-hex
|
|
5
13
|
'color-no-invalid-hex': true,
|
|
14
|
+
|
|
15
|
+
// Требует пустую строку перед комментариями
|
|
16
|
+
// https://stylelint.io/user-guide/rules/comment-empty-line-before
|
|
6
17
|
'comment-empty-line-before': [
|
|
7
18
|
'always',
|
|
8
19
|
{
|
|
@@ -10,8 +21,17 @@ export default {
|
|
|
10
21
|
ignore: ['stylelint-commands'],
|
|
11
22
|
},
|
|
12
23
|
],
|
|
24
|
+
|
|
25
|
+
// Запрещает пустые комментарии
|
|
26
|
+
// https://stylelint.io/user-guide/rules/comment-no-empty
|
|
13
27
|
'comment-no-empty': true,
|
|
28
|
+
|
|
29
|
+
// Требует пробелы внутри комментариев
|
|
30
|
+
// https://stylelint.io/user-guide/rules/comment-whitespace-inside
|
|
14
31
|
'comment-whitespace-inside': 'always',
|
|
32
|
+
|
|
33
|
+
// Требует пустую строку перед custom properties
|
|
34
|
+
// https://stylelint.io/user-guide/rules/custom-property-empty-line-before
|
|
15
35
|
'custom-property-empty-line-before': [
|
|
16
36
|
'always',
|
|
17
37
|
{
|
|
@@ -19,29 +39,86 @@ export default {
|
|
|
19
39
|
ignore: ['after-comment', 'inside-single-line-block'],
|
|
20
40
|
},
|
|
21
41
|
],
|
|
42
|
+
|
|
43
|
+
// Запрещает переопределение shorthand-свойств длинными формами
|
|
44
|
+
// https://stylelint.io/user-guide/rules/declaration-block-no-shorthand-property-overrides
|
|
22
45
|
'declaration-block-no-shorthand-property-overrides': true,
|
|
46
|
+
|
|
47
|
+
// Ограничивает количество деклараций в однострочном блоке
|
|
48
|
+
// https://stylelint.io/user-guide/rules/declaration-block-single-line-max-declarations
|
|
23
49
|
'declaration-block-single-line-max-declarations': 2,
|
|
50
|
+
|
|
51
|
+
// Требует пробелы вокруг операторов в calc()
|
|
52
|
+
// https://stylelint.io/user-guide/rules/function-calc-no-unspaced-operator
|
|
24
53
|
'function-calc-no-unspaced-operator': true,
|
|
54
|
+
|
|
55
|
+
// Запрещает нестандартные направления в linear-gradient()
|
|
56
|
+
// https://stylelint.io/user-guide/rules/function-linear-gradient-no-nonstandard-direction
|
|
25
57
|
'function-linear-gradient-no-nonstandard-direction': true,
|
|
58
|
+
|
|
59
|
+
// Требует нижний регистр для имeн функций
|
|
60
|
+
// https://stylelint.io/user-guide/rules/function-name-case
|
|
26
61
|
'function-name-case': 'lower',
|
|
62
|
+
|
|
63
|
+
// Запрещает !important в keyframe-декларациях
|
|
64
|
+
// https://stylelint.io/user-guide/rules/keyframe-declaration-no-important
|
|
27
65
|
'keyframe-declaration-no-important': true,
|
|
66
|
+
|
|
67
|
+
// Запрещает единицы измерения для нулевых значений длины
|
|
68
|
+
// https://stylelint.io/user-guide/rules/length-zero-no-unit
|
|
28
69
|
'length-zero-no-unit': true,
|
|
70
|
+
|
|
71
|
+
// Запрещает пустые исходники
|
|
72
|
+
// https://stylelint.io/user-guide/rules/no-empty-source
|
|
29
73
|
'no-empty-source': true,
|
|
74
|
+
|
|
75
|
+
// Запрещает невалидные двойные слэш-комментарии
|
|
76
|
+
// https://stylelint.io/user-guide/rules/no-invalid-double-slash-comments
|
|
30
77
|
'no-invalid-double-slash-comments': true,
|
|
78
|
+
|
|
79
|
+
// Запрещает неизвестные псевдоклассы
|
|
80
|
+
// https://stylelint.io/user-guide/rules/selector-pseudo-class-no-unknown
|
|
31
81
|
'selector-pseudo-class-no-unknown': [
|
|
32
82
|
true,
|
|
33
83
|
{
|
|
34
84
|
ignorePseudoClasses: ['global'],
|
|
35
85
|
},
|
|
36
86
|
],
|
|
87
|
+
|
|
88
|
+
// Требует одинарную нотацию для псевдоэлементов (:)
|
|
89
|
+
// https://stylelint.io/user-guide/rules/selector-pseudo-element-colon-notation
|
|
37
90
|
'selector-pseudo-element-colon-notation': 'single',
|
|
91
|
+
|
|
92
|
+
// Запрещает неизвестные псевдоэлементы
|
|
93
|
+
// https://stylelint.io/user-guide/rules/selector-pseudo-element-no-unknown
|
|
38
94
|
'selector-pseudo-element-no-unknown': true,
|
|
95
|
+
|
|
96
|
+
// Требует нижний регистр для селекторов типов
|
|
97
|
+
// https://stylelint.io/user-guide/rules/selector-type-case
|
|
39
98
|
'selector-type-case': 'lower',
|
|
99
|
+
|
|
100
|
+
// Запрещает неизвестные селекторы типов
|
|
101
|
+
// https://stylelint.io/user-guide/rules/selector-type-no-unknown
|
|
40
102
|
'selector-type-no-unknown': true,
|
|
103
|
+
|
|
104
|
+
// Запрещает избыточные значения в shorthand-свойствах
|
|
105
|
+
// https://stylelint.io/user-guide/rules/shorthand-property-no-redundant-values
|
|
41
106
|
'shorthand-property-no-redundant-values': true,
|
|
107
|
+
|
|
108
|
+
// Запрещает переносы строк в строках
|
|
109
|
+
// https://stylelint.io/user-guide/rules/string-no-newline
|
|
42
110
|
'string-no-newline': true,
|
|
111
|
+
|
|
112
|
+
// Запрещает неизвестные единицы измерения
|
|
113
|
+
// https://stylelint.io/user-guide/rules/unit-no-unknown
|
|
43
114
|
'unit-no-unknown': true,
|
|
115
|
+
|
|
116
|
+
// Запрещает дублирующиеся селекторы
|
|
117
|
+
// https://stylelint.io/user-guide/rules/no-duplicate-selectors
|
|
44
118
|
'no-duplicate-selectors': true,
|
|
119
|
+
|
|
120
|
+
// Запрещает дублирующиеся свойства в блоке
|
|
121
|
+
// https://stylelint.io/user-guide/rules/declaration-block-no-duplicate-properties
|
|
45
122
|
'declaration-block-no-duplicate-properties': [
|
|
46
123
|
true,
|
|
47
124
|
{
|
|
@@ -49,19 +126,44 @@ export default {
|
|
|
49
126
|
},
|
|
50
127
|
],
|
|
51
128
|
|
|
129
|
+
// Требует использовать CSS-переменные дизайн-системы вместо хардкода
|
|
130
|
+
// https://github.com/core-ds/stylelint-core-vars
|
|
52
131
|
'stylelint-core-vars/use-vars': true,
|
|
132
|
+
|
|
133
|
+
// Требует использовать миксины дизайн-системы
|
|
134
|
+
// https://github.com/core-ds/stylelint-core-vars
|
|
53
135
|
'stylelint-core-vars/use-mixins': true,
|
|
136
|
+
|
|
137
|
+
// Рекомендует использовать один из доступных vars при выборе значения
|
|
138
|
+
// https://github.com/core-ds/stylelint-core-vars
|
|
54
139
|
'stylelint-core-vars/use-one-of-vars': [true, { severity: 'warning' }],
|
|
140
|
+
|
|
141
|
+
// Рекомендует использовать один из доступных mixins при выборе
|
|
142
|
+
// https://github.com/core-ds/stylelint-core-vars
|
|
55
143
|
'stylelint-core-vars/use-one-of-mixins': [true, { severity: 'warning' }],
|
|
144
|
+
|
|
145
|
+
// Предупреждает об использовании тeмных цветов напрямую
|
|
146
|
+
// https://github.com/core-ds/stylelint-core-vars
|
|
56
147
|
'stylelint-core-vars/do-not-use-dark-colors': [true, { severity: 'warning' }],
|
|
148
|
+
|
|
149
|
+
// Требует пустую строку перед правилами
|
|
150
|
+
// https://stylelint.io/user-guide/rules/rule-empty-line-before
|
|
151
|
+
'rule-empty-line-before': [
|
|
152
|
+
'always',
|
|
153
|
+
{
|
|
154
|
+
except: ['first-nested'],
|
|
155
|
+
ignore: ['after-comment'],
|
|
156
|
+
},
|
|
157
|
+
],
|
|
57
158
|
},
|
|
58
159
|
plugins: ['@alfalab/stylelint-core-vars'],
|
|
59
160
|
overrides: [
|
|
60
161
|
{
|
|
61
162
|
files: ['*.module.css'],
|
|
62
163
|
rules: {
|
|
164
|
+
// Запрещает дефис в классах (требует camelCase или snake_case)
|
|
165
|
+
// https://stylelint.io/user-guide/rules/selector-class-pattern
|
|
63
166
|
'selector-class-pattern': [
|
|
64
|
-
// Запрещаем использовать дефис '-'
|
|
65
167
|
'^[^-]+$',
|
|
66
168
|
{
|
|
67
169
|
resolveNestedSelectors: true,
|