Skip to content

Commit 79091c1

Browse files
authored
style: add eslint (#237)
See https://eslint.org/. Added the default "recommended" rules. Turned off failing rules to make the integration easier
1 parent e421fa8 commit 79091c1

File tree

5 files changed

+882
-13
lines changed

5 files changed

+882
-13
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Node.js CI
33
on: [push]
44

55
jobs:
6-
prettier:
6+
lint:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
@@ -14,7 +14,7 @@ jobs:
1414
cache: yarn
1515
cache-dependency-path: "**/yarn.lock"
1616
- run: yarn install
17-
- run: yarn prettier --check .
17+
- run: yarn lint
1818

1919
build:
2020
runs-on: ${{ matrix.os }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ import "normally-transformed"; // This will remain 'normally-transformed', even
199199
## Project Guidelines for Contributors
200200

201201
- Package Manager: `yarn` (`yarn install`)
202-
- Format before commit: `prettier` (`yarn format`)
202+
- Format and lint the code before commit: `prettier` (`yarn format && yarn lint`)
203203
- Commit messages: [Conventional Commit Specs](https://www.conventionalcommits.org/en/v1.0.0/)
204204
- Releases: `changelogen` (`yarn release`)
205205

eslint.config.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
import tseslint from "typescript-eslint";
4+
5+
export default [
6+
{ files: ["**/*.{js,mjs,cjs,ts}"] },
7+
{ ignores: ["**/dist/", "src/declarations/", "test/projects/"] },
8+
{ languageOptions: { globals: globals.node } },
9+
pluginJs.configs.recommended,
10+
...tseslint.configs.recommended,
11+
{
12+
rules: {
13+
"@typescript-eslint/ban-ts-comment": "warn",
14+
"@typescript-eslint/no-empty-object-type": "warn",
15+
"@typescript-eslint/no-explicit-any": "off",
16+
"@typescript-eslint/no-namespace": "warn",
17+
"@typescript-eslint/no-require-imports": "off",
18+
"@typescript-eslint/no-unsafe-function-type": "warn",
19+
"@typescript-eslint/no-unused-vars": "warn",
20+
"no-case-declarations": "warn",
21+
"no-empty": "warn",
22+
"no-useless-escape": "warn",
23+
"prefer-const": "off",
24+
"prefer-rest-params": "warn",
25+
"prefer-spread": "warn",
26+
},
27+
},
28+
];

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"release": "changelogen --release --push",
1212
"--------------": "",
1313
"format": "prettier --write .",
14+
"lint": "prettier --check . && eslint .",
1415
"clean": "rm -rf \"**/dist\"",
1516
"clean:all": "yarn clean && rm -rf node_modules \"**/node_modules\" \"**/yarn.lock\" yarn.lock",
1617
"reset": "yarn clean:all && yarn install && yarn build",
@@ -53,15 +54,20 @@
5354
"nx-transformer.js"
5455
],
5556
"devDependencies": {
57+
"@eslint/js": "^9.8.0",
5658
"@tsconfig/node18": "^18.2.4",
59+
"@types/eslint": "^9",
5760
"@types/minimatch": "^5.1.2",
5861
"@types/node": "^18.19.43",
5962
"@types/ts-expose-internals": "npm:[email protected]",
6063
"@types/ts-node": "npm:ts-node@^10.9.2",
6164
"changelogen": "^0.5.5",
65+
"eslint": "9.x",
66+
"globals": "^15.9.0",
6267
"prettier": "^3.3.3",
6368
"ts-patch": "^3.2.1",
64-
"typescript": "^5.5.4"
69+
"typescript": "^5.5.4",
70+
"typescript-eslint": "^8.0.1"
6571
},
6672
"peerDependencies": {
6773
"typescript": ">=3.6.5"

0 commit comments

Comments
 (0)