@diplodoc/lint 1.0.0 → 1.0.1
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/.github/workflows/tests.yml +32 -0
- package/CHANGELOG.md +17 -0
- package/README.md +1 -1
- package/bin/eslint +11 -0
- package/bin/husky +11 -0
- package/bin/lint +21 -15
- package/bin/lint-staged +11 -0
- package/bin/prettier +11 -0
- package/bin/stylelint +11 -0
- package/bin/svgo +11 -0
- package/eslint-common-config.js +11 -3
- package/package.json +9 -3
- package/scaffolding/.lintstagedrc.js +2 -2
- package/scripts/modify-ignore.js +3 -2
- package/scripts/modify-package.js +11 -9
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ['**']
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Node v${{ matrix.node-version }} on ${{ matrix.os }}
|
|
12
|
+
runs-on: ${{ matrix.os }}
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
17
|
+
node-version: [18.x]
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v2
|
|
21
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
22
|
+
uses: actions/setup-node@v2
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node-version }}
|
|
25
|
+
os: ${{ matrix.os }}
|
|
26
|
+
cache: 'npm'
|
|
27
|
+
- name: Install packages for project
|
|
28
|
+
run: npm ci
|
|
29
|
+
- name: Run tests
|
|
30
|
+
run: |
|
|
31
|
+
cd test
|
|
32
|
+
npm start
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.1](https://github.com/diplodoc-platform/lint/compare/v1.0.0...v1.0.1) (2024-08-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* Add special rules for eslintrc.json ([bb4b615](https://github.com/diplodoc-platform/lint/commit/bb4b615e75c5099f343871fb6fcbea4ab119d14a))
|
|
9
|
+
* Extend lint-staged files lists ([b0229aa](https://github.com/diplodoc-platform/lint/commit/b0229aa0bb779d26a66717326c53a620e258d277))
|
|
10
|
+
* Fix install script ([9ea0d07](https://github.com/diplodoc-platform/lint/commit/9ea0d07cba75b0ef736477280ce92528726e2e5a))
|
|
11
|
+
* Fix shell script ([8743493](https://github.com/diplodoc-platform/lint/commit/8743493d09b067dd06d4d16e53288a9d2f1a7763))
|
|
12
|
+
* Fix windows specific ([c96a28c](https://github.com/diplodoc-platform/lint/commit/c96a28c10b393ff19000e4db37ce8d3ad7cdb11a))
|
|
13
|
+
* Fix Windows specific ([e4531c4](https://github.com/diplodoc-platform/lint/commit/e4531c46aaae4d3d27d4f1d2ecc4e8baab373730))
|
|
14
|
+
* Proxy all lint binary ([e9615cd](https://github.com/diplodoc-platform/lint/commit/e9615cdba5394b5433a3e523e2468754a04724a8))
|
|
15
|
+
* Proxy husky bin ([3ff236a](https://github.com/diplodoc-platform/lint/commit/3ff236a6561721e769b4b242f17ede10f115de61))
|
|
16
|
+
* Remove useless install command ([c9fce40](https://github.com/diplodoc-platform/lint/commit/c9fce40c67482ac04a145d0920c0bd1fc9edaf97))
|
|
17
|
+
* Skip useless css linting for node projects ([603d093](https://github.com/diplodoc-platform/lint/commit/603d09384f40e514acd795e708ca987845c52e5c))
|
|
18
|
+
* Use update instead of init on lint run ([ec23ed1](https://github.com/diplodoc-platform/lint/commit/ec23ed1392c5ccba58318f5a975e28baef6a3458))
|
|
19
|
+
|
|
3
20
|
## 1.0.0 (2024-08-10)
|
|
4
21
|
|
|
5
22
|
|
package/README.md
CHANGED
package/bin/eslint
ADDED
package/bin/husky
ADDED
package/bin/lint
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
set -e
|
|
4
4
|
|
|
5
|
-
BINDIR=$(dirname $0)
|
|
6
|
-
SRCDIR=$(dirname $(dirname $(node -pe "require('fs').realpathSync('$0')")))
|
|
5
|
+
BINDIR=$(dirname "$0")
|
|
6
|
+
SRCDIR=$(dirname $(dirname $(node -pe "require('fs').realpathSync('${0//\\//}')")))
|
|
7
7
|
|
|
8
8
|
while (( $# )); do
|
|
9
9
|
case "$1" in
|
|
10
|
-
|
|
10
|
+
fix ) :
|
|
11
11
|
FIX=1
|
|
12
12
|
;;
|
|
13
|
-
|
|
13
|
+
init ) :
|
|
14
14
|
INIT=1
|
|
15
15
|
;;
|
|
16
16
|
update ) :
|
|
@@ -20,19 +20,23 @@ while (( $# )); do
|
|
|
20
20
|
shift
|
|
21
21
|
done
|
|
22
22
|
|
|
23
|
-
if [[ -n $INIT
|
|
23
|
+
if [[ -n "$INIT$UPDATE" ]]; then
|
|
24
24
|
echo "[@diplodoc/lint] Add initial lint configs"
|
|
25
|
-
cp -
|
|
25
|
+
cp -a "$SRCDIR/scaffolding/." .
|
|
26
26
|
|
|
27
27
|
echo "[@diplodoc/lint] Extend .ignore configuration"
|
|
28
28
|
node "$SRCDIR/scripts/modify-ignore.js"
|
|
29
|
+
|
|
30
|
+
if [[ -z $INIT ]]; then
|
|
31
|
+
exit 0
|
|
32
|
+
fi
|
|
29
33
|
fi
|
|
30
34
|
|
|
31
35
|
if [[ -n $INIT ]]; then
|
|
32
36
|
echo "[@diplodoc/lint] Extend package.json configuration"
|
|
33
37
|
node "$SRCDIR/scripts/modify-package.js"
|
|
34
38
|
|
|
35
|
-
$BINDIR/husky
|
|
39
|
+
$BINDIR/husky init
|
|
36
40
|
|
|
37
41
|
exit 0
|
|
38
42
|
fi
|
|
@@ -40,17 +44,19 @@ fi
|
|
|
40
44
|
if [[ -n $FIX ]]; then
|
|
41
45
|
echo "Run linters in fix mode"
|
|
42
46
|
|
|
43
|
-
$BINDIR/eslint '**/*.{js,jsx,ts,tsx}' --fix
|
|
44
|
-
$BINDIR/prettier --write '
|
|
45
|
-
$
|
|
47
|
+
$BINDIR/eslint '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}' --fix
|
|
48
|
+
$BINDIR/prettier --write '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
|
|
49
|
+
if [[ -n $(find . -type f -name '*.css' -name '*.scss' | grep -vwFf .stylelintignore) ]]; then
|
|
50
|
+
$BINDIR/stylelint '**/*.{css,scss}' --fix
|
|
51
|
+
fi
|
|
46
52
|
|
|
47
53
|
exit 0
|
|
48
54
|
fi
|
|
49
55
|
|
|
50
56
|
echo "Run linters"
|
|
51
57
|
|
|
52
|
-
$BINDIR/eslint '**/*.{js,jsx,ts,tsx}'
|
|
53
|
-
$BINDIR/prettier --check '
|
|
54
|
-
$
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
$BINDIR/eslint '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
|
|
59
|
+
$BINDIR/prettier --check '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
|
|
60
|
+
if [[ -n $(find . -type f -name '*.css' -name '*.scss' | grep -vwFf .stylelintignore) ]]; then
|
|
61
|
+
$BINDIR/stylelint '**/*.{css,scss}'
|
|
62
|
+
fi
|
package/bin/lint-staged
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
BINDIR=$(dirname $(node -pe "require.resolve('lint-staged/package.json')"))
|
|
4
|
+
|
|
5
|
+
if [[ -z "$BINDIR" ]]; then
|
|
6
|
+
echo "Required package 'lint-staged' not found"
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
# Redirect to original lint-staged bin
|
|
11
|
+
$BINDIR/bin/lint-staged.js $@
|
package/bin/prettier
ADDED
package/bin/stylelint
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
BINDIR=$(dirname $(node -pe "require.resolve('stylelint/package.json')"))
|
|
4
|
+
|
|
5
|
+
if [[ -z "$BINDIR" ]]; then
|
|
6
|
+
echo "Required package 'stylelint' not found"
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
# Redirect to original stylelint bin
|
|
11
|
+
$BINDIR/bin/stylelint.mjs $@
|
package/bin/svgo
ADDED
package/eslint-common-config.js
CHANGED
|
@@ -4,9 +4,17 @@ module.exports = {
|
|
|
4
4
|
'@gravity-ui/eslint-config',
|
|
5
5
|
process.env.npm_command && '@gravity-ui/eslint-config/prettier',
|
|
6
6
|
].filter(Boolean),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
overrides: [{
|
|
8
|
+
files: [
|
|
9
|
+
'.eslintrc.js',
|
|
10
|
+
'.prettierrc.js',
|
|
11
|
+
'.stylelintrc.js',
|
|
12
|
+
'.lintstagedrc.js',
|
|
13
|
+
],
|
|
14
|
+
env: {
|
|
15
|
+
node: true,
|
|
16
|
+
},
|
|
17
|
+
}],
|
|
10
18
|
rules: {
|
|
11
19
|
'callback-return': 'off',
|
|
12
20
|
'consistent-return': 'off',
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diplodoc/lint",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Diplodoc platform internal utility set for linting",
|
|
5
5
|
"bin": {
|
|
6
|
-
"lint": "./bin/lint"
|
|
6
|
+
"lint": "./bin/lint",
|
|
7
|
+
"husky": "./bin/husky",
|
|
8
|
+
"eslint": "./bin/eslint",
|
|
9
|
+
"prettier": "./bin/prettier",
|
|
10
|
+
"stylelint": "./bin/stylelint",
|
|
11
|
+
"lint-staged": "./bin/lint-staged",
|
|
12
|
+
"svgo": "./bin/svgo"
|
|
7
13
|
},
|
|
8
14
|
"scripts": {
|
|
9
|
-
"test": "
|
|
15
|
+
"test": "cd test && npm start"
|
|
10
16
|
},
|
|
11
17
|
"exports": {
|
|
12
18
|
"./eslint-config": "./eslint-common-config.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
'**/*.{js,jsx,ts,tsx}': ['prettier --write', 'eslint --max-warnings=0 --fix'],
|
|
2
|
+
'**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}': ['prettier --write', 'eslint --max-warnings=0 --fix'],
|
|
3
3
|
'**/*.{css,scss}': ['prettier --write', 'stylelint --fix'],
|
|
4
4
|
'**/*.{json,yaml,yml,md}': ['prettier --write'],
|
|
5
|
-
'**/*.{svg}': ['
|
|
5
|
+
'**/*.{svg}': ['svgo'],
|
|
6
6
|
};
|
package/scripts/modify-ignore.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {join} = require('node:path');
|
|
2
|
+
const {readFileSync, writeFileSync} = require('node:fs');
|
|
2
3
|
|
|
3
4
|
const SYSTEM = [
|
|
4
5
|
'.idea',
|
|
@@ -49,7 +50,7 @@ const ignores = {
|
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
for (const [file, list] of Object.entries(ignores)) {
|
|
52
|
-
const filename = process.cwd()
|
|
53
|
+
const filename = join(process.cwd(), file);
|
|
53
54
|
|
|
54
55
|
let source;
|
|
55
56
|
try {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const {readFileSync, writeFileSync} = require('fs');
|
|
1
|
+
const {join} = require('node:path');
|
|
2
|
+
const {readFileSync, writeFileSync} = require('node:fs');
|
|
3
|
+
|
|
4
|
+
const filename = join(process.cwd(), 'package.json');
|
|
3
5
|
|
|
4
6
|
let pkg;
|
|
5
7
|
try {
|
|
@@ -8,20 +10,20 @@ try {
|
|
|
8
10
|
throw 'Unable to modify ' + filename;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
function configure(command, impl) {
|
|
13
|
+
function configure(command, impl, strict = true) {
|
|
12
14
|
if (pkg.scripts[command]) {
|
|
13
|
-
if (pkg.scripts[command] !== impl) {
|
|
15
|
+
if (pkg.scripts[command] !== impl && strict) {
|
|
14
16
|
throw `Lint command '${command}' already configured with different program`;
|
|
15
17
|
}
|
|
16
18
|
} else {
|
|
17
19
|
pkg.scripts[command] = impl;
|
|
18
|
-
console.log('=> Add', command, 'script');
|
|
20
|
+
console.log('[@diplodoc/lint]', '=> Add', command, 'script');
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
configure('lint', 'lint
|
|
23
|
-
configure('lint:fix', 'lint
|
|
24
|
-
configure('pre-commit', 'lint
|
|
25
|
-
configure('prepare', 'husky install || true');
|
|
24
|
+
configure('lint', 'lint update && lint');
|
|
25
|
+
configure('lint:fix', 'lint update && lint fix');
|
|
26
|
+
configure('pre-commit', 'lint update && lint-staged');
|
|
27
|
+
configure('prepare', 'husky install || true', false);
|
|
26
28
|
|
|
27
29
|
writeFileSync(filename, JSON.stringify(pkg, null, 2), 'utf8');
|