Skip to content

Commit 9277f21

Browse files
authored
fix: add eslint check and fix scripts (#87)
Signed-off-by: Denis Golovin <[email protected]>
1 parent f96c30b commit 9277f21

6 files changed

+2705
-404
lines changed

.eslintcache

+1
Large diffs are not rendered by default.

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test-resources
2+
scripts
3+
builtin/**
4+
www
5+
*.config.js
6+
types/**/*.ts
7+
__mocks__

.eslintrc.json

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"es2021": true,
5+
"node": true,
6+
"browser": false
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
/** @see https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#recommended-configs */
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:import/recommended",
13+
"plugin:import/typescript",
14+
"plugin:etc/recommended",
15+
"plugin:sonarjs/recommended"
16+
],
17+
"parser": "@typescript-eslint/parser",
18+
"parserOptions": {
19+
"ecmaVersion": 12,
20+
"sourceType": "module",
21+
"warnOnUnsupportedTypeScriptVersion": false,
22+
"project": [
23+
"tsconfig.json"
24+
]
25+
},
26+
"overrides": [
27+
{
28+
// enable the rule specifically for TypeScript files
29+
"files": ["*.ts"],
30+
"rules": {
31+
"@typescript-eslint/explicit-function-return-type": "error"
32+
}
33+
}
34+
],
35+
"settings": {
36+
"import/resolver": {
37+
"typescript": true,
38+
"node": true,
39+
"eslint-import-resolver-custom-alias": {
40+
"alias": {
41+
"/@": "./src",
42+
"/@gen": "./src-generated"
43+
},
44+
"extensions": [".ts"],
45+
"packages": []
46+
}
47+
}
48+
},
49+
"plugins": [
50+
"@typescript-eslint",
51+
"sonarjs",
52+
"etc",
53+
"redundant-undefined",
54+
"no-null",
55+
"header",
56+
"simple-import-sort",
57+
"unicorn"
58+
],
59+
"ignorePatterns": [
60+
"node_modules/**",
61+
"dist/**",
62+
"builtin/**"
63+
],
64+
"rules": {
65+
"eqeqeq": "error",
66+
"@typescript-eslint/explicit-function-return-type": "off",
67+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
68+
"@typescript-eslint/no-var-requires": "off",
69+
"@typescript-eslint/consistent-type-imports": "error",
70+
"@typescript-eslint/no-explicit-any": "error",
71+
"prefer-promise-reject-errors": "error",
72+
"@typescript-eslint/await-thenable": "error",
73+
"@typescript-eslint/no-floating-promises": "error",
74+
"@typescript-eslint/no-misused-promises": "error",
75+
"@typescript-eslint/prefer-optional-chain": "error",
76+
"no-null/no-null": "error",
77+
78+
/**
79+
* Having a semicolon helps the optimizer interpret your code correctly.
80+
* This avoids rare errors in optimized code.
81+
* @see https://twitter.com/alex_kozack/status/1364210394328408066
82+
*/
83+
"semi": ["error", "always"],
84+
/**
85+
* This will make the history of changes in the hit a little cleaner
86+
*/
87+
"comma-dangle": ["warn", "always-multiline"],
88+
/**
89+
* Just for beauty
90+
*/
91+
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
92+
"import/no-duplicates": "error",
93+
"import/no-unresolved": "off",
94+
"import/default": "off",
95+
"import/no-named-as-default-member": "off",
96+
"import/no-named-as-default": "off",
97+
"import/first": "error",
98+
"import/newline-after-import": "error",
99+
"sonarjs/cognitive-complexity": "off",
100+
"sonarjs/no-duplicate-string": "off",
101+
"sonarjs/no-empty-collection": "off",
102+
"sonarjs/no-small-switch": "off",
103+
"etc/no-commented-out-code": "error",
104+
"etc/no-deprecated": "off",
105+
"redundant-undefined/redundant-undefined": "error",
106+
"import/no-extraneous-dependencies": "error",
107+
"header/header": [2, "block", [{ "pattern": "SPDX-License-Identifier: Apache-2\\.0" }]],
108+
"simple-import-sort/imports": "error",
109+
"simple-import-sort/exports": "error",
110+
"unicorn/prefer-node-protocol": "error"
111+
}
112+
}

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"watch": "rollup --bundleConfigAsCjs --config rollup.config.js -w",
2424
"format:check": "prettier --cache --check \"{src,types,scripts}/**/*.{ts,js}\"",
2525
"format:fix": "prettier --cache --write \"{src,types,scripts}/**/*.{ts,js}\"",
26+
"lint:clean": "rimraf .eslintcache",
27+
"lint:fix": "node --max-old-space-size=6144 node_modules/eslint/bin/eslint.js --cache . --fix --ext js,ts",
28+
"lint:check": "node --max-old-space-size=6144 node_modules/eslint/bin/eslint.js --cache . --ext js,ts",
2629
"test": "vitest run --coverage"
2730
},
2831
"dependencies": {
@@ -41,7 +44,20 @@
4144
"@rollup/plugin-node-resolve": "^15.0.2",
4245
"@rollup/plugin-typescript": "^11.1.0",
4346
"@types/js-yaml": "^4.0.5",
47+
"@typescript-eslint/eslint-plugin": "^7.0.0",
48+
"@typescript-eslint/parser": "^6.21.0",
4449
"@vitest/coverage-v8": "^1.2.1",
50+
"eslint": "^8.57.0",
51+
"eslint-import-resolver-custom-alias": "^1.3.2",
52+
"eslint-import-resolver-typescript": "^3.6.1",
53+
"eslint-plugin-etc": "^2.0.3",
54+
"eslint-plugin-header": "^3.1.1",
55+
"eslint-plugin-import": "^2.29.1",
56+
"eslint-plugin-no-null": "^1.0.2",
57+
"eslint-plugin-redundant-undefined": "^1.0.0",
58+
"eslint-plugin-simple-import-sort": "^12.0.0",
59+
"eslint-plugin-sonarjs": "^0.24.0",
60+
"eslint-plugin-unicorn": "^51.0.1",
4561
"mkdirp": "^2.1.3",
4662
"prettier": "^3.2.5",
4763
"rollup": "^3.20.4",

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"allowSyntheticDefaultImports": true
1515
},
1616
"include": [
17-
"src"
17+
"src/**/*.ts"
1818
]
1919
}

0 commit comments

Comments
 (0)