forked from twilio-labs/paste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
144 lines (143 loc) · 5.1 KB
/
.eslintrc.js
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
const path = require('path');
const cachedPackages = require('./tools/.cache/packages.json');
// Based on https://github.com/iamturns/create-exposed-app/blob/master/.eslintrc.js
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
plugins: [
'@typescript-eslint',
'eslint-comments',
'jest',
'promise',
'unicorn',
'@emotion/eslint-plugin',
'import',
'jsx-a11y',
],
extends: [
'airbnb-typescript',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-comments/recommended',
'plugin:cypress/recommended',
'plugin:jest/recommended',
'plugin:promise/recommended',
'plugin:unicorn/recommended',
'plugin:react/recommended',
'prettier',
'plugin:paste-internal/all',
],
env: {
node: true,
browser: true,
jest: true,
},
rules: {
// Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'off',
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
'import/prefer-default-export': 'off',
'import/no-default-export': 'error',
// Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
'react/destructuring-assignment': 'off',
// No jsx extension: https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
'react/jsx-filename-extension': 'off',
// Doesnt really work in our use-cases: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
'react/require-default-props': 'off',
// Clashes with @typescript-eslint/parser
'no-use-before-define': 0,
'comma-dangle': 'off',
'@typescript-eslint/comma-dangle': ['error', 'only-multiline'],
// Makes no sense to allow type inferrence 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,
},
],
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-shadow': ['error', {ignoreFunctionTypeParameterNameValueShadow: true}],
// Common abbreviations are known and readable
'unicorn/prevent-abbreviations': 'off',
// We don't really have a 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-reduce': 'off',
'unicorn/no-fn-reference-in-iterator': 'off',
// weirdly specific
'unicorn/import-style': 'off',
'unicorn/prefer-ternary': 'off',
// Too big of a change
'unicorn/numeric-separators-style': 'off',
// Mixed ts and node code base
'unicorn/prefer-module': 'warn',
// 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',
// PropTypes are useless with typescript
'react/prop-types': 'off',
// ignore dev deps by default, point eslint to all package.json files in the monorepo
'import/no-extraneous-dependencies': [
'error',
{
packageDir: [path.join(__dirname, './'), ...cachedPackages.map((package) => package.location)],
},
],
'react/jsx-curly-brace-presence': 0,
'react/jsx-props-no-spreading': 0,
'react/display-name': 2,
'no-useless-constructor': 'off',
eqeqeq: ['error', 'smart'],
'no-plusplus': 'off',
'consistent-return': 'off',
'array-callback-return': ['error', {allowImplicit: true}],
// deprecated rule
'jsx-a11y/label-has-for': 'off',
'jsx-a11y/label-has-associated-control': [
2,
{
assert: 'either',
depth: 3,
},
],
// We don't use jasmine and this clashes with danger js
'jest/no-jasmine-globals': 'off',
// New rules
'unicorn/no-array-reduce': 'warn',
'unicorn/no-array-for-each': 'warn',
'unicorn/prefer-dom-node-dataset': 'warn',
'unicorn/no-lonely-if': 'warn',
'unicorn/prefer-export-from': 'warn',
'unicorn/no-array-callback-reference': 'warn',
'unicorn/consistent-destructuring': 'warn',
'unicorn/prefer-number-properties': 'warn',
'unicorn/prefer-node-protocol': 'warn',
'unicorn/prefer-spread': 'warn',
'unicorn/prefer-regexp-test': 'warn',
'unicorn/no-new-array': 'warn',
'unicorn/prefer-object-from-entries': 'warn',
'react/jsx-key': 'warn',
'jest/no-conditional-expect': 'warn',
},
settings: {
react: {
version: '17.0.2',
},
},
};