Skip to content

Commit ff50ead

Browse files
darzushakao
andauthored
Migration from TSLint to ESLint (microsoft#8039)
* Trying (and failing) to switch to eslint * eslint seems to mostly work. ~70 files changed later. * clean up eslintrc * clean up package.json changes * forgot one * add .eslintrc.js to each ts directory so that vscode plugin works * revert changes to pxtcompiler/ext-typescript/lib/lib.d.ts * revert * fix indent * remove unneeded * Upgrade from node 8.x to 14.x * fully remove tslint * Fix indent (thanks @shakao!) Co-authored-by: shakao <34112083+shakao@users.noreply.github.com> * trying fork that updates webfonts-generator b/c of build failure * update react-scripts in skillmap (so it matches eslint v7 in root); disable eslint in skillmap (b/c eslint gets very confused by the different working folders) * delete ondrive.ts * remove unused eslint directives * start linting streamer * explicitly name builds * remove matrix (b/c this kept appending the node version explicitly) * fix versions Co-authored-by: shakao <34112083+shakao@users.noreply.github.com>
1 parent d8a4cec commit ff50ead

84 files changed

Lines changed: 361 additions & 1010 deletions

Some content is hidden

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

.eslintignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
**/ext-typescript/
2+
.eslintrc.js
3+
4+
# For some reason these files cause eslint to crash inside the TS compiler :(
5+
# Error: Debug Failure. Unhandled declaration kind! ModuleDeclaration for {...}
6+
# Might be fixed if we update our TS version.
7+
# TODO: update to TS 4.2 and try again
8+
blocks.tsx
9+
snippetBuilder.tsx

.eslintrc.js

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*
2+
Generated from:
3+
https://github.com/typescript-eslint/tslint-to-eslint-config
4+
5+
References:
6+
https://code.visualstudio.com/api/advanced-topics/tslint-eslint-migration
7+
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
8+
https://github.com/microsoft/eslint-plugin-sdl
9+
https://github.com/dustinspecker/awesome-eslint#plugins
10+
*/
11+
module.exports = {
12+
"env": {
13+
"browser": true,
14+
"es6": true,
15+
"node": true
16+
},
17+
"parser": "@typescript-eslint/parser",
18+
"parserOptions": {
19+
"sourceType": "module"
20+
},
21+
"plugins": [
22+
"eslint-plugin-import",
23+
"@typescript-eslint",
24+
"@microsoft/sdl",
25+
"eslint-plugin-react",
26+
"jsx-a11y",
27+
],
28+
"extends": [
29+
],
30+
"rules": {
31+
// Rules enabled by default or migrated via tslint-to-eslint-config
32+
"@typescript-eslint/await-thenable": "error",
33+
"@typescript-eslint/member-delimiter-style": [
34+
"off",
35+
{
36+
"multiline": {
37+
"delimiter": "semi",
38+
"requireLast": true
39+
},
40+
"singleline": {
41+
"delimiter": "semi",
42+
"requireLast": false
43+
}
44+
}
45+
],
46+
"@typescript-eslint/no-for-in-array": "error",
47+
"@typescript-eslint/no-misused-new": "error",
48+
"@typescript-eslint/no-non-null-assertion": "off",
49+
"@typescript-eslint/no-unused-expressions": "error",
50+
"@typescript-eslint/prefer-namespace-keyword": "error",
51+
"@typescript-eslint/quotes": [
52+
"off",
53+
"double"
54+
],
55+
"@typescript-eslint/semi": [
56+
"off",
57+
"always"
58+
],
59+
"@typescript-eslint/triple-slash-reference": [
60+
"error",
61+
{
62+
"path": "always",
63+
"types": "prefer-import",
64+
"lib": "always"
65+
}
66+
],
67+
"@typescript-eslint/type-annotation-spacing": "error",
68+
"constructor-super": "error",
69+
"eqeqeq": [
70+
"off",
71+
"smart"
72+
],
73+
"import/no-internal-modules": "error",
74+
"import/no-unassigned-import": "error",
75+
"no-caller": "error",
76+
"no-cond-assign": "error",
77+
"no-control-regex": "error",
78+
"no-duplicate-case": "error",
79+
"no-eval": "error",
80+
"no-invalid-regexp": "error",
81+
"no-octal": "error",
82+
"no-octal-escape": "error",
83+
"no-regex-spaces": "error",
84+
"no-sparse-arrays": "error",
85+
"no-throw-literal": "error",
86+
"no-trailing-spaces": [
87+
"error",
88+
{
89+
"ignoreComments": true
90+
}
91+
],
92+
"no-unsafe-finally": "error",
93+
"no-unused-labels": "error",
94+
"no-var": "error",
95+
"spaced-comment": [
96+
"off",
97+
"always",
98+
{
99+
"markers": [
100+
"/"
101+
]
102+
}
103+
],
104+
"use-isnan": "error",
105+
106+
// React A11y
107+
"jsx-a11y/accessible-emoji": "error",
108+
"jsx-a11y/alt-text": "error",
109+
"jsx-a11y/aria-activedescendant-has-tabindex": "error",
110+
"jsx-a11y/aria-props": "error",
111+
"jsx-a11y/aria-role": "error",
112+
"jsx-a11y/aria-unsupported-elements": "error",
113+
"jsx-a11y/autocomplete-valid": "error",
114+
"jsx-a11y/heading-has-content": "error",
115+
"jsx-a11y/html-has-lang": "error",
116+
"jsx-a11y/img-redundant-alt": "error",
117+
"jsx-a11y/no-access-key": "error",
118+
"jsx-a11y/no-distracting-elements": "error",
119+
"jsx-a11y/role-has-required-aria-props": "error",
120+
"jsx-a11y/role-supports-aria-props": "error",
121+
"jsx-a11y/scope": "error",
122+
"jsx-a11y/tabindex-no-positive": "error",
123+
124+
// Consider enableing these additional accessability rules:
125+
// "jsx-a11y/anchor-has-content": "error",
126+
// "jsx-a11y/anchor-is-valid": "error",
127+
// "jsx-a11y/aria-proptypes": "error",
128+
// "jsx-a11y/click-events-have-key-events": "error",
129+
// "jsx-a11y/iframe-has-title": "error",
130+
// "jsx-a11y/interactive-supports-focus": "error",
131+
// "jsx-a11y/label-has-associated-control": "error",
132+
// "jsx-a11y/media-has-caption": "error",
133+
// "jsx-a11y/mouse-events-have-key-events": "error",
134+
// "jsx-a11y/no-interactive-element-to-noninteractive-role": "error",
135+
// "jsx-a11y/no-noninteractive-element-interactions": "error",
136+
// "jsx-a11y/no-noninteractive-element-to-interactive-role": "error",
137+
// "jsx-a11y/no-noninteractive-tabindex": "error",
138+
// "jsx-a11y/no-onchange": "error",
139+
// "jsx-a11y/no-redundant-roles": "error",
140+
// "jsx-a11y/no-static-element-interactions": "error",
141+
// "jsx-a11y/no-autofocus": "error",
142+
143+
// Microsoft SDL
144+
"@microsoft/sdl/no-inner-html": "error",
145+
"@microsoft/sdl/react-iframe-missing-sandbox": "error",
146+
"@typescript-eslint/no-implied-eval": "error",
147+
"react/no-danger": "error",
148+
}
149+
};

.github/workflows/pxt-buildmain.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ on:
99

1010
jobs:
1111
build:
12+
name: buildmain
1213

1314
runs-on: ubuntu-latest
1415

15-
strategy:
16-
matrix:
17-
node-version: [8.x]
18-
1916
steps:
2017
- uses: actions/checkout@v1
2118
- name: Use Node.js ${{ matrix.node-version }}
2219
uses: actions/setup-node@v1
2320
with:
24-
node-version: ${{ matrix.node-version }}
21+
node-version: '14.x'
2522
- name: npm install
2623
run: |
2724
sudo apt-get install xvfb

.github/workflows/pxt-buildpr.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ on: [pull_request]
44

55
jobs:
66
build:
7+
name: buildpr
78

89
runs-on: ubuntu-latest
910

10-
strategy:
11-
matrix:
12-
node-version: [8.x]
13-
1411
steps:
1512
- uses: actions/checkout@v1
16-
- name: Use Node.js ${{ matrix.node-version }}
13+
- name: Set Node.js version
1714
uses: actions/setup-node@v1
1815
with:
19-
node-version: ${{ matrix.node-version }}
16+
node-version: '14.x'
2017
- name: npm install
2118
run: |
2219
sudo apt-get install xvfb

.github/workflows/pxt-buildpush.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ on:
99

1010
jobs:
1111
build:
12+
name: buildpush
1213

1314
runs-on: ubuntu-latest
1415

15-
strategy:
16-
matrix:
17-
node-version: [8.x]
18-
1916
steps:
2017
- uses: actions/checkout@v1
21-
- name: Use Node.js ${{ matrix.node-version }}
18+
- name: Set Node.js version
2219
uses: actions/setup-node@v1
2320
with:
24-
node-version: ${{ matrix.node-version }}
21+
node-version: '14.x'
2522
- name: npm install
2623
run: |
2724
sudo apt-get install xvfb

cli/.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
"parserOptions": {
3+
"project": "cli/tsconfig.json",
4+
},
5+
}

cli/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* tslint:disable:forin cli only run in node */
1+
/* eslint-disable @typescript-eslint/no-for-in-array */
22

33
/// <reference path="../built/pxtlib.d.ts"/>
44
/// <reference path="../built/pxtcompiler.d.ts"/>

cli/commandparser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* tslint:disable:forin cli only run in node */
1+
/* eslint-disable @typescript-eslint/no-for-in-array */
22

33
const MaxColumns = 100;
44
const argRegex = /^(-+)?(.+)$/;

cli/nodeutil.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,7 @@ function nodeHttpRequestAsync(options: Util.HttpRequestOptions): Promise<Util.Ht
178178
let u = <http.RequestOptions><any>url.parse(options.url)
179179

180180
if (u.protocol == "https:") isHttps = true
181-
/* tslint:disable:no-http-string */
182181
else if (u.protocol == "http:") isHttps = false
183-
/* tslint:enable:no-http-string */
184182
else return Promise.reject("bad protocol: " + u.protocol)
185183

186184
u.headers = Util.clone(options.headers) || {}
@@ -586,7 +584,6 @@ export function lazyDependencies(): pxt.Map<string> {
586584
}
587585

588586
export function lazyRequire(name: string, install = false): any {
589-
/* tslint:disable:non-literal-require */
590587
let r: any;
591588
try {
592589
r = require(name);
@@ -598,7 +595,6 @@ export function lazyRequire(name: string, install = false): any {
598595
if (!r && install)
599596
pxt.log(`package "${name}" failed to load, run "pxt npminstallnative" to install native depencencies`)
600597
return r;
601-
/* tslint:enable:non-literal-require */
602598
}
603599

604600
export function stringify(content: any) {

cli/pyconv.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ namespace py {
453453
}
454454

455455

456-
/* tslint:disable:no-trailing-whitespace */
456+
/* eslint-disable no-trailing-spaces */
457457
const convPy = `
458458
import ast
459459
import sys
@@ -480,7 +480,7 @@ for fn in @files@:
480480
js[fn] = to_json(ast.parse(open(fn, "r").read()))
481481
print(json.dumps(js))
482482
`
483-
/* tslint:enable:no-trailing-whitespace */
483+
/* eslint-enable no-trailing-spaces */
484484

485485
const nameMap: Map<string> = {
486486
"Expr": "ExprStmt",
@@ -1481,9 +1481,7 @@ const exprMap: Map<(v: py.Expr) => B.JsNode> = {
14811481
else {
14821482
let ee = elts.shift()
14831483
let et = ee ? expr(ee) : B.mkText("???")
1484-
/* tslint:disable:no-invalid-template-strings */
14851484
res.push(B.mkText("${"), et, B.mkText("}"))
1486-
/* tslint:enable:no-invalid-template-strings */
14871485
}
14881486
return ""
14891487
})

0 commit comments

Comments
 (0)