forked from eps1lon/dom-accessibility-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc
94 lines (94 loc) · 3.41 KB
/
.eslintrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
// trade off between having a warning without consequences on main
// and having no warning but non-descriptive errors when using typescript@^3.8 syntax
"warnOnUnsupportedTypeScriptVersion": false
},
"plugins": ["@typescript-eslint"],
"rules": {
// required for window.Element
"@typescript-eslint/ban-ts-ignore": "off",
// I find this rule not very helpful since it prevents me from ordering
// functions in a file by importance e.g. default export at the top
"@typescript-eslint/no-use-before-define": "off",
"no-restricted-properties": [
2,
{
"object": "window",
// we restrict usage since it is quite costly in jsdom
// we only access it from a point where the library user can inject their
// own implementation. See https://github.com/eps1lon/dom-accessibility-api/blob/eb868428a31a093aecc531bf2dd17e8547bd0c3b/sources/accessible-name.ts#L33
"property": "getComputedStyle"
},
{
// `tagName` is oftentimes more expensive since it requires a toAsciiUpperCase of the local name.
// It certainly is in JSDOM: https://github.com/jsdom/jsdom/pull/3008
"property": "tagName",
"message": "Please use `getLocalName` instead because `tagName` is oftentimes more expensive since it requires a toAsciiUpperCase of the local name."
},
{
// `localName` is not available in all supported environments.
// We have a cross-browser helper with `getLocalName`
"property": "localName",
"message": "Please use `getLocalName` which implements .localName for older environments."
}
],
"no-restricted-syntax": [
"error",
{
"selector": "ForOfStatement",
"message": "for-of assumes iterators which require heavy transpilation for es5. Use ArrayFrom(...).forEach instead."
}
],
// Babel transpiles array spread assuming iterators.
// If we know we have an array we cann use .apply instead.
// TypeScript will validate that claim.
"prefer-spread": "off"
},
"overrides": [
{
"files": ["**/*.js"],
"rules": {
// this rule is unfixable in untyped languages
// https://github.com/typescript-eslint/typescript-eslint/blob/v3.4.0/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md#configuring-in-a-mixed-jsts-codebase
"@typescript-eslint/explicit-module-boundary-types": "off",
// this rule is unfixable in untyped languages
// https://github.com/typescript-eslint/typescript-eslint/blob/v2.31.0/packages/eslint-plugin/docs/rules/explicit-function-return-type.md#configuring-in-a-mixed-jsts-codebase
"@typescript-eslint/explicit-function-return-type": "off"
}
},
{
"files": ["**/__tests__/**/*.js"],
"env": {
"browser": true
},
"extends": ["plugin:jest/recommended"],
"plugins": ["jest"],
"rules": {
// disable previous window.getComputedStyles restriction
// perf concerns for this aren't applicable to test
// since we specifically want to test them
"no-restricted-properties": "off",
// disable previous for-of restriction
// over transpilation isn't a concern for tests
"no-restricted-syntax": "off"
}
},
{
"files": ["scripts/jest/**/*.js"],
"env": {
"node": true
},
"rules": {
// jest uses commonJS
"@typescript-eslint/no-var-requires": "off"
}
}
]
}