forked from trueplan/forecast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eslintrc.js
More file actions
183 lines (183 loc) · 5.71 KB
/
.eslintrc.js
File metadata and controls
183 lines (183 loc) · 5.71 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
settings: {
react: {
version: "detect",
},
jest: {
version: require("jest/package.json").version,
},
"import/parsers": {
[require.resolve("@typescript-eslint/parser")]: [".ts", ".tsx", ".d.ts"],
},
"import/resolver": {
[require.resolve("eslint-import-resolver-node")]: {
extensions: [],
},
},
},
extends: [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:promise/recommended",
"plugin:import/recommended",
"plugin:unicorn/recommended",
"plugin:sonarjs/recommended",
"plugin:jsdoc/recommended",
],
rules: {
"jsdoc/require-description-complete-sentence": ["warn"],
"jsdoc/require-hyphen-before-param-description": ["warn"],
// Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins
"no-prototype-builtins": "off",
eqeqeq: ["error", "smart"],
"consistent-return": "off",
"array-callback-return": ["error", { allowImplicit: true }],
// Common abbreviations are known and readable
"unicorn/prevent-abbreviations": "off",
// We don't really have a filename style yet. To be discussed
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/filename-case.md
"unicorn/filename-case": "off",
"unicorn/no-null": "off",
"unicorn/no-array-reduce": "off",
"unicorn/prefer-node-protocol": "off",
// conflicts with react hooks
"unicorn/no-useless-undefined": "off",
// weirdly specific
"unicorn/import-style": "off",
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
"import/prefer-default-export": "off",
"import/no-default-export": "error",
"import/order": [
"warn",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
],
},
],
},
overrides: [
{
files: ["*.{ts,tsx}"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
],
rules: {
// jsdoc types are redundant with typescript
"jsdoc/no-types": ["error", { contexts: ["any"] }],
"jsdoc/require-returns-type": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-property-type": "off",
// This rule tells people to do something (import foo = require('foo')) which doesn't work
// with babel compiled typescript.
"@typescript-eslint/no-var-requires": "off",
// Warn about incorrect type imports
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-imports.md
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-shadow": [
"error",
{ ignoreFunctionTypeParameterNameValueShadow: true },
],
// Makes no sense to allow type inference for expression parameters, but require typing the response
"@typescript-eslint/explicit-function-return-type": [
"error",
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
},
],
"@typescript-eslint/no-use-before-define": [
"error",
{
functions: false,
classes: true,
variables: true,
typedefs: true,
},
],
},
},
{
files: ["*.{js,cjs}"],
parser: "@babel/eslint-parser",
rules: {
"unicorn/prefer-module": "off",
},
},
{
files: ["*.{tsx,jsx}"],
extends: [
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
],
rules: {
// no-onchange rule is deprecated:
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
"jsx-a11y/no-onchange": "off",
// PropTypes are useless with typescript
"react/prop-types": "off",
"react/no-unescaped-entities": "off",
},
},
{
files: ["*.{test,spec}.{ts,tsx,js}"],
env: {
jest: true,
},
extends: [
"plugin:jest/recommended",
"plugin:jest-formatting/recommended",
"plugin:testing-library/react",
],
rules: {
"@typescript-eslint/no-empty-function": "off",
"import/no-default-export": "off",
"react/display-name": "off",
"unicorn/prefer-dom-node-dataset": "off",
},
},
{
files: ["*.{ts,tsx,js,jsx,cjs}"],
extends: ["prettier"],
},
{
files: ["website/**/*.{ts,tsx}"],
rules: {
// suppress errors for missing 'import React' in files
"react/react-in-jsx-scope": "off",
// allow jsx syntax in js files (for next.js project)
"react/jsx-filename-extension": [1, { extensions: [".ts", ".tsx"] }],
},
},
// Next.js needs default exports for pages and API points
{
files: ["website/pages/**/*"],
rules: {
"import/no-default-export": "off",
},
},
],
};