arui-presets-lint 8.0.0-beta.2 → 8.0.0-beta.4
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 +8 -28
- package/V8_MIGRATION_GUIDE.md +0 -1
- package/cli/index.mjs +30 -10
- package/lefthook/index.yml +25 -0
- package/package.json +6 -21
- package/husky/index.js +0 -7
- package/lint-staged/index.mjs +0 -5
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
Далее произвести следующие настройки:
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Подключение конфигов через `package.json`:
|
|
30
30
|
|
|
31
31
|
```json
|
|
32
32
|
{
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
}
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
## Конфигурация скриптов для запуска
|
|
46
|
+
## Конфигурация скриптов для запуска в `package.json`:
|
|
47
47
|
|
|
48
48
|
```json
|
|
49
49
|
{
|
|
50
50
|
"scripts": {
|
|
51
|
-
"lint": "arui-presets-lint lint",
|
|
52
|
-
"lint:fix": "arui-presets-lint fix",
|
|
53
51
|
"lint:css": "arui-presets-lint css",
|
|
54
52
|
"lint:scripts": "arui-presets-lint scripts",
|
|
53
|
+
"lint": "arui-presets-lint lint",
|
|
54
|
+
"lint:fix": "arui-presets-lint fix",
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
```
|
|
@@ -59,35 +59,15 @@
|
|
|
59
59
|
Если eslint/stylelint/prettier затрагивают файлы, над которыми вы не имеете контроль, вы можете исключить
|
|
60
60
|
их с помощью [.eslintignore](https://eslint.org/docs/latest/user-guide/configuring/ignoring-code#the-eslintignore-file) / [.stylelintignore](https://stylelint.io/user-guide/ignore-code/#files-entirely) / [.prettierignore](https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore)
|
|
61
61
|
|
|
62
|
-
> ⚠️ Внимание, .eslintignore [по умолчанию не подтягиватся в lint-staged](https://github.com/okonet/lint-staged#how-can-i-ignore-files-from-eslintignore)!
|
|
63
|
-
|
|
64
62
|
Для запуска eslint/stylelint рекомендуется использовать флаг [--max-warnings](https://eslint.org/docs/latest/user-guide/command-line-interface#--max-warnings), который позволяет ограничить количество возникающих предупреждений.
|
|
65
63
|
|
|
66
|
-
## Конфигурация [lint-staged](https://github.com/lint-staged/lint-staged):
|
|
67
|
-
|
|
68
|
-
.lintstagedrc.js
|
|
69
|
-
```js
|
|
70
|
-
export default 'arui-presets-lint/lint-staged'
|
|
71
64
|
```
|
|
72
65
|
|
|
73
|
-
## Конфигурация [
|
|
74
|
-
|
|
75
|
-
Для настройки git hooks рекомендуется использовать библиотеки [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks), либо [husky@4](https://github.com/typicode/husky/tree/v4.3.8)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
### Пример конфигурации для simple-git-hooks:
|
|
79
|
-
|
|
80
|
-
.simple-git-hooks.js
|
|
81
|
-
```js
|
|
82
|
-
module.exports = require('arui-presets-lint/hooks/simple-git-hooks');
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
### Пример конфигурации для husky@4:
|
|
66
|
+
## Конфигурация [lefthook](https://github.com/evilmartians/lefthook)
|
|
87
67
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
68
|
+
```yaml
|
|
69
|
+
extends:
|
|
70
|
+
- arui-presets-lint/lefthook/index.yml
|
|
91
71
|
```
|
|
92
72
|
|
|
93
73
|
## Настройка IDE:
|
package/V8_MIGRATION_GUIDE.md
CHANGED
|
@@ -3,4 +3,3 @@
|
|
|
3
3
|
```bash
|
|
4
4
|
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 kebab-case
|
|
5
5
|
```
|
|
6
|
-
|
package/cli/index.mjs
CHANGED
|
@@ -7,23 +7,43 @@ const prettierParams = '"./**/*.{ts,tsx,js,jsx,css,json}" --no-error-on-unmatche
|
|
|
7
7
|
const commandsMap = {
|
|
8
8
|
lint: `yarn lint:css && yarn lint:scripts && prettier --check ${prettierParams}`,
|
|
9
9
|
fix: `yarn lint:css --fix && yarn lint:scripts --fix && prettier --write ${prettierParams}`,
|
|
10
|
-
css: 'stylelint "**/*.css" --allow-empty-input --ignore-path .gitignore --ignore-path .stylelintignore',
|
|
10
|
+
css: 'stylelint "**/*.css" --allow-empty-input --ignore-path .gitignore --ignore-path .stylelintignore --cache',
|
|
11
11
|
scripts:
|
|
12
|
-
'eslint "**/*.{js,jsx,ts,tsx}" --ext .js,.jsx,.ts,.tsx --ignore-pattern=.gitignore,.eslintignore',
|
|
13
|
-
|
|
14
|
-
stage: 'lint-staged',
|
|
12
|
+
'eslint "**/*.{js,jsx,ts,tsx}" --ext .js,.jsx,.ts,.tsx --ignore-pattern=.gitignore,.eslintignore --cache',
|
|
13
|
+
run: (...args) => args.join(' '),
|
|
15
14
|
};
|
|
16
15
|
|
|
16
|
+
const commands = Object.keys(commandsMap);
|
|
17
17
|
const command = process.argv[2];
|
|
18
|
+
const commandValue = commandsMap[command];
|
|
18
19
|
const args = process.argv.slice(3);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
let exec;
|
|
22
|
+
|
|
23
|
+
if (!command || !commands.includes(command)) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.error(`Please specify one of available commands: ${commands.join(' ')}`);
|
|
26
|
+
|
|
27
|
+
process.exit(-1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (typeof commandValue === 'function') {
|
|
31
|
+
exec = commandValue(...args);
|
|
32
|
+
} else {
|
|
33
|
+
exec = [commandValue, ...args].join(' ');
|
|
34
|
+
}
|
|
21
35
|
|
|
22
36
|
// eslint-disable-next-line no-console
|
|
23
37
|
console.log(exec);
|
|
24
38
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
try {
|
|
40
|
+
await execaCommand(exec, {
|
|
41
|
+
shell: true,
|
|
42
|
+
preferLocal: true,
|
|
43
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
44
|
+
});
|
|
45
|
+
} catch (error) {
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
console.error(error.message);
|
|
48
|
+
process.exit(error.exitCode);
|
|
49
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Refer for explanation to following link:
|
|
2
|
+
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
|
|
3
|
+
|
|
4
|
+
pre-push:
|
|
5
|
+
parallel: true
|
|
6
|
+
commands:
|
|
7
|
+
lint:
|
|
8
|
+
run: yarn lint
|
|
9
|
+
pre-commit:
|
|
10
|
+
parallel: true
|
|
11
|
+
commands:
|
|
12
|
+
js:
|
|
13
|
+
glob: '*.{js,ts,jsx,tsx,mts,mjs,cjs,cts}'
|
|
14
|
+
run: npx --no-install prettier --write {staged_files} && npx --no-install eslint {staged_files} && git add {staged_files}
|
|
15
|
+
css:
|
|
16
|
+
glob: '*.{css}'
|
|
17
|
+
run: npx --no-install prettier --write {staged_files} && npx --no-install stylelint --fix {staged_files} && git add {staged_files}
|
|
18
|
+
json:
|
|
19
|
+
glob: '*.{json}'
|
|
20
|
+
run: npx --no-install prettier --write {staged_files} && git add {staged_files}
|
|
21
|
+
commit-msg:
|
|
22
|
+
parallel: true
|
|
23
|
+
commands:
|
|
24
|
+
commitlint:
|
|
25
|
+
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.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.4",
|
|
4
4
|
"description": "Config files for arui-apps",
|
|
5
5
|
"author": "core-ds contributors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"eslint-plugin-react-hooks": "4.6.2",
|
|
25
25
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
26
26
|
"eslint-plugin-unicorn": "55.0.0",
|
|
27
|
-
"execa": "9.4.
|
|
27
|
+
"execa": "9.4.1",
|
|
28
28
|
"kebab-case": "1.0.0",
|
|
29
|
-
"
|
|
29
|
+
"lefthook": "1.8.0",
|
|
30
30
|
"prettier": "3.3.3",
|
|
31
|
-
"stylelint": "16.
|
|
31
|
+
"stylelint": "16.10.0"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=18.12.0"
|
|
@@ -43,30 +43,15 @@
|
|
|
43
43
|
"@semantic-release/release-notes-generator": "12.1.0",
|
|
44
44
|
"react": "18.3.1",
|
|
45
45
|
"semantic-release": "22.0.12",
|
|
46
|
-
"simple-git-hooks": "2.11.1",
|
|
47
46
|
"typescript": "5.5.4"
|
|
48
47
|
},
|
|
49
48
|
"scripts": {
|
|
50
|
-
"precommit": "node ./cli/index.mjs stage",
|
|
51
49
|
"test": "yarn lint:scripts && eslint-config-prettier ./eslint/index.js && yarn lint:css && prettier --check \"./**/*.{ts,tsx,js,jsx,css,json}\"",
|
|
52
50
|
"lint:css": "node ./cli/index.mjs css",
|
|
53
51
|
"lint:scripts": "node ./cli/index.mjs scripts",
|
|
52
|
+
"lint": "node ./cli/index.mjs lint",
|
|
54
53
|
"lint:fix": "node ./cli/index.mjs fix"
|
|
55
54
|
},
|
|
56
|
-
"lint-staged": {
|
|
57
|
-
"**/*.{js,jsx,ts,tsx,json}": [
|
|
58
|
-
"prettier --write",
|
|
59
|
-
"eslint --fix --max-warnings=0"
|
|
60
|
-
],
|
|
61
|
-
"stylelint/*.js": [
|
|
62
|
-
"prettier --write",
|
|
63
|
-
"yarn lint:css"
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
"simple-git-hooks": {
|
|
67
|
-
"pre-commit": "yarn test",
|
|
68
|
-
"commit-msg": "yarn commitlint --edit $1"
|
|
69
|
-
},
|
|
70
55
|
"prettier": "./prettier",
|
|
71
56
|
"stylelint": {
|
|
72
57
|
"extends": "./stylelint"
|
|
@@ -87,5 +72,5 @@
|
|
|
87
72
|
"commitlint": {
|
|
88
73
|
"extends": "./commitlint"
|
|
89
74
|
},
|
|
90
|
-
"packageManager": "yarn@4.5.
|
|
75
|
+
"packageManager": "yarn@4.5.1"
|
|
91
76
|
}
|
package/husky/index.js
DELETED