Skip to content

Commit be51617

Browse files
committed
Add eslint and prettier
1 parent e3519ed commit be51617

16 files changed

+124
-28
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*]
2+
charset = utf-8
3+
insert_final_newline = true
4+
end_of_line = lf
5+
indent_style = space
6+
indent_size = 2
7+
max_line_length = 80

.eslintignore

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

.eslintrc.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"overrides": [
3+
{
4+
"env": {
5+
"browser": true,
6+
"es2021": true
7+
},
8+
"files": ["*.ts"],
9+
"extends": ["@eslint-recommended/eslint-config-typescript", "prettier"],
10+
"parserOptions": {
11+
"project": "tsconfig.json",
12+
"ecmaVersion": "latest",
13+
"sourceType": "module"
14+
}
15+
},
16+
{
17+
"env": {
18+
"node": true,
19+
"es2021": true
20+
},
21+
"files": ["*.js"],
22+
"extends": ["eslint:recommended", "prettier"],
23+
"parserOptions": {
24+
"ecmaVersion": "latest",
25+
"sourceType": "module"
26+
}
27+
}
28+
]
29+
}

.github/workflows/build.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@ on:
77
branches: ['master', 'dev']
88

99
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Use Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: lts/*
20+
21+
- name: Check code format and issues
22+
run: |
23+
npm install
24+
npm run check
25+
1026
build:
27+
needs: check
28+
1129
runs-on: ubuntu-latest
1230

1331
strategy:
@@ -17,7 +35,7 @@ jobs:
1735
steps:
1836
- uses: actions/checkout@v3
1937

20-
- name: Setup Node.js LTS
38+
- name: Use Node.js
2139
uses: actions/setup-node@v3
2240
with:
2341
node-version: lts/*

.prettierignore

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

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"endOfLine": "lf"
7+
}

.vscode/extensions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"],
3+
"unwantedRecommendations": []
4+
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
4+
"files.insertFinalNewline": true,
5+
"[jsonc]": {
6+
"editor.defaultFormatter": "esbenp.prettier-vscode"
7+
}
8+
}

package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
"watch:chrome": "npm run watch -- --env BROWSER=chrome",
1111
"watch:firefox": "npm run watch -- --env BROWSER=firefox",
1212
"watch": "webpack --watch --config webpack.dev.js",
13+
"check:prettier": "npx prettier --check .",
14+
"check:eslint": "npx eslint .",
15+
"check": "npm run check:prettier & npm run check:eslint",
16+
"fix:prettier": "npx prettier --write .",
17+
"fix:eslint": "npx eslint --fix",
18+
"fix": "npm run fix:prettier & npm run fix:eslint",
1319
"test": "echo \"Error: no test specified\" && exit 1"
1420
},
1521
"repository": {
@@ -23,11 +29,19 @@
2329
},
2430
"homepage": "https://github.com/kungfux/jira-automation-extension#readme",
2531
"devDependencies": {
32+
"@eslint-recommended/eslint-config-typescript": "^17.0.3",
33+
"@typescript-eslint/eslint-plugin": "^5.59.0",
2634
"copy-webpack-plugin": "^11.0.0",
35+
"eslint": "^8.38.0",
36+
"eslint-config-prettier": "^8.8.0",
37+
"eslint-plugin-import": "^2.27.5",
38+
"eslint-plugin-n": "^15.7.0",
39+
"eslint-plugin-promise": "^6.1.1",
2740
"merge-jsons-webpack-plugin": "^2.0.1",
41+
"prettier": "^2.8.7",
2842
"ts-loader": "^9.4.2",
2943
"typescript": "^5.0.4",
30-
"webpack": "^5.78.0",
44+
"webpack": "^5.79.0",
3145
"webpack-cli": "^5.0.1",
3246
"webpack-merge": "^5.8.0"
3347
}

src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Test {
2+
main(): void {
3+
console.log('OK');
4+
console.log('OK');
5+
console.dir({ foo: 'bar' });
6+
}
7+
}
8+
9+
new Test().main();

0 commit comments

Comments
 (0)