Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit e49e121

Browse files
levithomasonlayershifter
authored andcommitted
chore(package): add ESLint (#600)
* chore: replace ts-lint with eslint * update dependencies, fix configs * wip! * remove TSLint rule * revert changes in focusUtilities * disable import rule for whole directory * cleanup configs * revert change in test * more dependencies, rearrange configs, disable rules * disable more rules * disable more rules * disable more rules * restore TSLint * restore rules and configs * fix eval issue
1 parent 3ba7100 commit e49e121

File tree

15 files changed

+702
-91
lines changed

15 files changed

+702
-91
lines changed

.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.awcache/
2+
coverage/
3+
dist/
4+
dll/
5+
node_modules/

.eslintrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": ["./packages/internal-tooling/eslint/index.js"],
3+
"root": true
4+
}

.prettierignore

-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
.github/
2-
31
# editor configs
42
.idea/
53
.vscode/
64

75

86
coverage/
9-
107
dist/
118
dll/
12-
docs/src/componentInfo
13-
docs/src/componentMenu.json
14-
docs/src/behaviorMenu.json
15-
docs/src/exampleMenus
16-
docs/dist/
179
stats/
1810

1911
package.json

.prettierrc.json

+2-10
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@
22
"$schema": "http://json.schemastore.org/prettierrc",
33
"htmlWhitespaceSensitivity": "ignore",
44
"printWidth": 100,
5-
"tabWidth": 2,
65
"semi": false,
76
"singleQuote": true,
8-
"trailingComma": "all",
9-
"overrides": [
10-
{
11-
"files": ".prettierrc",
12-
"options": {
13-
"parser": "json"
14-
}
15-
}
16-
]
7+
"tabWidth": 2,
8+
"trailingComma": "all"
179
}

build/gulp/plugins/util/parseType.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const _ = require('lodash')
22

3+
// eslint-disable-next-line no-eval
34
const evalValue = value => eval(value) // tslint:disable-line no-eval
45

56
const isTransformable = value => typeof value === 'string' && value.includes('names')

build/gulp/sh.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { spawn } from 'child_process'
1+
import * as childProcess from 'child_process'
22

3-
const sh = (command: string, pipeOutputToResult: boolean = false): Promise<string> => {
4-
return new Promise((resolve, reject) => {
3+
const sh = (command: string, pipeOutputToResult: boolean = false): Promise<string> =>
4+
new Promise((resolve, reject) => {
55
const [cmd, ...args] = command.split(' ')
66

7-
const options = {
7+
const options: childProcess.SpawnOptions = {
88
cwd: process.cwd(),
99
env: process.env,
1010
stdio: pipeOutputToResult ? 'pipe' : [0, 1, 2],
1111
shell: true,
1212
}
1313

14-
const child = spawn(cmd, args, options)
14+
const child = childProcess.spawn(cmd, args, options)
1515

1616
let stdoutData = ''
1717

@@ -29,6 +29,5 @@ const sh = (command: string, pipeOutputToResult: boolean = false): Promise<strin
2929
reject(new Error(`child process exited with code ${code}`))
3030
})
3131
})
32-
}
3332

3433
export default sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"import/no-unresolved": "off"
4+
}
5+
}

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
"clean:cache": "gulp clean:cache",
99
"predeploy:docs": "cross-env NODE_ENV=production yarn build:docs",
1010
"deploy:docs": "gulp deploy:docs",
11-
"lint": "cross-env NODE_OPTIONS='-r ts-node/register' tslint -t stylish -p . --rules-dir ./build/tslint",
12-
"lint:fix": "yarn lint --fix",
11+
"lint": "eslint \"**/*.{js,ts,tsx}\" && yarn lint:old",
12+
"lint:fix": "yarn lint --fix && yarn lint:old --fix",
13+
"lint:old": "cross-env NODE_OPTIONS='-r ts-node/register' tslint -t stylish -p . --rules-dir ./build/tslint",
1314
"perf": "cross-env PERF=true gulp perf --times=50",
1415
"perf:debug": "cross-env PERF=true gulp perf:debug --debug",
1516
"prettier": "prettier --list-different \"**/*.{ts,tsx}\"",
@@ -39,6 +40,7 @@
3940
"**/*.{ts,tsx}": [
4041
"prettier --write",
4142
"tslint -t stylish --fix",
43+
"eslint --fix",
4244
"git add"
4345
],
4446
"**/*.{js,json}": [
+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
module.exports = {
2+
extends: ['airbnb', 'plugin:prettier/recommended'],
3+
parser: '@typescript-eslint/parser',
4+
plugins: ['@typescript-eslint', 'jest', 'import', 'prettier', 'react-hooks'],
5+
env: {
6+
browser: true,
7+
'jest/globals': true,
8+
},
9+
rules: {
10+
// False positive on arg types:
11+
// https://github.com/typescript-eslint/typescript-eslint/issues/46
12+
// '@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
13+
'import/no-unresolved': 'off',
14+
'prettier/prettier': 'error',
15+
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
16+
semi: ['error', 'never'],
17+
18+
// Temporary disabled rules
19+
'@typescript-eslint/no-unused-vars': 'off',
20+
'jsx-a11y/click-events-have-key-events': 'off',
21+
'jsx-a11y/no-static-element-interactions': 'off',
22+
'jsx-a11y/alt-text': 'off',
23+
'jsx-a11y/anchor-is-valid': 'off',
24+
'jsx-a11y/label-has-for': 'off',
25+
'jsx-a11y/label-has-associated-control': 'off',
26+
'jsx-a11y/no-noninteractive-tabindex': 'off',
27+
'import/export': 'off',
28+
'import/first': 'off',
29+
'import/order': 'off',
30+
'import/no-dynamic-require': 'off',
31+
'import/no-extraneous-dependencies': 'off',
32+
'import/no-named-default': 'off',
33+
'import/no-useless-path-segments': 'off',
34+
'import/newline-after-import': 'off',
35+
'import/prefer-default-export': 'off',
36+
'react/button-has-type': 'off',
37+
'react/destructuring-assignment': 'off',
38+
'react/default-props-match-prop-types': 'off',
39+
'react/jsx-curly-brace-presence': 'off',
40+
'react/jsx-boolean-value': 'off',
41+
'react/jsx-no-bind': 'off',
42+
'react/jsx-one-expression-per-line': 'off',
43+
'react/jsx-pascal-case': 'off',
44+
'react/jsx-wrap-multilines': 'off',
45+
'react/no-access-state-in-setstate': 'off',
46+
'react/no-children-prop': 'off',
47+
'react/no-array-index-key': 'off',
48+
'react/no-find-dom-node': 'off',
49+
'react/jsx-no-target-blank': 'off',
50+
'react/forbid-prop-types': 'off',
51+
'react/prefer-stateless-function': 'off',
52+
'react/no-multi-comp': 'off',
53+
'react/no-unused-prop-types': 'off',
54+
'react/no-unused-state': 'off',
55+
'react/no-unescaped-entities': 'off',
56+
'react/prop-types': 'off',
57+
'react/require-default-props': 'off',
58+
'react/sort-comp': 'off',
59+
'react/no-string-refs': 'off',
60+
'react/no-render-return-value': 'off',
61+
camelcase: 'off',
62+
'class-methods-use-this': 'off',
63+
'consistent-return': 'off',
64+
'default-case': 'off',
65+
'dot-notation': 'off',
66+
'global-require': 'off',
67+
'guard-for-in': 'off',
68+
'lines-between-class-members': 'off',
69+
'no-await-in-loop': 'off',
70+
'no-bitwise': 'off',
71+
'no-case-declarations': 'off',
72+
'no-empty': 'off',
73+
'no-continue': 'off',
74+
'no-extra-boolean-cast': 'off',
75+
'no-fallthrough': 'off',
76+
'no-nested-ternary': 'off',
77+
'no-param-reassign': 'off',
78+
'no-plusplus': 'off',
79+
'no-prototype-builtins': 'off',
80+
'no-return-await': 'off',
81+
'no-return-assign': 'off',
82+
'no-restricted-globals': 'off',
83+
'no-restricted-syntax': 'off',
84+
'no-throw-literal': 'off',
85+
'no-sparse-arrays': 'off',
86+
'no-shadow': 'off',
87+
'no-undef': 'off',
88+
'no-undef-init': 'off',
89+
'no-underscore-dangle': 'off',
90+
'no-unused-expressions': 'off',
91+
'no-useless-return': 'off',
92+
'no-unused-vars': 'off',
93+
'no-empty-function': 'off',
94+
'no-useless-constructor': 'off',
95+
'no-useless-escape': 'off',
96+
'no-use-before-define': 'off',
97+
'operator-assignment': 'off',
98+
'prefer-destructuring': 'off',
99+
'spaced-comment': 'off',
100+
},
101+
overrides: [
102+
{
103+
files: '**/jest.config.js',
104+
rules: {
105+
'global-require': 'off',
106+
},
107+
},
108+
{
109+
files: '**/test/**/*.{ts,tsx}',
110+
rules: {
111+
'import/no-extraneous-dependencies': 'off',
112+
},
113+
},
114+
],
115+
settings: {
116+
'import/resolver': {
117+
node: {
118+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
119+
},
120+
},
121+
},
122+
}

packages/internal-tooling/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@
1010
"@babel/preset-typescript": "^7.3.3",
1111
"@types/jest": "^24.0.11",
1212
"@types/jest-axe": "^2.2.3",
13+
"@typescript-eslint/eslint-plugin": "^1.6.0",
14+
"@typescript-eslint/parser": "^1.6.0",
1315
"babel-jest": "^24.5.0",
16+
"eslint": "^5.16.0",
17+
"eslint-config-airbnb": "^17.1.0",
18+
"eslint-config-prettier": "^4.1.0",
19+
"eslint-plugin-import": "^2.17.2",
20+
"eslint-plugin-jest": "^22.4.1",
21+
"eslint-plugin-jsx-a11y": "^6.2.1",
22+
"eslint-plugin-prettier": "^3.0.1",
23+
"eslint-plugin-react": "^7.12.4",
24+
"eslint-plugin-react-hooks": "^1.6.0",
1425
"jest": "^24.5.0",
1526
"jest-axe": "^3.1.1"
1627
},

packages/react-proptypes/src/leven.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copy of sindre's leven, wrapped in dead code elimination for production
22
// https://github.com/sindresorhus/leven/blob/master/index.js
3+
/* eslint-disable */
34

45
let leven = (a, b) => 0
56

packages/react/.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/themes/teams/components/Icon/svg/ProcessedIcons

packages/react/.eslintrc.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": ["../internal-tooling/eslint/index.js"],
3+
"overrides": [
4+
{
5+
"files": "**/icons/*.tsx",
6+
"rules": {
7+
"react/prop-types": "off"
8+
}
9+
}
10+
],
11+
"root": true
12+
}

packages/react/src/lib/whatInput.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import isBrowser from './isBrowser'
22

33
// Taken from https://github.com/ten1seven/what-input/blob/master/src/scripts/what-input.js
4+
/* eslint-disable */
45

56
/*
67
* variables

0 commit comments

Comments
 (0)