forked from RueNetwork/RueClient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
138 lines (128 loc) · 4.2 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
/** @format */
const { merge } = require( 'lodash' );
const reactVersion = require( './package.json' ).dependencies.react;
module.exports = {
root: true,
extends: [
'wpcalypso/react',
'plugin:jsx-a11y/recommended',
'plugin:jest/recommended',
'prettier',
'prettier/react',
],
overrides: [
{
files: [ 'bin/**/*' ],
rules: {
'import/no-nodejs-modules': 0,
'no-console': 0,
'no-process-exit': 0,
'valid-jsdoc': 0,
},
},
{
files: [ 'test/e2e/**/*' ],
rules: {
'import/no-nodejs-modules': 0,
'import/no-extraneous-dependencies': 0,
'no-console': 0,
'jest/valid-describe': 0,
'jest/no-test-prefixes': 0,
'jest/no-identical-title': 0,
},
globals: {
step: false,
},
},
merge(
// ESLint doesn't allow the `extends` field inside `overrides`, so we need to compose
// the TypeScript config manually using internal bits from various plugins
{},
// base TypeScript config: parser options, add plugin with rules
require( '@typescript-eslint/eslint-plugin' ).configs.base,
// basic recommended rules config from the TypeScript plugin
{ rules: require( '@typescript-eslint/eslint-plugin' ).configs.recommended.rules },
// Prettier rules config
require( 'eslint-config-prettier/@typescript-eslint' ),
// Our own overrides
{
files: [ '**/*.ts', '**/*.tsx' ],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-unused-vars': [ 'error', { ignoreRestSiblings: true } ],
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, typedefs: false },
],
'no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
// REST API objects include underscores
'@typescript-eslint/camelcase': 'off',
'valid-jsdoc': [
2,
{
requireParamType: false,
requireReturn: false,
requireReturnType: false,
},
],
},
}
),
],
env: {
browser: true,
jest: true,
// mocha is only still on because we have not finished porting all of our tests to jest's syntax
mocha: true,
node: true,
},
globals: {
// this is our custom function that's transformed by babel into either a dynamic import or a normal require
asyncRequire: true,
// this is the SHA of the current commit. Injected at boot in a script tag.
COMMIT_SHA: true,
// this is when Webpack last built the bundle
BUILD_TIMESTAMP: true,
},
plugins: [ 'jest', 'jsx-a11y', 'import' ],
settings: {
react: {
version: reactVersion,
},
},
rules: {
// REST API objects include underscores
camelcase: 0,
// TODO: why did we turn this off?
'jest/valid-expect': 0,
// Deprecated rule, fails in some valid cases with custom input components
'jsx-a11y/label-has-for': 0,
// i18n-calypso translate triggers false failures
'jsx-a11y/anchor-has-content': 0,
// error if any module depends on the data-observe mixin, which is deprecated
'no-restricted-imports': [ 2, 'lib/mixins/data-observe' ],
'no-restricted-modules': [ 2, 'lib/mixins/data-observe' ],
// Allows Chai `expect` expressions. Now that we're on jest, hopefully we can remove this one.
'no-unused-expressions': 0,
// enforce our classname namespacing rules
'wpcalypso/jsx-classname-namespace': [
2,
{
rootFiles: [ 'index.js', 'index.jsx', 'main.js', 'main.jsx' ],
},
],
// Force folks to use our custom combineReducers function instead of the plain redux one
// This allows us to control serialization for every reducer.
'wpcalypso/import-no-redux-combine-reducers': 2,
// Disallow importing of native node modules, with some exceptions
// - url because we use it all over the place to parse and build urls
// - events because we use it for some event emitters
// - path because we use it quite a bit
'import/no-nodejs-modules': [ 'error', { allow: [ 'url', 'events', 'path', 'config' ] } ],
// Disallow importing or requiring packages that are not listed in package.json
// This prevents us from depending on transitive dependencies, which could break in unexpected ways.
'import/no-extraneous-dependencies': [ 'error', { packageDir: './' } ],
},
};