Skip to content

Commit 33a91b7

Browse files
authored
chore(lint): Migrate to ESLint (#83)
1 parent f5012b0 commit 33a91b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3106
-1406
lines changed

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Dependencies ###
2+
.yarn/
3+
node_modules/
4+
5+
### Auto-generated ###
6+
build/
7+
dist/

.eslintrc.json

+221
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"browser": true,
5+
"es6": true,
6+
"node": true
7+
},
8+
"settings": {
9+
"import/resolver": {
10+
"typescript": {
11+
"alwaysTryTypes": true,
12+
"project": "./tsconfig.json"
13+
}
14+
}
15+
},
16+
"parserOptions": {
17+
"ecmaVersion": "latest",
18+
"project": "./tsconfig.json",
19+
"sourceType": "module"
20+
},
21+
"plugins": [
22+
"@typescript-eslint",
23+
"eslint-plugin-import",
24+
"eslint-plugin-jsdoc",
25+
"etc"
26+
],
27+
"extends": [
28+
"eslint:recommended",
29+
"plugin:@typescript-eslint/recommended",
30+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
31+
"plugin:etc/recommended",
32+
"plugin:import/typescript"
33+
],
34+
"overrides": [{
35+
"files": "*.ts?(x)",
36+
"parser": "@typescript-eslint/parser"
37+
}, {
38+
"files": "*.test.ts?(x)",
39+
"rules": {
40+
"@typescript-eslint/no-non-null-assertion": "off",
41+
"@typescript-eslint/restrict-template-expressions": "off",
42+
"etc/throw-error": "off"
43+
}
44+
}, {
45+
"files": "*.typetest.ts?(x)",
46+
"rules": {
47+
"@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": false }],
48+
"etc/throw-error": "off"
49+
}
50+
}, {
51+
"files": "*.js?(x)",
52+
"rules": {
53+
"@typescript-eslint/explicit-function-return-type": "off",
54+
"@typescript-eslint/explicit-member-accessibility": "off",
55+
"@typescript-eslint/explicit-module-boundary-types": "off",
56+
"@typescript-eslint/no-unsafe-argument": "off",
57+
"@typescript-eslint/no-unsafe-assignment": "off",
58+
"@typescript-eslint/no-unsafe-member-access": "off",
59+
"@typescript-eslint/no-unsafe-call": "off",
60+
"@typescript-eslint/no-unsafe-return": "off",
61+
"@typescript-eslint/no-var-requires": "off",
62+
"@typescript-eslint/restrict-plus-operands": "off",
63+
"@typescript-eslint/restrict-template-expressions": "off"
64+
}
65+
}],
66+
"rules": {
67+
"@typescript-eslint/ban-types": "error",
68+
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
69+
"@typescript-eslint/consistent-type-assertions": "error",
70+
"@typescript-eslint/dot-notation": "error",
71+
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
72+
"@typescript-eslint/explicit-member-accessibility": "error",
73+
"@typescript-eslint/explicit-module-boundary-types": "error",
74+
"@typescript-eslint/member-ordering": ["error", {
75+
"classes": [
76+
"static-field",
77+
"field",
78+
"constructor",
79+
"static-method",
80+
"abstract-method",
81+
"protected-method",
82+
"private-method",
83+
"public-method"
84+
],
85+
"interfaces": { "order": "alphabetically" },
86+
"typeLiterals": { "order": "alphabetically" }
87+
}],
88+
"@typescript-eslint/member-delimiter-style": ["error", {
89+
"multiline": {
90+
"delimiter": "semi",
91+
"requireLast": true
92+
},
93+
"singleline": {
94+
"delimiter": "semi",
95+
"requireLast": true
96+
}
97+
}],
98+
"@typescript-eslint/no-empty-function": "error",
99+
"@typescript-eslint/no-empty-interface": "error",
100+
"@typescript-eslint/no-explicit-any": ["error", { "ignoreRestArgs": true }],
101+
"@typescript-eslint/no-floating-promises": "off",
102+
"@typescript-eslint/no-inferrable-types": ["error", {
103+
"ignoreParameters": true,
104+
"ignoreProperties": true
105+
}],
106+
"@typescript-eslint/no-misused-new": "error",
107+
"@typescript-eslint/no-namespace": "off",
108+
"@typescript-eslint/no-non-null-assertion": "error",
109+
"@typescript-eslint/no-redundant-type-constituents": "error",
110+
"@typescript-eslint/no-shadow": ["error", { "hoist": "all" }],
111+
"@typescript-eslint/no-unused-expressions": ["error", { "allowTernary": true }],
112+
"@typescript-eslint/no-unused-vars": ["error", {
113+
"destructuredArrayIgnorePattern": "^_",
114+
"ignoreRestSiblings": true
115+
}],
116+
"@typescript-eslint/no-use-before-define": ["error", {
117+
"functions": false,
118+
"classes": false
119+
}],
120+
"@typescript-eslint/no-var-requires": "error",
121+
"@typescript-eslint/parameter-properties": "error",
122+
"@typescript-eslint/prefer-for-of": "error",
123+
"@typescript-eslint/prefer-function-type": "error",
124+
"@typescript-eslint/prefer-namespace-keyword": "error",
125+
"@typescript-eslint/quotes": ["error", "double", {
126+
"avoidEscape": true,
127+
"allowTemplateLiterals": false
128+
}],
129+
"@typescript-eslint/restrict-template-expressions": ["error", {
130+
"allowNumber": true,
131+
"allowBoolean": true,
132+
"allowNullish": true
133+
}],
134+
"@typescript-eslint/semi": "error",
135+
"@typescript-eslint/space-infix-ops": "error",
136+
"@typescript-eslint/triple-slash-reference": "error",
137+
"@typescript-eslint/type-annotation-spacing": "error",
138+
"@typescript-eslint/unbound-method": ["error", { "ignoreStatic": true }],
139+
"@typescript-eslint/unified-signatures": "error",
140+
"array-bracket-spacing": "error",
141+
"arrow-parens": ["error", "as-needed"],
142+
"arrow-spacing": "error",
143+
"brace-style": "error",
144+
"camelcase": "error",
145+
"comma-spacing": "error",
146+
"computed-property-spacing": "error",
147+
"constructor-super": "error",
148+
"curly": "error",
149+
"etc/no-commented-out-code": "error",
150+
"etc/throw-error": "error",
151+
"eol-last": "error",
152+
"eqeqeq": "error",
153+
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
154+
"import/newline-after-import": "error",
155+
"import/no-absolute-path": "error",
156+
"import/no-cycle": ["error", { "ignoreExternal": true }],
157+
"import/no-duplicates": "error",
158+
"import/no-import-module-exports": "error",
159+
"import/no-namespace": "error",
160+
"import/no-relative-packages": "error",
161+
"import/no-unresolved": "error",
162+
"import/no-useless-path-segments": "error",
163+
"import/order": ["error", {
164+
"alphabetize": {
165+
"caseInsensitive": false,
166+
"order": "asc"
167+
},
168+
"newlines-between": "always",
169+
"groups": ["external", "parent", "sibling"]
170+
}],
171+
"jsdoc/check-alignment": "error",
172+
"jsdoc/check-indentation": ["error", { "excludeTags": ["example", "param", "returns"] }],
173+
"jsdoc/newline-after-description": "error",
174+
"jsx-quotes": "error",
175+
"keyword-spacing": "error",
176+
"linebreak-style": "error",
177+
"max-classes-per-file": ["error", 1],
178+
"max-len": ["error", {
179+
"code": 120,
180+
"comments": 80,
181+
"ignoreRegExpLiterals": true,
182+
"ignorePattern": "^import (\\{ )?\\w+( \\})? from \".+\";$",
183+
"ignoreUrls": true,
184+
"tabWidth": 2
185+
}],
186+
"new-parens": "error",
187+
"no-caller": "error",
188+
"no-cond-assign": "error",
189+
"no-console": "error",
190+
"no-duplicate-imports": "error",
191+
"no-empty-function": "error",
192+
"no-eval": "error",
193+
"no-extra-boolean-cast": ["error", { "enforceForLogicalOperands": true }],
194+
"no-invalid-this": "error",
195+
"no-labels": "error",
196+
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
197+
"no-multi-spaces": "error",
198+
"no-new-wrappers": "error",
199+
"no-param-reassign": "error",
200+
"no-tabs": "error",
201+
"no-throw-literal": "error",
202+
"no-trailing-spaces": "error",
203+
"no-underscore-dangle": "error",
204+
"no-use-before-define": "off",
205+
"no-useless-computed-key": ["error", { "enforceForClassMembers": true }],
206+
"no-var": "error",
207+
"object-curly-spacing": ["error", "always"],
208+
"object-shorthand": "error",
209+
"one-var": ["error", "never"],
210+
"prefer-const": "error",
211+
"quote-props": ["error", "as-needed"],
212+
"radix": "error",
213+
"rest-spread-spacing": "error",
214+
"semi-spacing": "error",
215+
"sort-keys": "error",
216+
"space-before-blocks": "error",
217+
"space-in-parens": "error",
218+
"spaced-comment": "error",
219+
"switch-colon-spacing": "error"
220+
}
221+
}

examples/jest/jest.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const jestConfig: Config = {
44
preset: "ts-jest",
55
setupFilesAfterEnv: ["./test/setup.ts"],
66
testEnvironment: "node",
7-
testRegex: "test/.*\\.test\\.ts$"
7+
testRegex: "test/.*\\.test\\.ts$",
88
};
99

1010
export default jestConfig;

examples/jest/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"@examples/symbol-plugin": "workspace:^",
1010
"@stackbuilders/assertive-ts": "workspace:^",
1111
"@types/jest": "^29.4.0",
12-
"@types/node": "^18.13.0",
13-
"jest": "^29.4.2",
12+
"@types/node": "^18.14.2",
13+
"jest": "^29.4.3",
1414
"ts-jest": "^29.0.5",
1515
"ts-node": "^10.9.1",
1616
"typescript": "^4.9.5"

examples/mocha/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@examples/symbol-plugin": "workspace:^",
1010
"@stackbuilders/assertive-ts": "workspace:^",
1111
"@types/mocha": "^10.0.1",
12-
"@types/node": "^18.13.0",
12+
"@types/node": "^18.14.2",
1313
"mocha": "^10.2.0",
1414
"ts-node": "^10.9.1",
1515
"typescript": "^4.9.5"

examples/mocha/test/hooks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export function mochaHooks(): RootHookObject {
66
return {
77
beforeAll() {
88
usePlugin(SymbolPlugin);
9-
}
9+
},
1010
};
1111
}

examples/symbolPlugin/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { SymbolAssertion } from "./lib/SymbolAssertion";
55
declare module "@stackbuilders/assertive-ts" {
66

77
export interface Expect {
8-
// tslint:disable-next-line: callable-types
8+
// eslint-disable-next-line @typescript-eslint/prefer-function-type
99
(actual: symbol): SymbolAssertion;
1010
}
1111
}
1212

1313
export const SymbolPlugin: Plugin<symbol, SymbolAssertion> = {
1414
Assertion: SymbolAssertion,
1515
insertAt: "top",
16-
predicate: (actual): actual is symbol => typeof actual === "symbol"
16+
predicate: (actual): actual is symbol => typeof actual === "symbol",
1717
};

examples/symbolPlugin/src/lib/SymbolAssertion.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,35 @@ export class SymbolAssertion extends Assertion<symbol> {
99
public toBeSymbol(): this {
1010
const error = new AssertionError({
1111
actual: this.actual,
12-
message: `Expected ${String(this.actual)} to be a symbol`
12+
message: `Expected ${String(this.actual)} to be a symbol`,
1313
});
1414
const invertedError = new AssertionError({
1515
actual: this.actual,
16-
message: `Expected ${String(this.actual)} not to be a symbol`
16+
message: `Expected ${String(this.actual)} not to be a symbol`,
1717
});
1818

1919
return this.execute({
2020
assertWhen: typeof this.actual === "symbol",
2121
error,
22-
invertedError
22+
invertedError,
2323
});
2424
}
2525

2626
public toHaveDescription(expected: string): this {
2727
const error = new AssertionError({
2828
actual: this.actual.description,
2929
expected,
30-
message: `Expected ${String(this.actual)} to have the description: ${expected}`
30+
message: `Expected ${String(this.actual)} to have the description: ${expected}`,
3131
});
3232
const invertedError = new AssertionError({
3333
actual: this.actual.description,
34-
message: `Expected ${String(this.actual)} not to have the description: ${expected}`
34+
message: `Expected ${String(this.actual)} not to have the description: ${expected}`,
3535
});
3636

3737
return this.execute({
3838
assertWhen: this.actual.description === expected,
3939
error,
40-
invertedError
40+
invertedError,
4141
});
4242
}
4343
}

package.json

+11-14
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,23 @@
1414
"examples/*"
1515
],
1616
"scripts": {
17-
"check": "yarn compile && yarn lint && yarn test",
17+
"check": "turbo check && yarn lint",
1818
"build": "turbo run build",
19-
"build:core": "turbo run build --filter=@stackbuilders/assertive-ts",
2019
"compile": "turbo run compile",
21-
"compile:core": "turbo run compile --filter=@stackbuilders/assertive-ts",
22-
"compile:examples": "turbo run compile --filter=\"@examples/*\"",
23-
"compile:examples:jest": "turbo run compile --filter=@examples/jest",
24-
"compile:examples:mocha": "turbo run compile --filter=@examples/mocha",
25-
"lint": "tslint -c tslint.json \"**/*.ts\"",
20+
"lint": "eslint .",
2621
"pages": "yarn workspace @stackbuilders/assertive-ts pages",
2722
"release": "turbo release",
28-
"test": "turbo run test",
29-
"test:core": "turbo run test --filter=@stackbuilders/assertive-ts",
30-
"test:examples": "turbo run test --filter=\"@examples/*\"",
31-
"test:examples:jest": "turbo run test --filter=@examples/jest",
32-
"test:examples:mocha": "turbo run test --filter=@examples/mocha"
23+
"test": "turbo run test"
3324
},
3425
"devDependencies": {
35-
"tslint": "^6.1.3",
36-
"turbo": "^1.7.3",
26+
"@typescript-eslint/eslint-plugin": "^5.54.0",
27+
"@typescript-eslint/parser": "^5.54.0",
28+
"eslint": "^8.35.0",
29+
"eslint-import-resolver-typescript": "^3.5.3",
30+
"eslint-plugin-etc": "^2.0.2",
31+
"eslint-plugin-import": "^2.27.5",
32+
"eslint-plugin-jsdoc": "^40.0.0",
33+
"turbo": "^1.8.3",
3734
"typescript": "^4.9.5"
3835
}
3936
}

package/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"scripts": {
2525
"build": "tsc -p tsconfig.prod.json",
26-
"check": "yarn compile && yarn lint && yarn test --forbid-only",
26+
"check": "yarn compile && yarn test --forbid-only",
2727
"compile": "tsc -p tsconfig.json",
2828
"pages": "typedoc",
2929
"release": "semantic-release",
@@ -34,15 +34,15 @@
3434
},
3535
"devDependencies": {
3636
"@types/mocha": "^10.0.1",
37-
"@types/node": "^18.13.0",
37+
"@types/node": "^18.14.2",
3838
"@types/sinon": "^10.0.13",
3939
"all-contributors-cli": "^6.24.0",
4040
"cross-env": "^7.0.3",
4141
"mocha": "^10.2.0",
4242
"semantic-release": "^20.1.0",
4343
"sinon": "^15.0.1",
4444
"ts-node": "^10.9.1",
45-
"typedoc": "^0.23.24",
45+
"typedoc": "^0.23.26",
4646
"typedoc-plugin-markdown": "^3.14.0",
4747
"typedoc-plugin-merge-modules": "^4.0.1",
4848
"typescript": "^4.9.5"

0 commit comments

Comments
 (0)