Skip to content

Commit 5e08575

Browse files
authored
Switch to eslint and fix linting errors (#225)
1 parent 74383d0 commit 5e08575

21 files changed

+5307
-65
lines changed

.eslintrc.js

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
module.exports = {
2+
env: {
3+
es6: true,
4+
node: true,
5+
},
6+
extends: [
7+
"plugin:@typescript-eslint/recommended",
8+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
9+
"prettier",
10+
],
11+
parser: "@typescript-eslint/parser",
12+
parserOptions: {
13+
project: "tsconfig.json",
14+
sourceType: "module",
15+
},
16+
plugins: [
17+
"eslint-plugin-import",
18+
"eslint-plugin-jsdoc",
19+
"eslint-plugin-prefer-arrow",
20+
"@typescript-eslint",
21+
],
22+
rules: {
23+
"@typescript-eslint/adjacent-overload-signatures": "error",
24+
"@typescript-eslint/array-type": [
25+
"error",
26+
{
27+
default: "array",
28+
},
29+
],
30+
"@typescript-eslint/ban-types": [
31+
"error",
32+
{
33+
types: {
34+
Object: {
35+
message: "Avoid using the `Object` type. Did you mean `object`?",
36+
},
37+
Function: {
38+
message:
39+
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`.",
40+
},
41+
Boolean: {
42+
message: "Avoid using the `Boolean` type. Did you mean `boolean`?",
43+
},
44+
Number: {
45+
message: "Avoid using the `Number` type. Did you mean `number`?",
46+
},
47+
String: {
48+
message: "Avoid using the `String` type. Did you mean `string`?",
49+
},
50+
Symbol: {
51+
message: "Avoid using the `Symbol` type. Did you mean `symbol`?",
52+
},
53+
},
54+
},
55+
],
56+
"@typescript-eslint/consistent-type-assertions": "error",
57+
"@typescript-eslint/dot-notation": "error",
58+
"@typescript-eslint/member-delimiter-style": [
59+
"error",
60+
{
61+
multiline: {
62+
delimiter: "semi",
63+
requireLast: true,
64+
},
65+
singleline: {
66+
delimiter: "semi",
67+
requireLast: false,
68+
},
69+
},
70+
],
71+
"@typescript-eslint/naming-convention": "off",
72+
"@typescript-eslint/no-empty-function": "error",
73+
"@typescript-eslint/no-empty-interface": "error",
74+
"@typescript-eslint/no-explicit-any": "off",
75+
"@typescript-eslint/no-misused-new": "error",
76+
"@typescript-eslint/no-namespace": "error",
77+
"@typescript-eslint/no-parameter-properties": "off",
78+
"@typescript-eslint/no-shadow": [
79+
"error",
80+
{
81+
hoist: "all",
82+
},
83+
],
84+
"@typescript-eslint/no-unused-expressions": "error",
85+
"@typescript-eslint/no-use-before-define": "off",
86+
"@typescript-eslint/no-var-requires": "error",
87+
"@typescript-eslint/prefer-for-of": "error",
88+
"@typescript-eslint/prefer-function-type": "error",
89+
"@typescript-eslint/prefer-namespace-keyword": "error",
90+
"@typescript-eslint/semi": ["error"],
91+
"@typescript-eslint/triple-slash-reference": [
92+
"error",
93+
{
94+
path: "always",
95+
types: "prefer-import",
96+
lib: "always",
97+
},
98+
],
99+
"@typescript-eslint/unified-signatures": "error",
100+
complexity: "off",
101+
"constructor-super": "error",
102+
"dot-notation": "error",
103+
eqeqeq: ["off", "always"],
104+
"guard-for-in": "error",
105+
"id-denylist": [
106+
"error",
107+
"any",
108+
"Number",
109+
"number",
110+
"String",
111+
"string",
112+
"Boolean",
113+
"boolean",
114+
"Undefined",
115+
"undefined",
116+
],
117+
"id-match": "error",
118+
"import/order": "off",
119+
"jsdoc/check-alignment": "error",
120+
"jsdoc/check-indentation": "error",
121+
"jsdoc/newline-after-description": "error",
122+
"max-classes-per-file": ["error", 1],
123+
"new-parens": "error",
124+
"no-bitwise": "error",
125+
"no-caller": "error",
126+
"no-cond-assign": "error",
127+
"no-console": "off",
128+
"no-debugger": "error",
129+
"no-empty": "error",
130+
"no-empty-function": "error",
131+
"no-eval": "error",
132+
"no-fallthrough": "off",
133+
"no-invalid-this": "off",
134+
"no-new-wrappers": "error",
135+
"no-shadow": "error",
136+
"no-throw-literal": "error",
137+
"no-trailing-spaces": "error",
138+
"no-undef-init": "error",
139+
"no-underscore-dangle": "error",
140+
"no-unsafe-finally": "error",
141+
"no-unused-expressions": "error",
142+
"no-unused-labels": "error",
143+
"no-use-before-define": "off",
144+
"no-var": "error",
145+
"object-shorthand": "error",
146+
"one-var": ["error", "never"],
147+
"prefer-arrow/prefer-arrow-functions": "off",
148+
"prefer-const": "error",
149+
radix: "error",
150+
semi: "error",
151+
"space-before-function-paren": "off",
152+
"spaced-comment": [
153+
"error",
154+
"always",
155+
{
156+
markers: ["/"],
157+
},
158+
],
159+
"use-isnan": "error",
160+
"valid-typeof": "off",
161+
},
162+
};
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Test autoDocstring
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
unit_tests:
11+
runs-on: "${{ matrix.os }}"
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
node: [16]
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions/setup-node@v2
19+
with:
20+
node-version: "${{ matrix.node-version }}"
21+
cache: "npm"
22+
- run: npm install
23+
- run: npm run vscode:prepublish
24+
- run: npm run unit_test
25+
26+
integration_tests:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v2
30+
- uses: actions/setup-node@v2
31+
with:
32+
node-version: 16
33+
cache: "npm"
34+
- run: npm install
35+
- run: npm run prepare_integration_tests
36+
- uses: GabrielBB/xvfb-action@v1
37+
with:
38+
options: -screen 0 1024x768x24
39+
run: npm run integration_test
40+
publish:
41+
needs:
42+
- unit_tests
43+
- integration_tests
44+
if: startsWith(github.event.ref, 'refs/tags/v')
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v2
48+
- uses: actions/setup-node@v2
49+
with:
50+
node-version: 16
51+
cache: "npm"
52+
- run: npm ci
53+
- name: GitHub Release
54+
uses: softprops/action-gh-release@v1
55+
with:
56+
generate_release_notes: true
57+
body: |
58+
# Summary
59+
See [changelog](https://github.com/NilsJPWerner/autoDocstring/blob/master/CHANGELOG.md)
60+
name: ${{ github.ref_name }}
61+
fail_on_unmatched_files: true
62+
- name: Publish to Visual Studio Marketplace
63+
uses: HaaLeo/publish-vscode-extension@v1
64+
with:
65+
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
66+
registryUrl: https://marketplace.visualstudio.com

.vscode/tasks.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,12 @@
1414
"isDefault": true
1515
}
1616
},
17+
{
18+
"type": "npm",
19+
"script": "lint",
20+
"problemMatcher": ["$eslint-stylish"],
21+
"label": "npm: lint",
22+
"detail": "eslint -c .eslintrc.js --ext .ts src/"
23+
}
1724
]
1825
}

0 commit comments

Comments
 (0)