Skip to content

Commit b0234c3

Browse files
committed
Add linting
1 parent 863e4ce commit b0234c3

File tree

4 files changed

+1794
-1
lines changed

4 files changed

+1794
-1
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
/dist

.eslintrc.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
module.exports = {
2+
parser: "@typescript-eslint/parser",
3+
extends: [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/eslint-recommended",
6+
"plugin:@typescript-eslint/recommended",
7+
"plugin:import/errors",
8+
"plugin:import/typescript",
9+
"prettier",
10+
],
11+
plugins: ["@typescript-eslint", "simple-import-sort", "import"],
12+
parserOptions: {
13+
ecmaVersion: 2018,
14+
sourceType: "module",
15+
},
16+
env: {
17+
node: true,
18+
es6: true,
19+
},
20+
globals: {
21+
NodeJS: false, // For TypeScript
22+
},
23+
rules: {
24+
"no-unused-vars": 0,
25+
"@typescript-eslint/no-unused-vars": [
26+
"error",
27+
{
28+
argsIgnorePattern: "^_",
29+
varsIgnorePattern: "^_",
30+
args: "after-used",
31+
ignoreRestSiblings: true,
32+
},
33+
],
34+
curly: "error",
35+
"no-else-return": 0,
36+
"no-return-assign": [2, "except-parens"],
37+
"no-underscore-dangle": 0,
38+
camelcase: 0,
39+
"prefer-arrow-callback": [
40+
"error",
41+
{
42+
allowNamedFunctions: true,
43+
},
44+
],
45+
"class-methods-use-this": 0,
46+
"no-restricted-syntax": 0,
47+
"no-param-reassign": [
48+
"error",
49+
{
50+
props: false,
51+
},
52+
],
53+
54+
"arrow-body-style": 0,
55+
"no-nested-ternary": 0,
56+
57+
/*
58+
* simple-import-sort seems to be the most stable import sorting currently,
59+
* disable others
60+
*/
61+
"simple-import-sort/imports": "error",
62+
"simple-import-sort/exports": "error",
63+
"sort-imports": "off",
64+
"import/order": "off",
65+
66+
"import/no-deprecated": "warn",
67+
"import/no-duplicates": "error",
68+
// Doesn't support 'exports'?
69+
"import/no-unresolved": "off",
70+
"@typescript-eslint/ban-ts-comment": "off",
71+
"@typescript-eslint/no-namespace": "off",
72+
},
73+
overrides: [
74+
{
75+
files: ["__tests__/**/*", "test.js"],
76+
rules: {
77+
"@typescript-eslint/no-explicit-any": 0,
78+
"@typescript-eslint/explicit-function-return-type": 0,
79+
"@typescript-eslint/no-var-requires": 0,
80+
"@typescript-eslint/ban-ts-comment": 0,
81+
},
82+
},
83+
{
84+
files: ["perfTest/**/*", "examples/**/*"],
85+
rules: {
86+
"@typescript-eslint/no-var-requires": 0,
87+
},
88+
},
89+
],
90+
};

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
},
1010
"scripts": {
1111
"test": "node --test",
12-
"watch": "tsc --watch"
12+
"watch": "tsc --watch",
13+
"lint": "yarn prettier:check && eslint --ext .js,.jsx,.ts,.tsx,.graphql .",
14+
"lint:fix": "eslint --ext .js,.jsx,.ts,.tsx,.graphql . --fix; prettier --cache --ignore-path .eslintignore --write '**/*.{js,jsx,ts,tsx,graphql,md,json}'",
15+
"prettier:check": "prettier --cache --ignore-path .eslintignore --check '**/*.{js,jsx,ts,tsx,graphql,md,json}'"
1316
},
1417
"repository": {
1518
"type": "git",
@@ -47,6 +50,13 @@
4750
"devDependencies": {
4851
"@tsconfig/recommended": "^1.0.7",
4952
"@types/node": "^22.5.4",
53+
"@typescript-eslint/eslint-plugin": "^6.8.0",
54+
"@typescript-eslint/parser": "^6.8.0",
55+
"eslint": "^8.51.0",
56+
"eslint-config-prettier": "^9.0.0",
57+
"eslint-plugin-import": "^2.28.1",
58+
"eslint-plugin-simple-import-sort": "^10.0.0",
59+
"eslint_d": "^13.0.0",
5060
"prettier": "^3.3.3",
5161
"typescript": "^5.6.2"
5262
},

0 commit comments

Comments
 (0)