@diplodoc/lint 1.0.0 → 1.0.2
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 +27 -0
- package/README.md +1 -1
- package/bin/eslint +12 -0
- package/bin/husky +12 -0
- package/bin/lint +23 -21
- package/bin/lint-staged +12 -0
- package/bin/prettier +12 -0
- package/bin/stylelint +12 -0
- package/bin/svgo +12 -0
- package/eslint-common-config.js +11 -3
- package/package.json +9 -3
- package/scaffolding/.husky/pre-commit +0 -3
- package/scaffolding/.lintstagedrc.js +2 -2
- package/scripts/modify-ignore.js +3 -9
- package/scripts/modify-package.js +10 -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,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.2](https://github.com/diplodoc-platform/lint/compare/v1.0.1...v1.0.2) (2024-08-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* Change init staps sequence ([7f8aaa5](https://github.com/diplodoc-platform/lint/commit/7f8aaa54f758dbfe58adbbda6ec0a9e5cb556baa))
|
|
9
|
+
* Do not rewrite husky npm script ([f0b1b85](https://github.com/diplodoc-platform/lint/commit/f0b1b85e2ba86cafc85d91f844ebb09c081c8ed2))
|
|
10
|
+
* Make internal bins force executable ([d69f85e](https://github.com/diplodoc-platform/lint/commit/d69f85e1e60e0cd6fb9f7c3b0648785191eb065d))
|
|
11
|
+
* Unignore rc configs ([cf201c6](https://github.com/diplodoc-platform/lint/commit/cf201c694ee4de91d6c7a98326ec07ee52254fb8))
|
|
12
|
+
|
|
13
|
+
## [1.0.1](https://github.com/diplodoc-platform/lint/compare/v1.0.0...v1.0.1) (2024-08-11)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* Add special rules for eslintrc.json ([bb4b615](https://github.com/diplodoc-platform/lint/commit/bb4b615e75c5099f343871fb6fcbea4ab119d14a))
|
|
19
|
+
* Extend lint-staged files lists ([b0229aa](https://github.com/diplodoc-platform/lint/commit/b0229aa0bb779d26a66717326c53a620e258d277))
|
|
20
|
+
* Fix install script ([9ea0d07](https://github.com/diplodoc-platform/lint/commit/9ea0d07cba75b0ef736477280ce92528726e2e5a))
|
|
21
|
+
* Fix shell script ([8743493](https://github.com/diplodoc-platform/lint/commit/8743493d09b067dd06d4d16e53288a9d2f1a7763))
|
|
22
|
+
* Fix windows specific ([c96a28c](https://github.com/diplodoc-platform/lint/commit/c96a28c10b393ff19000e4db37ce8d3ad7cdb11a))
|
|
23
|
+
* Fix Windows specific ([e4531c4](https://github.com/diplodoc-platform/lint/commit/e4531c46aaae4d3d27d4f1d2ecc4e8baab373730))
|
|
24
|
+
* Proxy all lint binary ([e9615cd](https://github.com/diplodoc-platform/lint/commit/e9615cdba5394b5433a3e523e2468754a04724a8))
|
|
25
|
+
* Proxy husky bin ([3ff236a](https://github.com/diplodoc-platform/lint/commit/3ff236a6561721e769b4b242f17ede10f115de61))
|
|
26
|
+
* Remove useless install command ([c9fce40](https://github.com/diplodoc-platform/lint/commit/c9fce40c67482ac04a145d0920c0bd1fc9edaf97))
|
|
27
|
+
* Skip useless css linting for node projects ([603d093](https://github.com/diplodoc-platform/lint/commit/603d09384f40e514acd795e708ca987845c52e5c))
|
|
28
|
+
* Use update instead of init on lint run ([ec23ed1](https://github.com/diplodoc-platform/lint/commit/ec23ed1392c5ccba58318f5a975e28baef6a3458))
|
|
29
|
+
|
|
3
30
|
## 1.0.0 (2024-08-10)
|
|
4
31
|
|
|
5
32
|
|
package/README.md
CHANGED
package/bin/eslint
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
BINDIR=$(dirname $(node -pe "require.resolve('eslint/package.json')"))
|
|
4
|
+
|
|
5
|
+
if [[ -z "$BINDIR" ]]; then
|
|
6
|
+
echo "Required package 'eslint' not found"
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
# Redirect to original eslint bin
|
|
11
|
+
chmod +x $BINDIR/bin/eslint.js
|
|
12
|
+
$BINDIR/bin/eslint.js $@
|
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,19 @@ while (( $# )); do
|
|
|
20
20
|
shift
|
|
21
21
|
done
|
|
22
22
|
|
|
23
|
-
if [[ -n $INIT
|
|
23
|
+
if [[ -n "$INIT$UPDATE" ]]; then
|
|
24
|
+
if [[ -n $INIT ]]; then
|
|
25
|
+
echo "[@diplodoc/lint] Extend package.json configuration"
|
|
26
|
+
node "$SRCDIR/scripts/modify-package.js"
|
|
27
|
+
|
|
28
|
+
$BINDIR/husky init
|
|
29
|
+
fi
|
|
30
|
+
|
|
24
31
|
echo "[@diplodoc/lint] Add initial lint configs"
|
|
25
|
-
cp -
|
|
32
|
+
cp -a "$SRCDIR/scaffolding/." .
|
|
26
33
|
|
|
27
34
|
echo "[@diplodoc/lint] Extend .ignore configuration"
|
|
28
35
|
node "$SRCDIR/scripts/modify-ignore.js"
|
|
29
|
-
fi
|
|
30
|
-
|
|
31
|
-
if [[ -n $INIT ]]; then
|
|
32
|
-
echo "[@diplodoc/lint] Extend package.json configuration"
|
|
33
|
-
node "$SRCDIR/scripts/modify-package.js"
|
|
34
|
-
|
|
35
|
-
$BINDIR/husky install
|
|
36
36
|
|
|
37
37
|
exit 0
|
|
38
38
|
fi
|
|
@@ -40,17 +40,19 @@ fi
|
|
|
40
40
|
if [[ -n $FIX ]]; then
|
|
41
41
|
echo "Run linters in fix mode"
|
|
42
42
|
|
|
43
|
-
$BINDIR/eslint '**/*.{js,jsx,ts,tsx}' --fix
|
|
44
|
-
$BINDIR/prettier --write '
|
|
45
|
-
$
|
|
43
|
+
$BINDIR/eslint '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}' --fix
|
|
44
|
+
$BINDIR/prettier --write '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
|
|
45
|
+
if [[ -n $(find . -type f -name '*.css' -name '*.scss' | grep -vwFf .stylelintignore) ]]; then
|
|
46
|
+
$BINDIR/stylelint '**/*.{css,scss}' --fix
|
|
47
|
+
fi
|
|
46
48
|
|
|
47
49
|
exit 0
|
|
48
50
|
fi
|
|
49
51
|
|
|
50
52
|
echo "Run linters"
|
|
51
53
|
|
|
52
|
-
$BINDIR/eslint '**/*.{js,jsx,ts,tsx}'
|
|
53
|
-
$BINDIR/prettier --check '
|
|
54
|
-
$
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
$BINDIR/eslint '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
|
|
55
|
+
$BINDIR/prettier --check '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
|
|
56
|
+
if [[ -n $(find . -type f -name '*.css' -name '*.scss' | grep -vwFf .stylelintignore) ]]; then
|
|
57
|
+
$BINDIR/stylelint '**/*.{css,scss}'
|
|
58
|
+
fi
|
package/bin/lint-staged
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
chmod +x $BINDIR/bin/lint-staged.js
|
|
12
|
+
$BINDIR/bin/lint-staged.js $@
|
package/bin/prettier
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
BINDIR=$(dirname $(node -pe "require.resolve('prettier')"))
|
|
4
|
+
|
|
5
|
+
if [[ -z "$BINDIR" ]]; then
|
|
6
|
+
echo "Required package 'prettier' not found"
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
# Redirect to original prettier bin
|
|
11
|
+
chmod +x $BINDIR/bin/prettier.cjs
|
|
12
|
+
$BINDIR/bin/prettier.cjs $@
|
package/bin/stylelint
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
chmod +x $BINDIR/bin/stylelint.mjs
|
|
12
|
+
$BINDIR/bin/stylelint.mjs $@
|
package/bin/svgo
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
BINDIR=$(dirname $(node -pe "require.resolve('svgo/package.json')"))
|
|
4
|
+
|
|
5
|
+
if [[ -z "$BINDIR" ]]; then
|
|
6
|
+
echo "Required package 'svgo' not found"
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
# Redirect to original svgo bin
|
|
11
|
+
chmod +x $BINDIR/bin/svgo
|
|
12
|
+
$BINDIR/bin/svgo $@
|
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.2",
|
|
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',
|
|
@@ -23,13 +24,6 @@ const ignores = {
|
|
|
23
24
|
...SYSTEM,
|
|
24
25
|
...INSTALL,
|
|
25
26
|
...ARTIFACTS,
|
|
26
|
-
'/.eslintrc.js',
|
|
27
|
-
'/.prettierrc.js',
|
|
28
|
-
'/.stylelintrc.js',
|
|
29
|
-
'/.lintstagedrc.js',
|
|
30
|
-
// '/.eslinignore',
|
|
31
|
-
// '/.prettierignore',
|
|
32
|
-
// '/.stylelintignore',
|
|
33
27
|
],
|
|
34
28
|
'.eslintignore': [
|
|
35
29
|
...SYSTEM,
|
|
@@ -49,7 +43,7 @@ const ignores = {
|
|
|
49
43
|
};
|
|
50
44
|
|
|
51
45
|
for (const [file, list] of Object.entries(ignores)) {
|
|
52
|
-
const filename = process.cwd()
|
|
46
|
+
const filename = join(process.cwd(), file);
|
|
53
47
|
|
|
54
48
|
let source;
|
|
55
49
|
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,19 @@ 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');
|
|
26
27
|
|
|
27
28
|
writeFileSync(filename, JSON.stringify(pkg, null, 2), 'utf8');
|