Skip to content

Commit 26a1dc8

Browse files
Merge pull request #74 from grammarly/switch-from-tslint-to-eslint
Switch from TSLint to ESLint
2 parents 29e1635 + 6af9d9f commit 26a1dc8

Some content is hidden

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

55 files changed

+1592
-171
lines changed

.eslintrc.js

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"parser": "@typescript-eslint/parser",
7+
"plugins": [
8+
"@typescript-eslint",
9+
"@typescript-eslint/tslint",
10+
"jsdoc",
11+
"react"
12+
],
13+
"rules": {
14+
"react/jsx-uses-vars": "error",
15+
"react/jsx-uses-react": "error",
16+
"@typescript-eslint/await-thenable": "error",
17+
"@typescript-eslint/consistent-type-assertions": "error",
18+
"@typescript-eslint/consistent-type-definitions": "error",
19+
"@typescript-eslint/dot-notation": "error",
20+
"@typescript-eslint/explicit-member-accessibility": [
21+
"off",
22+
{
23+
"accessibility": "explicit"
24+
}
25+
],
26+
"@typescript-eslint/indent": "off",
27+
"@typescript-eslint/interface-name-prefix": "off",
28+
"@typescript-eslint/member-delimiter-style": [
29+
"error",
30+
{
31+
"multiline": {
32+
"delimiter": "none",
33+
"requireLast": true
34+
},
35+
"singleline": {
36+
"delimiter": "semi",
37+
"requireLast": false
38+
}
39+
}
40+
],
41+
"@typescript-eslint/member-ordering": "off",
42+
"@typescript-eslint/no-empty-function": "error",
43+
"@typescript-eslint/no-explicit-any": "off",
44+
"@typescript-eslint/no-inferrable-types": "error",
45+
"@typescript-eslint/no-require-imports": "off",
46+
"@typescript-eslint/no-unused-expressions": "error",
47+
"@typescript-eslint/no-unused-vars": [
48+
"error",
49+
{
50+
"argsIgnorePattern": "^_" ,
51+
"varsIgnorePattern": "^_"
52+
}
53+
] ,
54+
"@typescript-eslint/no-use-before-define": "error",
55+
"@typescript-eslint/no-var-requires": "off",
56+
"@typescript-eslint/prefer-namespace-keyword": "error",
57+
"@typescript-eslint/quotes": [
58+
"error",
59+
"single",
60+
{
61+
"avoidEscape": true,
62+
"allowTemplateLiterals": true
63+
}
64+
],
65+
"@typescript-eslint/semi": [
66+
"error",
67+
"never"
68+
],
69+
"@typescript-eslint/strict-boolean-expressions": "off",
70+
"@typescript-eslint/type-annotation-spacing": "error",
71+
"@typescript-eslint/typedef": [
72+
"error",
73+
{
74+
"propertyDeclaration": true
75+
}
76+
],
77+
"@typescript-eslint/method-signature-style": [
78+
"error",
79+
"method"
80+
],
81+
"no-redeclare": "off",
82+
"@typescript-eslint/no-redeclare": ["error"],
83+
"arrow-parens": [
84+
"error",
85+
"as-needed"
86+
],
87+
"brace-style": [
88+
"error",
89+
"1tbs"
90+
],
91+
"camelcase": "error",
92+
"class-methods-use-this": "error",
93+
"comma-dangle": "error",
94+
"constructor-super": "error",
95+
"curly": "off",
96+
"default-case": "error",
97+
"eol-last": "error",
98+
"eqeqeq": [
99+
"error",
100+
"smart"
101+
],
102+
"func-style": [
103+
"error",
104+
"declaration",
105+
{ "allowArrowFunctions": true }
106+
],
107+
"guard-for-in": "off",
108+
"id-blacklist": [
109+
"error",
110+
"any",
111+
"Number",
112+
"number",
113+
"String",
114+
"string",
115+
"Boolean",
116+
"boolean",
117+
"Undefined",
118+
"undefined"
119+
],
120+
"id-match": "error",
121+
"jsdoc/check-alignment": "error",
122+
"jsdoc/check-indentation": "error",
123+
"jsdoc/newline-after-description": "error",
124+
"max-len": [
125+
"error",
126+
{
127+
"code": 100
128+
}
129+
],
130+
"no-bitwise": "error",
131+
"no-caller": "error",
132+
"no-cond-assign": "error",
133+
"no-console": [
134+
"error",
135+
{
136+
"allow": [
137+
"log",
138+
"warn",
139+
"error",
140+
"dir",
141+
"assert",
142+
"clear",
143+
"count",
144+
"countReset",
145+
"group",
146+
"groupCollapsed",
147+
"groupEnd",
148+
"Console",
149+
"dirxml",
150+
"table",
151+
"markTimeline",
152+
"profile",
153+
"profileEnd",
154+
"timeline",
155+
"timelineEnd",
156+
"timeStamp",
157+
"context"
158+
]
159+
}
160+
],
161+
"no-control-regex": "error",
162+
"no-debugger": "error",
163+
"no-empty": "error",
164+
"no-extra-semi": "error",
165+
"no-eval": "error",
166+
"no-fallthrough": "error",
167+
"no-invalid-regexp": "error",
168+
"no-irregular-whitespace": "error",
169+
"no-multiple-empty-lines": "error",
170+
"no-new-wrappers": "error",
171+
"no-null/no-null": "off",
172+
"no-regex-spaces": "error",
173+
"no-shadow": [
174+
"off",
175+
{
176+
"hoist": "all"
177+
}
178+
],
179+
"no-throw-literal": "error",
180+
"no-trailing-spaces": "error",
181+
"no-unused-labels": "error",
182+
"no-var": "error",
183+
"object-curly-spacing": [
184+
"error",
185+
"always"
186+
],
187+
"prefer-const": "error",
188+
"radix": "error",
189+
"spaced-comment": [
190+
"error",
191+
"always",
192+
{
193+
"markers": [
194+
"/"
195+
]
196+
}
197+
],
198+
"use-isnan": "error"
199+
/*
200+
// check mapping of tslint to eslint rules and current status of rules migration here
201+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/ROADMAP.md
202+
"@typescript-eslint/tslint/config": [
203+
"error",
204+
{
205+
"rules": {
206+
"function-name": [
207+
true,
208+
{
209+
"method-regex": "^[a-z][\\w\\d]+$",
210+
"private-method-regex": "^__?[a-z][\\w\\d]+$",
211+
"static-method-regex": "^[a-z][\\w\\d]+$",
212+
"function-regex": "^[a-z][\\w\\d]+$"
213+
}
214+
],
215+
"no-unnecessary-local-variable": true,
216+
"no-unnecessary-override": true
217+
}
218+
}
219+
]
220+
*/
221+
}
222+
};

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v8.11.3
1+
v12.14.1

.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
"typescript.tsdk": "./node_modules/typescript/lib",
33
"editor.tabSize": 2,
44
"editor.detectIndentation": false,
5-
"tslint.nodePath": "./node_modules"
65
}

package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,23 @@
33
"name": "focal",
44
"scripts": {
55
"build": "yarn workspace @grammarly/focal build",
6+
"lint": "yarn lint:focal && yarn lint:test && yarn lint:todomvc && yarn lint:examples",
7+
"lint:focal": "yarn workspace @grammarly/focal lint",
8+
"lint:test": "yarn workspace focal-manual-tests lint",
9+
"lint:todomvc": "yarn workspace focal-todomvc lint",
10+
"lint:examples": "yarn workspace focal-examples lint",
611
"package": "yarn workspace @grammarly/focal pack",
712
"test": "yarn workspace @grammarly/focal test && yarn workspace focal-todomvc build && yarn workspace focal-examples build && yarn workspace focal-manual-tests build",
813
"postinstall": "yarn build",
914
"bump-version": "sh ./scripts/release.sh"
1015
},
1116
"devDependencies": {
12-
"@grammarly/tslint-config": "0.5.1",
13-
"tslint": "5.20.0",
17+
"@typescript-eslint/eslint-plugin": "^4.14.0",
18+
"@typescript-eslint/eslint-plugin-tslint": "^4.14.0",
19+
"@typescript-eslint/parser": "^4.14.0",
20+
"eslint": "^7.18.0",
21+
"eslint-plugin-jsdoc": "^31.0.8",
22+
"eslint-plugin-react": "^7.22.0",
1423
"typescript": "3.6.4"
1524
},
1625
"workspaces": [

packages/examples/all/.eslintrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
"parserOptions": {
3+
"project": "./tsconfig.json",
4+
"sourceType": "module",
5+
"tsconfigRootDir": __dirname,
6+
}
7+
}

packages/examples/all/package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"clean": "rm -rf ./build",
1515
"dev": "npm start",
1616
"start": "node ./webpack/dev_server.js",
17-
"test": "yarn build"
17+
"test": "yarn build",
18+
"lint": "eslint './src/**/*.ts*' && tsc --noemit"
1819
},
1920
"sideEffects": false,
2021
"author": "Grammarly, Inc.",
@@ -25,6 +26,8 @@
2526
"@types/react": "16.9.11",
2627
"@types/react-dom": "16.9.3",
2728
"css-loader": "^3.2.0",
29+
"eslint": "^7.18.0",
30+
"eslint-webpack-plugin": "^2.5.3",
2831
"express": "^4.14.0",
2932
"react": "16.11.0",
3033
"react-dom": "16.11.0",
@@ -36,12 +39,11 @@
3639
"todomvc-app-css": "^2.0.6",
3740
"ts-loader": "^6.2.1",
3841
"tslint": "5.20.0",
39-
"tslint-loader": "^3.3.0",
4042
"typescript": "3.6.4",
4143
"webpack": "^4.41.2",
44+
"webpack-bundle-analyzer": "^3.6.0",
4245
"webpack-cli": "^3.3.9",
4346
"webpack-dev-middleware": "^3.7.2",
44-
"webpack-hot-middleware": "^2.25.0",
45-
"webpack-bundle-analyzer": "^3.6.0"
47+
"webpack-hot-middleware": "^2.25.0"
4648
}
4749
}

packages/examples/all/src/app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface ExampleComponent<S> {
88

99
declare const require: (path: string) => any
1010

11-
const examples: { name: string, example: ExampleComponent<any> }[] = [
11+
const examples: { name: string; example: ExampleComponent<any> }[] = [
1212
'counter',
1313
'clock',
1414
'checkbox',

packages/examples/all/src/big-table/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const THead = (props: { columns: ReadOnlyAtom<string[]> }) =>
4848
</thead>
4949

5050
const TBody = (props: {
51-
state: Atom<typeof defaultState>,
51+
state: Atom<typeof defaultState>
5252
visibleRows: ReadOnlyAtom<{ begin: number; end: number }>
5353
}) =>
5454
<F.tbody>
@@ -75,7 +75,7 @@ const App = ({
7575
state,
7676
scrollTop = Atom.create(0)
7777
}: {
78-
state: Atom<typeof defaultState>,
78+
state: Atom<typeof defaultState>
7979
scrollTop: Atom<number>
8080
}) =>
8181
<div>

packages/examples/all/src/bmi/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react'
22
import { Atom, F, bind } from '@grammarly/focal'
33

44
interface AppState {
5-
weightKg: number,
5+
weightKg: number
66
heightCm: number
77
}
88

packages/examples/all/src/change-color/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const BOLD = 'bold'
1212

1313
interface AppState {
1414
style: {
15-
color: string,
15+
color: string
1616
font: string
1717
}
1818
}

packages/examples/all/src/convert-inputs/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const toFahrenheit = (celsius: number) => celsius * 9 / 5 + 32
55
const toCelsius = (fahrenheit: number) => (fahrenheit - 32) * 5 / 9
66

77
interface AppState {
8-
celsius: number,
8+
celsius: number
99
fahrenheit: number
1010
}
1111

packages/examples/all/src/hello/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react'
22
import { Atom, F, bind } from '@grammarly/focal'
33

44
interface AppState {
5-
firstName: string,
5+
firstName: string
66
lastName: string
77
}
88

packages/examples/all/src/http-search-github/index.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ enum ResultKind {
77
InProgress
88
}
99

10-
interface Success<T> { kind: ResultKind.Success, value: T }
11-
interface Failure { kind: ResultKind.Failure, error: any }
10+
interface Success<T> { kind: ResultKind.Success; value: T }
11+
interface Failure { kind: ResultKind.Failure; error: any }
1212
interface InProgress { kind: ResultKind.InProgress }
1313

1414
type Result<T> = Success<T> | Failure | InProgress
1515

16+
// eslint-disable-next-line @typescript-eslint/no-redeclare
1617
namespace Result {
1718
export function success<T>(value: T): Success<T> {
1819
return {
@@ -33,7 +34,7 @@ namespace Result {
3334

3435
interface AppState {
3536
searchString: string
36-
result: undefined | Result<{ url: string, name: string }[]>
37+
result: undefined | Result<{ url: string; name: string }[]>
3738
}
3839

3940
namespace AppState {

packages/examples/all/src/list-search/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ function getRandomSearchList() {
1111
}
1212

1313
interface AppState {
14-
searchString: string,
15-
searchList: string[],
14+
searchString: string
15+
searchList: string[]
1616
timer: number
1717
}
1818

0 commit comments

Comments
 (0)