Skip to content

Commit a6b40e9

Browse files
authored
Merge pull request #1205 from danger/fb/eslint
chore: Switch from tslint to eslint
2 parents 1047571 + 8322ffa commit a6b40e9

Some content is hidden

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

51 files changed

+708
-163
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source/danger.d.ts
2+
source/runner/_tests/fixtures/*.ts

.eslintrc.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
node: true,
6+
},
7+
extends: ["plugin:@typescript-eslint/recommended", "plugin:jest/recommended", "prettier"],
8+
parser: "@typescript-eslint/parser",
9+
parserOptions: {
10+
project: "tsconfig.spec.json",
11+
sourceType: "module",
12+
},
13+
plugins: ["eslint-plugin-jest", "eslint-plugin-jsdoc", "@typescript-eslint"],
14+
rules: {
15+
"@typescript-eslint/naming-convention": "error",
16+
"@typescript-eslint/no-empty-function": "error",
17+
"@typescript-eslint/no-unused-expressions": "error",
18+
19+
// Something is grumpy about these rules re: node imports - TODO
20+
"@typescript-eslint/no-require-imports": "off",
21+
"@typescript-eslint/no-var-requires": "off",
22+
23+
curly: "error",
24+
"jsdoc/check-alignment": "error",
25+
"jsdoc/check-indentation": "off",
26+
"jsdoc/newline-after-description": "off",
27+
"no-empty": "error",
28+
// This is used intentionally in a bunch of ci_source/providers
29+
"no-empty-function": "off",
30+
"no-redeclare": "error",
31+
"no-var": "error",
32+
// There are a bunch of existing uses of 'let' where this rule would trigger
33+
"prefer-const": "off",
34+
35+
// This project has a ton of interacting APIs, and sometimes it's helpful to be explicit, even if the type is trivial
36+
"@typescript-eslint/no-inferrable-types": "off",
37+
38+
"no-unused-expressions": "off",
39+
"@typescript-eslint/no-unused-expressions": "error",
40+
41+
"no-unused-vars": "off",
42+
"@typescript-eslint/no-unused-vars": [
43+
"warn",
44+
{
45+
// Allow function args to be unused
46+
args: "none",
47+
argsIgnorePattern: "^_",
48+
varsIgnorePattern: "^_",
49+
caughtErrorsIgnorePattern: "^_",
50+
},
51+
],
52+
53+
"jest/no-disabled-tests": "warn",
54+
"jest/no-focused-tests": "error",
55+
"jest/no-identical-title": "error",
56+
"jest/prefer-to-have-length": "off",
57+
"jest/valid-expect": "error",
58+
"@typescript-eslint/no-non-null-assertion": "off",
59+
// Tons of violations in the codebase
60+
"@typescript-eslint/naming-convention": "off",
61+
// Used liberally in the codebase
62+
"@typescript-eslint/no-explicit-any": "off",
63+
// This has value in communicating with other Developers even if it has no functional effect.
64+
"@typescript-eslint/no-empty-interface": "off",
65+
},
66+
}

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"recommendations": [
33
"Orta.vscode-jest",
44
"esbenp.prettier-vscode",
5+
"dbaeumer.vscode-eslint",
56
"christian-kohler.path-intellisense",
67
"wayou.vscode-todo-highlight"
78
]

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
<!-- Your comment below this -->
1717

18+
- *Chore:* Switch from tslint to eslint (tslint is end-of-life) - [#1205](https://github.com/danger/danger-js/pull/1205) [@fbartho]
1819

1920
<!-- Your comment above this -->
2021

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Test against this version of Node.js
22
environment:
3-
nodejs_version: "10"
3+
nodejs_version: "12"
44

55
# Install scripts. (runs after repo cloning)
66
install:

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"git add"
3535
],
3636
"*.@(ts|tsx)": [
37-
"tslint --fix",
37+
"yarn lint:fix",
3838
"yarn prettier --write",
3939
"git add"
4040
]
@@ -56,8 +56,8 @@
5656
"test:fixtures": "node ./scripts/run-fixtures.js",
5757
"test:update-fixtures": "yarn test:fixtures --update",
5858
"test:watch": "jest --watch",
59-
"lint": "tslint \"source/**/*.ts\"",
60-
"lint:fix": "tslint \"source/**/*.ts\" --fix",
59+
"lint": "eslint \"source/*.ts\" \"source/**/*.ts\"",
60+
"lint:fix": "yarn --silent lint --fix",
6161
"prepublishOnly": "yarn build && yarn jest && yarn declarations && yarn build:flow-types && yarn build:pretty-types",
6262
"build": "shx rm -rf ./distribution && tsc -p tsconfig.production.json && madge ./distribution --circular",
6363
"build:fast": "tsc -p tsconfig.production.json",
@@ -114,9 +114,15 @@
114114
"@types/prettier": "^1.16.1",
115115
"@types/readline-sync": "^1.4.3",
116116
"@types/voca": "^1.4.0",
117+
"@typescript-eslint/eslint-plugin": "^5.10.1",
118+
"@typescript-eslint/parser": "^5.10.1",
117119
"danger-plugin-jest": "^1.0.1",
118120
"danger-plugin-yarn": "^1.3.1",
119121
"date-fns": "^1.29.0",
122+
"eslint": "^8.8.0",
123+
"eslint-config-prettier": "^8.3.0",
124+
"eslint-plugin-jest": "^26.0.0",
125+
"eslint-plugin-jsdoc": "^37.7.0",
120126
"flow-bin": "^0.77.0",
121127
"husky": "^1.0.1",
122128
"jest": "^24.0.0",
@@ -125,13 +131,11 @@
125131
"madge": "^3.2.0",
126132
"nock": "^10.0.6",
127133
"pkg": "^4.4.2",
128-
"prettier": "^1.14.2",
134+
"prettier": "^2.5.1",
129135
"release-it": "^13.5.2",
130136
"shx": "^0.3.2",
131137
"ts-jest": "^24.0.2",
132138
"ts-node": "^8.0.2",
133-
"tslint": "^5.11.0",
134-
"tslint-config-prettier": "^1.15.0",
135139
"typedoc": "0.9.0",
136140
"typescript": "^4.5.5",
137141
"typescript-json-schema": "^0.32.0"

scripts/create-danger-dts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (allDiagnostics.length) {
2424
console.log(
2525
"\nIf you've added something new to the DSL, and the errors are about something missing, you may need to add an interface in `source/dsl/*`."
2626
)
27-
allDiagnostics.forEach(diagnostic => {
27+
allDiagnostics.forEach((diagnostic) => {
2828
if (diagnostic.file) {
2929
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!)
3030
let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")

scripts/danger-dts.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import * as fs from "fs"
22
import * as prettier from "prettier"
33

4-
const mapLines = (s: string, func: (s: string) => string) =>
5-
s
6-
.split("\n")
7-
.map(func)
8-
.join("\n")
4+
const mapLines = (s: string, func: (s: string) => string) => s.split("\n").map(func).join("\n")
95

106
const createDTS = () => {
117
const header = `//
@@ -23,10 +19,10 @@ import { File } from "parse-diff"
2319

2420
const dslFiles = fs
2521
.readdirSync("source/dsl")
26-
.filter(f => !f.startsWith("_tests"))
27-
.map(f => `source/dsl/${f}`)
22+
.filter((f) => !f.startsWith("_tests"))
23+
.map((f) => `source/dsl/${f}`)
2824

29-
dslFiles.forEach(file => {
25+
dslFiles.forEach((file) => {
3026
// Sometimes they have more stuff, in those cases
3127
// offer a way to crop the file.
3228
const content = fs.readFileSync(file).toString()
@@ -72,7 +68,7 @@ import { File } from "parse-diff"
7268
const chainDefs = fs.readFileSync("distribution/commands/utils/chainsmoker.d.ts", "utf8")
7369
const chainDefsMinusDefaultExport = chainDefs
7470
.split("\n")
75-
.filter(line => {
71+
.filter((line) => {
7672
return !line.startsWith("export default function")
7773
})
7874
.join("\n")
@@ -82,10 +78,10 @@ import { File } from "parse-diff"
8278
// Remove all JS-y bits
8379
fileOutput = fileOutput
8480
.split("\n")
85-
.filter(line => {
81+
.filter((line) => {
8682
return !line.startsWith("import") && !line.includes("* @type ")
8783
})
88-
.filter(line => {
84+
.filter((line) => {
8985
return !line.includes("Please don't have")
9086
})
9187
.join("\n")
@@ -94,7 +90,7 @@ import { File } from "parse-diff"
9490
const noRedundantExports = trimmedWhitespaceLines
9591
.replace(/export interface/g, "interface")
9692
.replace(/export type/g, "type")
97-
const indentedBody = mapLines(noRedundantExports, line => (line.length ? line : ""))
93+
const indentedBody = mapLines(noRedundantExports, (line) => (line.length ? line : ""))
9894

9995
const def = header + indentedBody + footer
10096

source/api/fetch.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ export function api(
6363
url: string | node_fetch.Request,
6464
init: node_fetch.RequestInit,
6565
suppressErrorReporting?: boolean,
66-
provessEnv: NodeJS.ProcessEnv = process.env
66+
processEnv: NodeJS.ProcessEnv = process.env
6767
): Promise<node_fetch.Response> {
6868
const isTests = typeof jest !== "undefined"
6969
if (isTests && !url.toString().includes("localhost")) {
7070
const message = `No API calls in tests please: ${url}`
71-
debugger // tslint:disable-line
71+
debugger
7272
throw new Error(message)
7373
}
7474

@@ -79,8 +79,8 @@ export function api(
7979
output.push(`-X ${init.method}`)
8080
}
8181

82-
const showToken = provessEnv["DANGER_VERBOSE_SHOW_TOKEN"]
83-
const token = provessEnv["DANGER_GITHUB_API_TOKEN"] || provessEnv["GITHUB_TOKEN"]
82+
const showToken = processEnv["DANGER_VERBOSE_SHOW_TOKEN"]
83+
const token = processEnv["DANGER_GITHUB_API_TOKEN"] || processEnv["GITHUB_TOKEN"]
8484

8585
if (init.headers) {
8686
for (const prop in init.headers) {
@@ -109,7 +109,7 @@ export function api(
109109

110110
let agent = init.agent
111111
const proxy =
112-
provessEnv["HTTPS_PROXY"] || provessEnv["https_proxy"] || provessEnv["HTTP_PROXY"] || provessEnv["http_proxy"]
112+
processEnv["HTTPS_PROXY"] || processEnv["https_proxy"] || processEnv["HTTP_PROXY"] || processEnv["http_proxy"]
113113

114114
if (!agent && proxy) {
115115
let secure = url.toString().startsWith("https")

source/ci_source/get_ci_source.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export async function getCISourceForExternal(env: Env, modulePath: string): Prom
3030
console.error(`could not load CI provider at ${modulePath} due to ${error}`)
3131
}
3232
if (stat && stat.isFile()) {
33-
const externalModule = require(path) //tslint:disable-line:no-require-imports
33+
// eslint-disable-next-line
34+
const externalModule = require(path) // @typescript-eslint/no-var-requires @typescript-eslint/no-require-imports
3435
const moduleConstructor = externalModule.default || externalModule
3536
resolve(new moduleConstructor(env))
3637
}

0 commit comments

Comments
 (0)