Skip to content

Commit 33696a8

Browse files
committed
chore: stricter lint rules for tests
test codes should also be considered as source codes
1 parent bbe6d5d commit 33696a8

9 files changed

+42
-40
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
lib
2+
CHANGELOG.md

.eslintrc.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const { md, mdx } = require('@1stg/eslint-config/overrides')
1+
const { js, md, mdx } = require('@1stg/eslint-config/overrides')
22

33
module.exports = {
4-
extends: ['plugin:prettier/recommended'],
5-
overrides: [md, mdx],
4+
extends: ['@1stg'],
5+
overrides: [js, md, mdx],
66
rules: {
7-
'prettier/prettier': 2,
7+
'node/no-unsupported-features/es-syntax': 0,
88
},
99
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.type-coverage
12
lib
23
node_modules
34
*.log

.lintstagedrc

-14
This file was deleted.

.lintstagedrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@1stg/lint-staged')

codechecks.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ checks:
55
- path: 'lib/**/*.*'
66
- name: type-coverage-watcher
77
options:
8+
atLeast: 100
89
ignoreCatch: true
910
strict: true

package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
],
1919
"scripts": {
2020
"build": "rimraf lib && tsc -b src && r",
21-
"lint:md": "cross-env EFF_NO_LINK_RULES=true eslint . --ext md -f friendly",
22-
"lint:src": "cross-env EFF_NO_LINK_RULES=true eslint src --ext js,ts -f friendly",
23-
"lint": "run-p lint:*",
21+
"lint": "cross-env EFF_NO_LINK_RULES=true eslint . --ext md,js,ts -f friendly --ignore-pattern tests",
2422
"pretest": "r",
25-
"test": "eslint tests/**/index.ts",
23+
"test": "cross-env EFF_NO_LINK_RULES=true eslint tests/**/*.{ts,tsx} -f friendly",
2624
"type-coverage": "type-coverage --cache --ignore-catch --detail --strict"
2725
},
2826
"keywords": [
@@ -47,6 +45,7 @@
4745
"@1stg/babel-preset": "^0.6.1",
4846
"@1stg/eslint-config": "^0.9.3",
4947
"@1stg/husky-config": "^0.3.0",
48+
"@1stg/lint-staged": "^0.6.0",
5049
"@1stg/prettier-config": "^0.2.0",
5150
"@1stg/remark-config": "^0.2.1",
5251
"@1stg/rollup-config": "^0.9.3",
@@ -56,7 +55,7 @@
5655
"@commitlint/config-conventional": "^8.1.0",
5756
"@types/debug": "^4.1.5",
5857
"@types/glob": "^7.1.1",
59-
"@types/node": "^12.7.4",
58+
"@types/node": "^12.7.5",
6059
"@types/resolve": "^0.0.8",
6160
"@types/unist": "^2.0.3",
6261
"cross-env": "^5.2.1",

tests/baseEslintConfig.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
const path = require('path')
22

33
module.exports = dirname => ({
4-
env: {
5-
es6: true,
6-
},
7-
parserOptions: {
8-
ecmaVersion: 2018,
9-
sourceType: 'module',
4+
parser: '@typescript-eslint/parser',
5+
extends: [
6+
'eslint:recommended',
7+
'plugin:@typescript-eslint/eslint-recommended',
8+
'plugin:@typescript-eslint/recommended',
9+
'plugin:import/errors',
10+
'plugin:import/typescript',
11+
],
12+
settings: {
13+
'import/resolver': {
14+
[path.resolve(__dirname, '../lib/cjs.js')]: {
15+
directory: dirname,
16+
alwaysTryTypes: true,
17+
},
18+
},
1019
},
11-
plugins: ['import'],
1220
rules: {
13-
'import/no-unresolved': 'error',
21+
'import/no-duplicates': 0,
22+
'import/no-unresolved': 2,
1423
'import/extensions': [
15-
'error',
24+
2,
1625
'ignorePackages',
1726
{
1827
js: 'never',
@@ -21,13 +30,7 @@ module.exports = dirname => ({
2130
tsx: 'never',
2231
},
2332
],
24-
},
25-
settings: {
26-
'import/resolver': {
27-
[path.resolve(__dirname, '../lib/cjs.js')]: {
28-
directory: dirname,
29-
alwaysTryTypes: true,
30-
},
31-
},
33+
'node/no-extraneous-import': 0,
34+
'node/no-missing-import': 0,
3235
},
3336
})

yarn.lock

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
resolved "https://registry.yarnpkg.com/@1stg/husky-config/-/husky-config-0.3.0.tgz#dcf89d1f791dfd04d8d1a3fc1b59ba97c57ed6be"
4949
integrity sha512-YKVLG5lc/qKPyY9by/mVPdZLMe3s1FuO1d0mCmCogYl6VTWW/98LW80B4pMcDTmHPBTjZfKUAwgVBIvaYVthBA==
5050

51+
"@1stg/lint-staged@^0.6.0":
52+
version "0.6.0"
53+
resolved "https://registry.yarnpkg.com/@1stg/lint-staged/-/lint-staged-0.6.0.tgz#cdb0bca89e3815f1dfe28a9282b882d50b6bb241"
54+
integrity sha512-NedCH9PEjEVy0R/FH0LoviWJP/aX2a0MDiDFqv+Jv68MqCeXWFFT9suY3NcZTjEf034Ofn9+dJ+9Z80qujFHyA==
55+
5156
"@1stg/prettier-config@^0.2.0":
5257
version "0.2.0"
5358
resolved "https://registry.yarnpkg.com/@1stg/prettier-config/-/prettier-config-0.2.0.tgz#853c1142834f31d9287cd9e30f2b91d46e4961d6"
@@ -1412,6 +1417,11 @@
14121417
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.4.tgz#64db61e0359eb5a8d99b55e05c729f130a678b04"
14131418
integrity sha512-W0+n1Y+gK/8G2P/piTkBBN38Qc5Q1ZSO6B5H3QmPCUewaiXOo2GCAWZ4ElZCcNhjJuBSUSLGFUJnmlCn5+nxOQ==
14141419

1420+
"@types/node@^12.7.5":
1421+
version "12.7.5"
1422+
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.5.tgz#e19436e7f8e9b4601005d73673b6dc4784ffcc2f"
1423+
integrity sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w==
1424+
14151425
"@types/normalize-package-data@^2.4.0":
14161426
version "2.4.0"
14171427
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"

0 commit comments

Comments
 (0)