@necrobox/eslint-config 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js ADDED
@@ -0,0 +1,260 @@
1
+ module.exports = {
2
+ extends: 'airbnb',
3
+ env: {
4
+ es2020: true,
5
+ },
6
+ parserOptions: {
7
+ ecmaVersion: 2020,
8
+ },
9
+ globals: {
10
+ // React
11
+ b: 'readonly',
12
+ T: 'readonly',
13
+ Component: 'readonly',
14
+ Fragment: 'readonly',
15
+ PropTypes: 'readonly',
16
+ PureComponent: 'readonly',
17
+ React: 'readonly',
18
+ ReactDOM: 'readonly',
19
+
20
+ // Env variables
21
+ APPLICATION_VERSION: 'readonly',
22
+ BUILD_TIMESTAMP: 'readonly',
23
+ APPLICATION_ENVIRONMENT: 'readonly',
24
+ GIT_COMMIT: 'readonly',
25
+ BASE_PATH: 'readonly',
26
+ },
27
+ rules: {
28
+ // Turned off, because it's based on teams POVs.
29
+ 'arrow-parens': 'off',
30
+
31
+ // Gets in the way of BEM.
32
+ camelcase: 'off',
33
+
34
+ // Forces to create useless static methods or even separated functions.
35
+ 'class-methods-use-this': 'off',
36
+
37
+ // Commonly used in projects, e.g. in JSX files.
38
+ 'global-require': 'off',
39
+
40
+ // Things happen.
41
+ 'max-len': 'off',
42
+
43
+ // Yeah, Promise.all is great, but in CLI apps we do want to use await in loops, and it's fine.
44
+ 'no-await-in-loop': 'off',
45
+
46
+ // `console.log` is removed in production by minifier, but in dev env we usually need it.
47
+ 'no-console': 'off',
48
+
49
+ // Makes logic too explicit, which is usually not so handy.
50
+ 'no-mixed-operators': 'off',
51
+
52
+ // Doesn't prevent mutation, but gets in the way of optimizations and performance improvements in the complex projects (FD-1861)
53
+ 'no-param-reassign': 'off',
54
+
55
+ // Makes sense when `;` isn't used at the end of lines. But we use `;`.
56
+ 'no-plusplus': 'off',
57
+
58
+ // In Airbnb config 'always' is turned on, but it doesn't allow things like this: ref={r => (this.root = r)}.
59
+ // So leave the rule, but add an exception.
60
+ 'no-return-assign': ['error', 'except-parens'],
61
+
62
+ // Same as Airbnb's except it allows default exports.
63
+ 'no-restricted-exports': ['error', {
64
+ restrictedNamedExports: ['then'],
65
+ }],
66
+
67
+ // Same as Airbnb used, but without restricting `ForOfStatement`.
68
+ // It's disabled there because it's “heavyweight” due to requiring regenerator-runtime. But our projects already use regenerator-runtime, so why not.
69
+ 'no-restricted-syntax': [
70
+ 'error',
71
+ {
72
+ selector: 'ForInStatement',
73
+ message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
74
+ },
75
+ {
76
+ selector: 'LabeledStatement',
77
+ message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
78
+ },
79
+ {
80
+ selector: 'WithStatement',
81
+ message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
82
+ },
83
+ ],
84
+
85
+ // Allows to use funcs and classes before their definition, 'cause it may be handy.
86
+ // Such variables usage isn't allowed by default.
87
+ 'no-use-before-define': ['error', {
88
+ functions: false,
89
+ classes: false,
90
+ }],
91
+
92
+ // Multiline object definition is a matter of likes and dislikes.
93
+ // But when do it, let's do it properly.
94
+ 'object-curly-newline': ['error', {
95
+ multiline: true,
96
+ consistent: true,
97
+ }],
98
+
99
+ // Destructuring is not always the right way to write code.
100
+ // E.g. chains like `event.target.width` are fine.
101
+ 'prefer-destructuring': 'off',
102
+
103
+ // `parseInt` autodetected octal literals in the older versions of ECMAScript, which we don't use nowadays.
104
+ // So using `parseInt` w/o radix is totally fine.
105
+ 'radix': 'off',
106
+
107
+ // Does not allow reexport elements of BEM blocks with *.
108
+ // But such reexport makes use of external blocks libraries easier.
109
+ 'import/named': 'off',
110
+
111
+ // Only devDeps and general deps are allowed.
112
+ 'import/no-extraneous-dependencies': ['error', {
113
+ devDependencies: true,
114
+ optionalDependencies: false,
115
+ }],
116
+
117
+ // Usually when loaders are used in projects like this it makes sense.
118
+ 'import/no-webpack-loader-syntax': 'off',
119
+
120
+ // Not always true. E.g. we can have files with constants or actions creators with only one entity.
121
+ 'import/prefer-default-export': 'off',
122
+
123
+ // Not always convenient.
124
+ 'react/destructuring-assignment': 'off',
125
+
126
+ // Sometimes a component may not know about the structure of an object of an array.
127
+ // E.g. when it have to pass them in the call chain.
128
+ 'react/forbid-prop-types': 'off',
129
+
130
+ // Let the developer decide.
131
+ 'react/function-component-definition': 'off',
132
+
133
+ // Not always convenient.
134
+ 'react/jsx-closing-tag-location': 'off',
135
+
136
+ // To make it work with Fragment as global var.
137
+ 'react/jsx-no-undef': [2, { allowGlobals: true }],
138
+
139
+ // Works incorrectly with   and the similar things.
140
+ 'react/jsx-one-expression-per-line': 'off',
141
+
142
+ // Gets in the way of BEM.
143
+ 'react/jsx-pascal-case': 'off',
144
+
145
+ // Not always convenient.
146
+ 'react/jsx-props-no-spreading': 'off',
147
+
148
+ // Remove spaces even in front of `/>`, because it's prettier.
149
+ 'react/jsx-tag-spacing': ['error', {
150
+ closingSlash: 'never',
151
+ beforeSelfClosing: 'never',
152
+ afterOpening: 'never',
153
+ beforeClosing: 'never',
154
+ }],
155
+
156
+ // Sometimes it's convenient. Let the developer decide.
157
+ 'react/no-array-index-key': 'off',
158
+
159
+ // Prevents loops in UI, but doesn't allow to change state when it's needed.
160
+ // It's nearly impossible to ignore the error it prevents.
161
+ // So it's easier to turn it off globally rather then in every project (FD-2353).
162
+ 'react/no-did-update-set-state': 'off',
163
+
164
+ // When it's important it's easier to use babel-plugin that transforms classes into functions.
165
+ 'react/prefer-stateless-function': 'off',
166
+
167
+ // defaultProps is't used everywhere.
168
+ 'react/require-default-props': 'off',
169
+
170
+ // Same order as in Airbnb, but without prefix checks (`on`, `get`, `set`)
171
+ 'react/sort-comp': ['error', {
172
+ order: [
173
+ 'static-methods',
174
+ 'instance-variables',
175
+ 'lifecycle',
176
+ 'instance-methods',
177
+ 'everything-else',
178
+ 'rendering',
179
+ ],
180
+ groups: {
181
+ lifecycle: [
182
+ 'displayName',
183
+ 'propTypes',
184
+ 'contextTypes',
185
+ 'childContextTypes',
186
+ 'mixins',
187
+ 'statics',
188
+ 'defaultProps',
189
+ 'constructor',
190
+ 'getDefaultProps',
191
+ 'getInitialState',
192
+ 'state',
193
+ 'getChildContext',
194
+ 'componentWillMount',
195
+ 'componentDidMount',
196
+ 'componentWillReceiveProps',
197
+ 'shouldComponentUpdate',
198
+ 'componentWillUpdate',
199
+ 'componentDidUpdate',
200
+ 'componentWillUnmount',
201
+ ],
202
+ rendering: [
203
+ '/^render.+$/',
204
+ 'render',
205
+ ],
206
+ },
207
+ }],
208
+
209
+ // Let the developer decide.
210
+ 'react/state-in-constructor': 'off',
211
+
212
+ // Deprecated and most likely will stop working in the future.
213
+ // So turn it off today.
214
+ 'jsx-a11y/label-has-for': 'off',
215
+
216
+ // A11y rules should be turned on when they're necessary in the project
217
+ 'jsx-a11y/accessible-emoji': 'off',
218
+ 'jsx-a11y/anchor-has-content': 'off',
219
+ 'jsx-a11y/aria-activedescendant-has-tabindex': 'off',
220
+ 'jsx-a11y/click-events-have-key-events': 'off',
221
+ 'jsx-a11y/iframe-has-title': 'off',
222
+ 'jsx-a11y/img-redundant-alt': 'off',
223
+ 'jsx-a11y/interactive-supports-focus': 'off',
224
+ 'jsx-a11y/label-has-associated-control': 'off',
225
+ 'jsx-a11y/media-has-caption': 'off',
226
+ 'jsx-a11y/mouse-events-have-key-events': 'off',
227
+ 'jsx-a11y/no-access-key': 'off',
228
+ 'jsx-a11y/no-autofocus': 'off',
229
+ 'jsx-a11y/no-interactive-element-to-noninteractive-role': 'off',
230
+ 'jsx-a11y/no-noninteractive-element-interactions': 'off',
231
+ 'jsx-a11y/no-noninteractive-element-to-interactive-role': 'off',
232
+ 'jsx-a11y/no-noninteractive-tabindex': 'off',
233
+ 'jsx-a11y/no-onchange': 'off',
234
+ 'jsx-a11y/no-static-element-interactions': 'off',
235
+ 'jsx-a11y/tabindex-no-positive': 'off',
236
+
237
+ // The following rules are currently disabled in the Airbnb config v18.2.1, but will be probably enabled in the future. Now we turn them on.
238
+ 'default-case-last': 'error',
239
+ 'default-param-last': 'error',
240
+ 'function-call-argument-newline': ['error', 'consistent'],
241
+ 'grouped-accessor-pairs': ['error', 'anyOrder'],
242
+ 'no-constructor-return': 'error',
243
+ 'no-dupe-else-if': 'error',
244
+ 'no-import-assign': 'error',
245
+ 'no-loss-of-precision': 'error',
246
+ 'no-promise-executor-return': 'error',
247
+ 'no-setter-return': 'error',
248
+ 'no-useless-backreference': 'error',
249
+ 'no-unreachable-loop': 'error',
250
+ 'prefer-exponentiation-operator': 'error',
251
+ 'prefer-regex-literals': 'error',
252
+ 'react/jsx-no-script-url': ['error', [
253
+ {
254
+ name: 'Link',
255
+ props: ['href', 'to'],
256
+ },
257
+ ]],
258
+ 'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }],
259
+ },
260
+ };
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ extends: './index.js',
3
+ globals: {
4
+ after: 'readonly',
5
+ afterEach: 'readonly',
6
+ before: 'readonly',
7
+ beforeEach: 'readonly',
8
+ browser: 'readonly',
9
+ casper: 'readonly',
10
+ describe: 'readonly',
11
+ expect: 'readonly',
12
+ it: 'readonly',
13
+ xit: 'readonly',
14
+ },
15
+ plugins: ['@funboxteam/eslint-plugin-no-only-tests'],
16
+ rules: {
17
+ '@funboxteam/no-only-tests/no-only': 2,
18
+ },
19
+ };
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 FunBox LLC and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/MIGRATION.md ADDED
@@ -0,0 +1,119 @@
1
+ # Migration
2
+
3
+ ## 7.4.0 → 8.0.0
4
+
5
+ Use `@necrobox/eslint-config` instead of `@funboxteam/eslint-config`.
6
+
7
+
8
+ ## 6.0.1 → 7.0.0
9
+
10
+ eslint-plugin-jsx-a11y@6.2.3 is not marked as eslint@7 compatible.
11
+ But we don't want to downgrade the Airbnb config, so you won't be able to get rid of these messages:
12
+
13
+ ```
14
+ npm WARN eslint-config-airbnb@18.2.1 requires a peer of eslint-plugin-jsx-a11y@^6.4.1 but none is installed. You must install peer dependencies yourself.
15
+ npm WARN eslint-plugin-jsx-a11y@6.2.3 requires a peer of eslint@^3 || ^4 || ^5 || ^6 but none is installed. You must install peer dependencies yourself.
16
+ ```
17
+
18
+ Even though the plugin itself should work fine, there are several possible points of failure.
19
+ The latest Airbnb config that is compatible with eslint-plugin-jsx-a11y@6.2.3 is v18.1.0.
20
+ According to the [v18.1.0...v18.2.1 diff](https://github.com/airbnb/javascript/compare/eslint-config-airbnb-v18.1.0...eslint-config-airbnb-v18.2.1):
21
+
22
+ 1. `jsx-a11y/aria-role` options have been changed from `{ ignoreNonDom: false }` to `{ ignoreNonDOM: false }`.
23
+ This is probably a typo fix.
24
+ 2. `jsx-a11y/accessible-emoji` rule has been disabled due to deprecation.
25
+ 3. `jsx-a11y/autocomplete-valid` rule has been turned off.
26
+
27
+ If you use any of these rules, please make sure they work fine with your project.
28
+
29
+ Other than that, everything should work well.
30
+
31
+
32
+ ## 5.3.2 → 6.0.0
33
+
34
+ ESLint peer dep was updated to ^7.32.0. Here are migration guides from ESLint:
35
+
36
+ - [v5 to v6](https://eslint.org/docs/user-guide/migrating-to-6.0.0)
37
+ - [v6 to v7](https://eslint.org/docs/user-guide/migrating-to-7.0.0)
38
+
39
+ Also we've changed the config itself. Below you can find full list of the changed rules.
40
+
41
+ ### Rules
42
+
43
+ #### Changed rules default values
44
+
45
+ - Disabled [react/no-multi-comp](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/CHANGELOG.md#1711--2019-07-01)
46
+ - Enabled [prefer-object-spread](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/CHANGELOG.md#1400--2019-08-09)
47
+ - Enabled [no-async-promise-executor](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/CHANGELOG.md#1400--2019-08-09)
48
+ - Enabled [no-misleading-character-class](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/CHANGELOG.md#1400--2019-08-09)
49
+ - Enabled [max-classes-per-file](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/CHANGELOG.md#1400--2019-08-09)
50
+ - Enabled [no-useless-catch](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/CHANGELOG.md#1400--2019-08-09)
51
+ - Enabled `props` option in [no-self-assign](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/CHANGELOG.md#1400--2019-08-09)
52
+ - Added `forms` option to [react/jsx-no-target-blank](https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#7250---20210827)
53
+ - Added `caseSensitiveStrict` option to [import/no-unresolved](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md#2250---2021-10-11)
54
+ - Added `commonjs` option to [import/no-useless-path-segments](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md#2190---2019-12-08)
55
+ - Used valid `maxDepth` option in [import/no-cycle](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/CHANGELOG.md#1421--2020-11-06)
56
+ - Restricted empty lines at beginning of file in [no-multiple-empty-lines](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/CHANGELOG.md#1400--2019-08-09)
57
+ - Allowed for redux dev tools in the main config in [no-underscore-dangle](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/CHANGELOG.md#1711--2019-07-01)
58
+
59
+ #### New rules
60
+
61
+ - [jsx-a11y/autocomplete-valid](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/autocomplete-valid.md) disabled by default
62
+ - [jsx-a11y/control-has-associated-label](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-associated-control.md) enabled by default as an error with the following options:
63
+ ```js
64
+ {
65
+ labelAttributes: [
66
+ 'label',
67
+ ],
68
+ controlComponents: [],
69
+ ignoreElements: [
70
+ 'audio',
71
+ 'canvas',
72
+ 'embed',
73
+ 'input',
74
+ 'textarea',
75
+ 'tr',
76
+ 'video',
77
+ ],
78
+ ignoreRoles: [
79
+ 'grid',
80
+ 'listbox',
81
+ 'menu',
82
+ 'menubar',
83
+ 'radiogroup',
84
+ 'row',
85
+ 'tablist',
86
+ 'toolbar',
87
+ 'tree',
88
+ 'treegrid',
89
+ ],
90
+ depth: 5,
91
+ }
92
+ ```
93
+ - [default-case-last](https://eslint.org/docs/rules/default-case-last) enabled manually as an error
94
+ - [default-param-last](https://eslint.org/docs/rules/default-param-last) enabled manually as an error
95
+ - [function-call-argument-newline](https://eslint.org/docs/rules/function-call-argument-newline) enabled manually as an error with the option `consistent`
96
+ - [grouped-accessor-pairs](https://eslint.org/docs/rules/grouped-accessor-pairs) enabled manually as an error with the option `getBeforeSet`
97
+ - [id-denylist](https://eslint.org/docs/rules/id-denylist) disabled by default
98
+ - [no-constructor-return](https://eslint.org/docs/rules/no-constructor-return) enabled manually as an error
99
+ - [no-dupe-else-if](https://eslint.org/docs/rules/no-dupe-else-if) enabled manually as an error
100
+ - [no-import-assign](https://eslint.org/docs/rules/no-import-assign) enabled manually as an error
101
+ - [no-loss-of-precision](https://eslint.org/docs/rules/no-loss-of-precision) enabled manually as an error
102
+ - [no-promise-executor-return](https://eslint.org/docs/rules/no-promise-executor-return) enabled as an error
103
+ - [no-restricted-exports](https://eslint.org/docs/rules/no-restricted-exports) disabled by default
104
+ - [no-setter-return](https://eslint.org/docs/rules/no-setter-return) enabled manually as an error
105
+ - [no-unreachable-loop](https://eslint.org/docs/rules/no-unreachable-loop) enabled manually as an error
106
+ - [no-useless-backreference](https://eslint.org/docs/rules/no-useless-backreference) enabled manually as an error
107
+ - [prefer-exponentiation-operator](https://eslint.org/docs/rules/prefer-exponentiation-operator) enabled manually as an error
108
+ - [prefer-regex-literals](https://eslint.org/docs/rules/prefer-regex-literals) enabled manually as an error
109
+ - [react/function-component-definition](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md) disabled by default
110
+ - [react/jsx-curly-newline](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md) enabled by default as an error with options
111
+ `{ multiline: 'consistent', singleline: 'consistent' }`
112
+ - [react/jsx-fragments](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md) enabled by default as an error with the option `syntax`
113
+ - [react/jsx-no-script-url](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md) enabled manually as an error with options `{ name: 'Link', props: ['href', 'to'] }`
114
+ - [react/jsx-no-useless-fragment](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md) enabled manually as an error (btw, v6.0.1 enabled this rule with `allowExpressions` option)
115
+ - [react/jsx-props-no-spreading](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md) disabled manually
116
+ - [react/no-adjacent-inline-elements](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md) disabled by default
117
+ - [react/prefer-read-only-props](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md) disabled by default
118
+ - [react/state-in-constructor](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md) enabled manually as an error with the option `never`
119
+ - [react/static-property-placement](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md) enabled by default as an error with the option `property assignment`
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @necrobox/eslint-config
2
+
3
+ [![npm](https://img.shields.io/npm/v/@necrobox/eslint-config.svg)](https://www.npmjs.com/package/@necrobox/eslint-config)
4
+
5
+ ESLint rules that follow our style guide.
6
+
7
+ Based on the well-known [Airbnb JS Style Guide](https://github.com/airbnb/javascript).
8
+
9
+ [По-русски](./README.ru.md)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install --save-dev @necrobox/eslint-config
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Include into a project config using flag [-c](http://eslint.org/docs/user-guide/command-line-interface#-c---config),
20
+ and pass paths for files as arguments:
21
+
22
+ ```sh
23
+ eslint -c node_modules/@necrobox/eslint-config/.eslintrc.js src/app src/sandbox
24
+ ```
25
+
26
+ To lint tests files use the separated config:
27
+
28
+ ```sh
29
+ eslint -c node_modules/@necrobox/eslint-config/.eslintrc.tests.js src/tests
30
+ ```
31
+
32
+ Also you can create your own `.eslintrc.js` and extend this config there:
33
+
34
+ ```js
35
+ module.exports = {
36
+ extends: '@necrobox',
37
+ env: {
38
+ browser: true
39
+ },
40
+ globals: {
41
+ fetcher: 'readonly',
42
+ System: 'readonly',
43
+ moment: 'readonly'
44
+ },
45
+ settings: {
46
+ 'import/resolver': {
47
+ webpack: {
48
+ config: 'config/webpack.config.dev.js',
49
+ }
50
+ }
51
+ },
52
+ }
53
+ ```
54
+
55
+ Same for tests' config:
56
+
57
+ ```
58
+ module.exports = {
59
+ extends: '@necrobox/eslint-config/tests',
60
+ globals: {
61
+ __utils__: 'readonly',
62
+ }
63
+ }
64
+ ```
65
+
66
+ Read more about `.eslintrc.js` in [ESLint docs](https://eslint.org/docs/user-guide/configuring).
package/README.ru.md ADDED
@@ -0,0 +1,66 @@
1
+ # @necrobox/eslint-config
2
+
3
+ [![npm](https://img.shields.io/npm/v/@necrobox/eslint-config.svg)](https://www.npmjs.com/package/@necrobox/eslint-config)
4
+
5
+ Пакет с правилами для линтера ESLint, соответствующие принятому в компании стайлгайду.
6
+
7
+ Основан на [конфиге от Airbnb](https://github.com/airbnb/javascript).
8
+
9
+ ## Установка
10
+
11
+ ```bash
12
+ npm install --save-dev @necrobox/eslint-config
13
+ ```
14
+
15
+ ## Использование
16
+
17
+ Подключить в конфиг рабочего проекта, используя ключ [-c](http://eslint.org/docs/user-guide/command-line-interface#-c---config),
18
+ и передать пути для поиска файлов в качестве аргументов:
19
+
20
+ ```sh
21
+ eslint -c node_modules/@necrobox/eslint-config/.eslintrc.js src/app src/sandbox
22
+ ```
23
+
24
+ Для линтинга тестов следует использовать отдельный конфиг:
25
+
26
+ ```sh
27
+ eslint -c node_modules/@necrobox/eslint-config/.eslintrc.test.only.js src/tests
28
+ ```
29
+
30
+ Также можно создать свой файл `.eslintrc.js`, и доопределить в нём этот конфиг.
31
+ Пример такого доопределения:
32
+
33
+ ```js
34
+ module.exports = {
35
+ extends: '@necrobox',
36
+ env: {
37
+ browser: true
38
+ },
39
+ globals: {
40
+ fetcher: 'readonly',
41
+ System: 'readonly',
42
+ moment: 'readonly'
43
+ },
44
+ settings: {
45
+ 'import/resolver': {
46
+ webpack: {
47
+ config: 'config/webpack.config.dev.js',
48
+ }
49
+ }
50
+ },
51
+ }
52
+ ```
53
+
54
+ Пример доопределения конфига для тестов:
55
+
56
+ ```
57
+ module.exports = {
58
+ extends: '@necrobox/eslint-config/tests',
59
+ globals: {
60
+ __utils__: 'readonly',
61
+ }
62
+ }
63
+ ```
64
+
65
+ Более подробно о том, как устроен файл `.eslintrc.js`,
66
+ и что в нём можно настраивать, можно прочитать [в документации ESLint](https://eslint.org/docs/user-guide/configuring).
package/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./.eslintrc');
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@necrobox/eslint-config",
3
+ "version": "8.0.0",
4
+ "description": "ESLint rules that follow our style guide",
5
+ "keywords": [
6
+ "eslint",
7
+ "funbox",
8
+ "config"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/necrobox/eslint-config"
13
+ },
14
+ "files": [
15
+ ".eslintrc.js",
16
+ ".eslintrc.tests.js",
17
+ "index.js",
18
+ "tests.js",
19
+ "MIGRATION.md"
20
+ ],
21
+ "author": "FunBox LLC <wanted@fun-box.ru> (https://funbox.ru)",
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "@funboxteam/eslint-plugin-no-only-tests": "5.0.0",
25
+ "eslint-config-airbnb": "19.0.4",
26
+ "eslint-import-resolver-webpack": "0.13.10",
27
+ "eslint-plugin-import": "2.32.0",
28
+ "eslint-plugin-jsx-a11y": "6.10.2",
29
+ "eslint-plugin-react": "7.37.5",
30
+ "eslint-plugin-react-hooks": "4.6.0"
31
+ },
32
+ "devDependencies": {
33
+ "eslint": "7.32.0"
34
+ },
35
+ "peerDependencies": {
36
+ "eslint": "^7.32.0 || ^8.2.0"
37
+ }
38
+ }
package/tests.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./.eslintrc.tests');