-
Notifications
You must be signed in to change notification settings - Fork 4
/
.eslintrc.js
155 lines (154 loc) · 5.07 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
145
146
147
148
149
150
151
152
153
154
155
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: [
'eslint:recommended',
'plugin:unicorn/recommended',
'plugin:cypress/recommended',
'plugin:import/typescript',
'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
],
plugins: ['import', 'tsdoc', 'sort-destructure-keys'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
},
env: { 'shared-node-browser': true },
settings: {
'import/resolver': {
typescript: true,
node: true,
},
},
rules: {
// eslint built-in rules (override recommended)
curly: 'warn',
'new-cap': [
'error',
{
newIsCap: true,
newIsCapExceptions: [],
capIsNew: false,
capIsNewExceptions: [
'Immutable.Map',
'Immutable.Set',
'Immutable.List',
],
},
],
'no-console': ['warn', { allow: ['error', 'warn', 'debug'] }],
'no-else-return': ['error', { allowElseIf: false }],
'no-extra-semi': 'off',
'object-shorthand': 'warn',
'prefer-destructuring': 'warn',
'prefer-template': 'warn',
quotes: ['error', 'single', { avoidEscape: true }],
radix: 'error',
'spaced-comment': [
'warn',
'always',
// allow TS /// directives
{ line: { markers: ['/'] } },
],
// @typescript-eslint/eslint-plugin rules (override recommended)
'@typescript-eslint/lines-between-class-members': [
'warn',
'always',
{ exceptAfterSingleLine: true },
],
'@typescript-eslint/no-extraneous-class': [
'error',
{ allowWithDecorator: true },
],
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
],
'@typescript-eslint/restrict-template-expressions': [
'warn',
{ allowNumber: true },
],
'@typescript-eslint/return-await': 'error',
// eslint-plugin-import rules
'import/export': 'error',
'import/no-duplicates': 'warn',
'import/no-extraneous-dependencies': 'error',
'import/no-named-as-default': 'warn',
// eslint-plugin-sort-destructure-keys rules
'sort-destructure-keys/sort-destructure-keys': 'warn',
// eslint-plugin-tsdoc rules
'tsdoc/syntax': 'warn',
// eslint-plugin-unicorn rules (override recommended)
'unicorn/filename-case': 'off', // Doesn't match our file naming, maybe can be configured later
'unicorn/no-empty-file': 'off', // False positives
'unicorn/no-null': 'off', // A lot of null in React and other libraries
'unicorn/prefer-module': 'off', // Cypress and apollo-collaboration-server need this
'unicorn/prevent-abbreviations': 'off', // Doesn't guess a lot of abbreviations correctly
},
overrides: [
// Only use React-specific lint rules in jbrowse-plugin-apollo
{
files: ['./packages/jbrowse-plugin-apollo/**/*.{ts,tsx}'],
env: { browser: true },
extends: [
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
],
settings: {
// These settings are from eslint-plugin-react
react: {
// React version. "detect" automatically picks the version you have installed.
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
// It will default to "latest" and warn if missing, and to "detect" in the future
version: 'detect',
},
componentWrapperFunctions: [
// The name of any function used to wrap components, e.g. Mobx `observer` function. If this isn't set, components wrapped by these functions will be skipped.
'observer', // `property`
{ property: 'styled' }, // `object` is optional
{ property: 'observer', object: 'Mobx' },
{ property: 'observer', object: '<pragma>' }, // sets `object` to whatever value `settings.react.pragma` is set to
],
},
},
// Lint non-src JS files (e.g. jest.config.js) using a separate tsconfig
{
files: ['./packages/jbrowse-plugin-apollo/*.js'],
parserOptions: {
project: 'packages/jbrowse-plugin-apollo/tsconfig.eslint.json',
},
env: { node: true },
},
{
files: ['./packages/apollo-cli/*.{c,}js'],
parserOptions: {
project: 'packages/apollo-cli/tsconfig.eslint.json',
},
env: { node: true },
},
// Specify Node env and tsconfig for cypress testing and config files
{
files: [
'./packages/jbrowse-plugin-apollo/cypress.config.js',
'./packages/jbrowse-plugin-apollo/cypress/**/*.{j,t}s',
],
parserOptions: {
project: 'packages/jbrowse-plugin-apollo/cypress/tsconfig.json',
},
env: { node: true },
},
// Specify Node env for apollo-collaboration-server/
{
files: ['./packages/apollo-collaboration-server/**/*.ts'],
env: { node: true },
},
// Don't enforce tsdoc syntax in JS files
{
files: ['**/*.js'],
rules: {
'tsdoc/syntax': 'off',
},
},
],
}