arui-presets-lint 8.2.0-beta.1 → 8.3.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 CHANGED
@@ -63,6 +63,7 @@
63
63
  Для запуска eslint/stylelint рекомендуется использовать флаг [--max-warnings](https://eslint.org/docs/latest/user-guide/command-line-interface#--max-warnings), который позволяет ограничить количество возникающих предупреждений.
64
64
 
65
65
  Пример такой конфигурации:
66
+
66
67
  ```json
67
68
  {
68
69
  "scripts": {
@@ -89,27 +90,24 @@ extends:
89
90
  extends:
90
91
  - ./node_modules/arui-presets-lint/lefthook/index.yml
91
92
 
92
-
93
93
  pre-commit:
94
94
  commands:
95
-
96
- # Добавить сборку typescript на pre-commit:
95
+ # Добавить сборку typescript на pre-commit:
97
96
  check-ts:
98
97
  run: npx --no-install tsc --noEmit
99
98
 
100
- # Запустить тесты, относящиеся к измененному файлу:
99
+ # Запустить тесты, относящиеся к измененному файлу:
101
100
  run-tests:
102
101
  glob: '*.{js,ts,jsx,tsx,mts,mjs,cjs,cts}'
103
102
  run: npx --no-install jest --findRelatedTests --passWithNoTests {staged_files}
104
103
 
105
- # Запустить команду 'lint' на pre-push:
106
104
  pre-push:
107
105
  commands:
106
+ # Запустить команду 'lint' на pre-push:
108
107
  run-lint:
109
108
  run: yarn lint
110
109
  ```
111
110
 
112
-
113
111
  ## Гибкая конфигурация
114
112
 
115
113
  Так как `yarn run` в yarn 2+ не поддерживает возможность запускать бинарные файлы, которые не установлены как прямые зависимости, а `yarn dlx` не умеет запускать бинарники без скачивания его из npm, существует возможность это сделать через вызов `npx --no-install ...`:
@@ -128,13 +126,16 @@ npx --no-install eslint "**/*.{js,jsx}" --ext .js,.jsx --ignore-pattern=.gitigno
128
126
  Таким образом можно гибко настраивать поведение линтеров для вашего проекта, если по какой-то причине стандартная конфигурация вам не подходит.
129
127
 
130
128
  ## Дебаг
129
+
131
130
  Если нужно увидеть в консоли чему именно соответствует алиас в cli-утилите, нужно запустить arui-presets-lint с флагом --echo, например:
131
+
132
132
  ```sh
133
133
  yarn arui-presets-lint --echo format
134
134
  # >> prettier --write "./**/*.{ts,tsx,js,jsx,mjs,mts,cjs,cts,css,json}" --no-error-on-unmatched-pattern --cache
135
135
  ```
136
136
 
137
137
  Если нужно посмотреть, какой именно конфиг применяется в текущем проекте:
138
+
138
139
  ```sh
139
140
  # eslint:
140
141
  npx --no-install eslint --print-config file.tsx > eslintconfig.json
@@ -146,7 +147,6 @@ npx --no-install stylelint --print-config file.css > stylelintconfig.json
146
147
  npx --no-install commitlint --print-config > commitlintconfig.txt
147
148
  ```
148
149
 
149
-
150
150
  ## Настройка IDE:
151
151
 
152
152
  1. Включить ESLint
@@ -1,22 +1,26 @@
1
1
  # Гид по миграции на arui-presets-lint@8
2
2
 
3
3
  ## Введение
4
+
4
5
  Обновление содержит в себе множество изменений, которые позволяют работать с конфигурацией линтеров в проектах проще. Ключевые изменения:
5
- - Поставляется готовая конфигурация lefthook - инструмента, который заменяет lint-staged и husky
6
- - Больше никаких peer dependency - работа с ними вызывала боль, инструменты по их автоматической установке не работают в yarn 4. Никто больше не сможет сломать вашу конфигурацию случайным поднятием зависимости
7
- - CLI для запуска команд позволяет не писать копипасту в каждом проекте
8
- - Новые решения гибкие - возможность писать собственные команды остается, как и возможность расширить конфигурацию lefthook (см [README](./README.md))
6
+
7
+ - Поставляется готовая конфигурация lefthook - инструмента, который заменяет lint-staged и husky
8
+ - Больше никаких peer dependency - работа с ними вызывала боль, инструменты по их автоматической установке не работают в yarn 4. Никто больше не сможет сломать вашу конфигурацию случайным поднятием зависимости
9
+ - CLI для запуска команд позволяет не писать копипасту в каждом проекте
10
+ - Новые решения гибкие - возможность писать собственные команды остается, как и возможность расширить конфигурацию lefthook (см [README](./README.md))
9
11
 
10
12
  1. Для начала нужно выполнить команду:
11
13
 
12
14
  ```bash
13
15
  yarn remove eslint eslint-config-airbnb eslint-config-airbnb-typescript eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-cypress eslint-plugin-dirnames eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-simple-import-sort eslint-plugin-unicorn lint-staged prettier stylelint @typescript-eslint/parser @typescript-eslint/eslint-plugin stylelint-config-prettier husky kebab-case @commitlint/cli @commitlint/config-conventional
14
16
  ```
17
+
15
18
  -- отмечу, что никаких зависимостей с плагинами stylelint/eslint в проекте быть не должно, кроме тех, которые использует ваш локальный конфиг
16
19
 
17
- 2. Удалить конфигурации husky и lint-staged (могут находится в .husky, .huskyrc.js, package.json.husky, .lintstagedrc.js, package.json.lint-staged, итп). Для husky 5+ нужно также удалить настройку .git/config `hooksPath = .husky` из `git/config`.
20
+ 2. Удалить конфигурации husky и lint-staged (могут находится в .husky, .huskyrc.js, package.json.husky, .lintstagedrc.js, package.json.lint-staged, итп). Для husky 5+ нужно также удалить настройку `hooksPath = .husky` из `git/config`.
18
21
 
19
22
  3. Добавить в lefthook.yml следующее:
23
+
20
24
  ```yml
21
25
  extends:
22
26
  - ./node_modules/arui-presets-lint/lefthook/index.yml
@@ -30,28 +34,28 @@ extends:
30
34
 
31
35
  pre-commit:
32
36
  commands:
33
-
34
- # Добавить сборку typescript на pre-commit:
37
+ # Добавить сборку typescript на pre-commit:
35
38
  check-ts:
36
39
  run: npx --no-install tsc --noEmit
37
40
 
38
- # Запустить тесты, относящиеся к измененному файлу:
41
+ # Запустить тесты, относящиеся к измененному файлу:
39
42
  run-tests:
40
43
  glob: '*.{js,ts,jsx,tsx,mts,mjs,cjs,cts}'
41
44
  run: npx --no-install jest --findRelatedTests --passWithNoTests {staged_files}
42
45
 
43
- # Запустить команду 'lint' на pre-push:
44
46
  pre-push:
45
47
  commands:
48
+ # Запустить команду 'lint' на pre-push:
46
49
  run-lint:
47
50
  run: yarn lint
48
51
  ```
49
52
 
50
-
51
53
  4. Выполнить следующую команду:
54
+
52
55
  ```
53
56
  npx --no-install lefthook install
54
57
  ```
58
+
55
59
  чтобы установить новую конфигурацию git-hooks. Отмечу, что в библиотеке lefthook есть скрипт, который делает это автоматически при каждой установке библиотеки arui-presets-lint.
56
60
 
57
61
  5. Поменять команды для запуска в package.json.scripts, они должны выглядить следующим образом:
@@ -69,16 +73,16 @@ npx --no-install lefthook install
69
73
  }
70
74
  ```
71
75
 
72
- 6. Выполнить команду ```yarn lint:fix```, и исправить возникающие ошибки
76
+ 6. Выполнить команду `yarn lint:fix`, и исправить возникающие ошибки
73
77
 
74
78
  ## Возможные проблемы и способы их решения:
75
79
 
76
80
  > Q: Получаю ошибку `node_modules/.bin/prettier: Permission denied`
77
81
 
78
82
  > A: Это плавающая проблема с установкой библиотеки prettier, которая решается командой: `chmod +x ./node_modules/.bin/prettier`
79
- Происходит такое только на системах macOS [issue](https://github.com/prettier/prettier/issues/15164)
83
+ > Происходит такое только на системах macOS [issue](https://github.com/prettier/prettier/issues/15164)
80
84
 
81
85
  > Q: Отображается warning при изменении файла, который не должен проверятся eslint:
82
- `0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to disable file ignore settings or use "--no-warn-ignored" to suppress this warning.`
86
+ > `0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to disable file ignore settings or use "--no-warn-ignored" to suppress this warning.`
83
87
 
84
88
  > A: Это ожидаемое поведение, eslint не будет пытаться изменить файл. Warning будет отключен в рамках [issue](https://github.com/core-ds/arui-presets-lint/issues/28), следите за обновлениями
package/cli/index.mjs CHANGED
@@ -18,7 +18,6 @@ const enableEcho = process.argv[2] === '--echo';
18
18
  const command = enableEcho ? process.argv[3] : process.argv[2];
19
19
 
20
20
  if (!command || !commands.includes(command)) {
21
- // eslint-disable-next-line no-console
22
21
  console.error(`Please specify one of available commands: ${commands.join(' ')}`);
23
22
 
24
23
  process.exit(-1);
@@ -29,7 +28,6 @@ const args = enableEcho ? process.argv.slice(4) : process.argv.slice(3);
29
28
  const exec = [commandsMap[command], ...args].join(' ');
30
29
 
31
30
  if (enableEcho) {
32
- // eslint-disable-next-line no-console
33
31
  console.log('>>', exec);
34
32
  }
35
33
 
@@ -40,7 +38,6 @@ try {
40
38
  stdio: ['pipe', 'inherit', 'inherit'],
41
39
  });
42
40
  } catch (error) {
43
- // eslint-disable-next-line no-console
44
41
  console.error(error.message);
45
42
  process.exit(error.exitCode);
46
43
  }
@@ -14,7 +14,6 @@ pre-commit:
14
14
  glob: '*.{json}'
15
15
  run: npx --no-install prettier --write {staged_files} --cache && git add {staged_files}
16
16
  commit-msg:
17
- parallel: true
18
17
  commands:
19
18
  commitlint:
20
19
  run: npx --no-install commitlint --edit {1}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arui-presets-lint",
3
- "version": "8.2.0-beta.1",
3
+ "version": "8.3.0",
4
4
  "description": "Config files for arui-apps",
5
5
  "author": "core-ds contributors",
6
6
  "license": "MIT",
@@ -68,7 +68,8 @@
68
68
  "test/**/*"
69
69
  ]
70
70
  }
71
- ]
71
+ ],
72
+ "no-console": "off"
72
73
  }
73
74
  },
74
75
  "commitlint": {
@@ -28,7 +28,12 @@ module.exports = {
28
28
  'length-zero-no-unit': true,
29
29
  'no-empty-source': true,
30
30
  'no-invalid-double-slash-comments': true,
31
- 'selector-pseudo-class-no-unknown': true,
31
+ 'selector-pseudo-class-no-unknown': [
32
+ true,
33
+ {
34
+ ignorePseudoClasses: ['global'],
35
+ },
36
+ ],
32
37
  'selector-pseudo-element-colon-notation': 'single',
33
38
  'selector-pseudo-element-no-unknown': true,
34
39
  'selector-type-case': 'lower',