@kununu/eslint-config 2.0.0 → 2.2.1

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.
Files changed (3) hide show
  1. package/README.md +6 -3
  2. package/index.js +226 -150
  3. package/package.json +20 -16
package/README.md CHANGED
@@ -7,8 +7,9 @@ This package contains ESLint rules for consistent JS and JSX code across kununu'
7
7
  ## 📦 Installation
8
8
 
9
9
  Add @kununu/eslint-config npm package as dev dependency to your project:
10
+
10
11
  ```console
11
- npx install --save-dev @kununu/eslint-config
12
+ npm install --save-dev @kununu/eslint-config
12
13
  ```
13
14
 
14
15
  ## 💻 Usage
@@ -29,8 +30,10 @@ At kununu, [@kununu/eslint-config](https://www.npmjs.com/package/@kununu/eslint-
29
30
 
30
31
  There's what we use and recommend:
31
32
 
32
- **Visual Code Studio**
33
+ ### Visual Code Studio
34
+
33
35
  - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
34
36
 
35
- **Atom**
37
+ ### Atom
38
+
36
39
  - [linter-eslint](https://atom.io/packages/linter-eslint)
package/index.js CHANGED
@@ -1,5 +1,177 @@
1
+ // we need to have the baseRules to have the same on the typescript override
2
+ // because it has extends the eslint does not take into consideration the ones from the base
3
+ const baseRules = {
4
+ 'import/no-extraneous-dependencies': ['error', {
5
+ devDependencies: [
6
+ '**/*.spec.js',
7
+ '**/*.spec.jsx',
8
+ '**/*.test.js',
9
+ '**/*.test.jsx',
10
+ '**/stories.jsx',
11
+ '*/test-*/*.js',
12
+ '*/test-*/*.jsx',
13
+ 'config/**/*.js',
14
+ 'jest.setup.js',
15
+ 'jestsetup.js',
16
+ 'mockBff/*',
17
+ 'next.config.js',
18
+ ],
19
+ }],
20
+ 'max-len': 'off', // Sometimes longer lines are more readable (Airbnb rule change)
21
+ 'no-param-reassign': ['error', {props: false}],
22
+ 'no-prototype-builtins': 'off', // Objects aren't created that don't extend from Object.prototype (Airbnb rule change)
23
+ 'object-curly-spacing': 'off', // Disabled in favor of @babel/object-curly-spacing in order to avoid false positives with ECMAScript modules (Airbnb rule change)
24
+ 'space-before-function-paren': ['error', {
25
+ anonymous: 'always', // const foo = function () {}
26
+ named: 'always', // function foo () {} (Airbnb rule change)
27
+ asyncArrow: 'always', // const foo = async (a) => await a
28
+ }],
29
+
30
+ // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
31
+ 'react/no-direct-mutation-state': 'error', // Use .setState() always (Airbnb rule change)
32
+
33
+ // https://github.com/babel/babel/tree/main/eslint/babel-eslint-plugin#rules
34
+ '@babel/object-curly-spacing': 'error', // No spaces in single-line objects to make nested objects like {a: {b: 'c'}} look more sane (Airbnb rule change)
35
+
36
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/
37
+ 'import/order': ['error', { // Make import sort order an error (Airbnb rule change)
38
+ 'newlines-between': 'always',
39
+ groups: [
40
+ 'builtin', // import fs from 'fs';
41
+ 'external', // import chalk from 'chalk';
42
+ 'internal', // import foo from 'src/foo';
43
+ 'parent', // import qux from '../qux';
44
+ 'sibling', // import bar from './bar';
45
+ 'index', // import main from './';
46
+ ],
47
+ }],
48
+
49
+ 'import/no-useless-path-segments': ['error', {
50
+ 'noUselessIndex': true,
51
+ }],
52
+
53
+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md#rule-details
54
+ // allow `Link` to have `to` and not the mandatory `href`
55
+ 'jsx-a11y/anchor-is-valid': ['error', {
56
+ components: ['Link'],
57
+ specialLink: ['to'],
58
+ }],
59
+
60
+ // https://eslint.org/docs/rules/operator-linebreak
61
+ 'operator-linebreak': ['error', 'after'],
62
+
63
+ // https://eslint.org/docs/rules/no-confusing-arrow
64
+ // turn off to prevent conflict with
65
+ // https://eslint.org/docs/rules/arrow-body-style
66
+ 'no-confusing-arrow': 'off',
67
+
68
+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
69
+ // 'label' tags need 'htmlFor' prop, but nesting is not required
70
+ 'jsx-a11y/label-has-for': ['error', {
71
+ 'required': 'id',
72
+ }],
73
+
74
+ // https://eslint.org/docs/rules/padding-line-between-statements
75
+ // enforce empty lines after variable declarations
76
+ 'padding-line-between-statements': ['error', {
77
+ 'blankLine': 'always', 'prev': ['const', 'let', 'var'], 'next': '*',
78
+ }, {
79
+ 'blankLine': 'any', 'prev': ['const', 'let', 'var'], 'next': ['const', 'let', 'var'],
80
+ }],
81
+
82
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
83
+ // jsx props should be on separate lines each
84
+ 'react/jsx-max-props-per-line': ['error', {'maximum': 1}],
85
+
86
+ // https://www.npmjs.com/package/eslint-plugin-react-hooks
87
+ // enforces the rules of react-hooks (call at top level and only from functional components; checks dependencies)
88
+ 'react-hooks/rules-of-hooks': 'error',
89
+ 'react-hooks/exhaustive-deps': 'warn',
90
+
91
+ // https://eslint.org/docs/rules/no-underscore-dangle
92
+ // no underscores at either the beginning or end of an identifier
93
+ 'no-underscore-dangle': ['error', {'allow': ['__NEXT_DATA__', '__NEXT_REDUX_STORE__']}],
94
+
95
+ 'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 1 }],
96
+
97
+ // https://eslint.org/docs/rules/eol-last
98
+ // require newline at the end of files
99
+ 'eol-last': ['error', 'always'],
100
+
101
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md
102
+ // enforce defaultProps declarations alphabetical sorting
103
+ 'react/jsx-sort-default-props': ['error', {
104
+ 'ignoreCase': true
105
+ }],
106
+
107
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
108
+ // enforce props alphabetical sorting
109
+ 'react/jsx-sort-props': ['error', {
110
+ 'ignoreCase': true
111
+ }],
112
+
113
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
114
+ // enforce propTypes declarations alphabetical sorting
115
+ 'react/sort-prop-types': ['error', {
116
+ 'ignoreCase': true
117
+ }],
118
+
119
+ // https://eslint.org/docs/rules/sort-keys
120
+ // require object keys to be sorted
121
+ 'sort-keys': ['error', 'asc', {'caseSensitive': false, 'natural': false}],
122
+
123
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
124
+ // enforces where React component static properties should be positioned
125
+ 'react/static-property-placement': ['error', 'property assignment'],
126
+
127
+ // https://eslint.org/docs/rules/indent
128
+ // enforces a consistent 2 spaces indentation style
129
+ 'indent': ['error', 2, {
130
+ 'SwitchCase': 1
131
+ }],
132
+
133
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
134
+ // enforces the state initialization style to be either in a constructor or with a class property
135
+ 'react/state-in-constructor': 'off',
136
+
137
+ // https://eslint.org/docs/rules/arrow-parens
138
+ // enforces no braces where they can be omitted
139
+ 'arrow-parens': ['error', 'as-needed'],
140
+
141
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
142
+ 'import/extensions': ['error', 'ignorePackages', {
143
+ 'js': 'never',
144
+ 'jsx': 'never',
145
+ 'ts': 'never',
146
+ 'tsx': 'never',
147
+ 'scss': 'ignorePackages',
148
+ 'json': 'always'
149
+ }],
150
+
151
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
152
+ // disallow spread on html tags directly but allows it on React components
153
+ 'react/jsx-props-no-spreading': ['error', {
154
+ 'html': 'enforce',
155
+ 'custom': 'ignore',
156
+ }],
157
+
158
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
159
+ 'react/function-component-definition': 'off',
160
+ 'prefer-promise-reject-errors': 'off',
161
+ 'react-hooks/exhaustive-deps': 'off',
162
+ 'no-restricted-exports' : 'off',
163
+
164
+ 'testing-library/prefer-screen-queries': 'off',
165
+ 'testing-library/render-result-naming-convention': 'off',
166
+ };
167
+
1
168
  module.exports = {
2
- extends: 'airbnb', // Many strict rules for ECMAScript and React
169
+ extends: [
170
+ 'airbnb', // Many strict rules for ECMAScript and React
171
+ 'airbnb/hooks',
172
+ 'plugin:jest-dom/recommended',
173
+ 'plugin:testing-library/react'
174
+ ],
3
175
 
4
176
  parser: '@babel/eslint-parser',
5
177
 
@@ -11,161 +183,65 @@ module.exports = {
11
183
  env: {
12
184
  browser: true,
13
185
  jest: true,
186
+ node: true,
187
+ es6: true,
14
188
  },
15
189
 
16
- rules: {
17
- 'import/no-extraneous-dependencies': ['error', {
18
- devDependencies: [
19
- '**/*.test.js',
20
- '**/*.test.jsx',
21
- '**/*.spec.js',
22
- '**/*.spec.jsx',
23
- '**/*.pact.js',
24
- '*/test-*/*.js',
25
- '*/test-*/*.jsx',
26
- ],
27
- }],
28
- 'max-len': 'off', // Sometimes longer lines are more readable (Airbnb rule change)
29
- 'no-param-reassign': ['error', {props: false}],
30
- 'no-prototype-builtins': 'off', // Objects aren't created that don't extend from Object.prototype (Airbnb rule change)
31
- 'object-curly-spacing': 'off', // Disabled in favor of @babel/object-curly-spacing in order to avoid false positives with ECMAScript modules (Airbnb rule change)
32
- 'space-before-function-paren': ['error', {
33
- anonymous: 'always', // const foo = function () {}
34
- named: 'always', // function foo () {} (Airbnb rule change)
35
- asyncArrow: 'always', // const foo = async (a) => await a
36
- }],
37
-
38
- // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
39
- 'react/no-direct-mutation-state': 'error', // Use .setState() always (Airbnb rule change)
40
-
41
- // https://github.com/babel/babel/tree/main/eslint/babel-eslint-plugin#rules
42
- '@babel/object-curly-spacing': 'error', // No spaces in single-line objects to make nested objects like {a: {b: 'c'}} look more sane (Airbnb rule change)
43
-
44
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/
45
- 'import/order': ['error', { // Make import sort order an error (Airbnb rule change)
46
- 'newlines-between': 'always',
47
- groups: [
48
- 'builtin', // import fs from 'fs';
49
- 'external', // import chalk from 'chalk';
50
- 'internal', // import foo from 'src/foo';
51
- 'parent', // import qux from '../qux';
52
- 'sibling', // import bar from './bar';
53
- 'index', // import main from './';
54
- ],
55
- }],
56
-
57
- 'import/no-useless-path-segments': ['error', {
58
- 'noUselessIndex': true,
59
- }],
60
-
61
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md#rule-details
62
- // allow `Link` to have `to` and not the mandatory `href`
63
- 'jsx-a11y/anchor-is-valid': ['error', {
64
- components: ['Link'],
65
- specialLink: ['to'],
66
- }],
67
-
68
- // https://eslint.org/docs/rules/operator-linebreak
69
- 'operator-linebreak': ['error', 'after'],
70
-
71
- // https://eslint.org/docs/rules/no-confusing-arrow
72
- // turn off to prevent conflict with
73
- // https://eslint.org/docs/rules/arrow-body-style
74
- 'no-confusing-arrow': 'off',
75
-
76
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
77
- // 'label' tags need 'htmlFor' prop, but nesting is not required
78
- 'jsx-a11y/label-has-for': ['error', {
79
- 'required': 'id',
80
- }],
81
-
82
- // https://eslint.org/docs/rules/padding-line-between-statements
83
- // enforce empty lines after variable declarations
84
- 'padding-line-between-statements': ['error', {
85
- 'blankLine': 'always', 'prev': ['const', 'let', 'var'], 'next': '*',
86
- }, {
87
- 'blankLine': 'any', 'prev': ['const', 'let', 'var'], 'next': ['const', 'let', 'var'],
88
- }],
89
-
90
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
91
- // jsx props should be on separate lines each
92
- 'react/jsx-max-props-per-line': ['error', {'maximum': 1}],
93
-
94
- // https://www.npmjs.com/package/eslint-plugin-react-hooks
95
- // enforces the rules of react-hooks (call at top level and only from functional components; checks dependencies)
96
- 'react-hooks/rules-of-hooks': 'error',
97
- 'react-hooks/exhaustive-deps': 'warn',
98
-
99
- // https://eslint.org/docs/rules/no-underscore-dangle
100
- // no underscores at either the beginning or end of an identifier
101
- 'no-underscore-dangle': ['error', {'allow': ['__NEXT_DATA__', '__NEXT_REDUX_STORE__']}],
102
-
103
- 'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 1 }],
104
-
105
- // https://eslint.org/docs/rules/eol-last
106
- // require newline at the end of files
107
- 'eol-last': ['error', 'always'],
108
-
109
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md
110
- // enforce defaultProps declarations alphabetical sorting
111
- 'react/jsx-sort-default-props': ['error', {
112
- 'ignoreCase': true
113
- }],
114
-
115
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
116
- // enforce props alphabetical sorting
117
- 'react/jsx-sort-props': ['error', {
118
- 'ignoreCase': true
119
- }],
120
-
121
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
122
- // enforce propTypes declarations alphabetical sorting
123
- 'react/sort-prop-types': ['error', {
124
- 'ignoreCase': true
125
- }],
126
-
127
- // https://eslint.org/docs/rules/sort-keys
128
- // require object keys to be sorted
129
- 'sort-keys': ['error', 'asc', {'caseSensitive': false, 'natural': false}],
130
-
131
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
132
- // enforces where React component static properties should be positioned
133
- 'react/static-property-placement': ['error', 'property assignment'],
134
-
135
- // https://eslint.org/docs/rules/indent
136
- // enforces a consistent 2 spaces indentation style
137
- 'indent': ['error', 2, {
138
- 'SwitchCase': 1
139
- }],
140
-
141
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
142
- // enforces the state initialization style to be either in a constructor or with a class property
143
- 'react/state-in-constructor': 'off',
144
-
145
- // https://eslint.org/docs/rules/arrow-parens
146
- // enforces no braces where they can be omitted
147
- 'arrow-parens': ['error', 'as-needed'],
148
-
149
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
150
- 'import/extensions': ['error', 'ignorePackages', {
151
- 'js': 'never',
152
- 'jsx': 'never',
153
- 'scss': 'ignorePackages'
154
- }],
155
-
156
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
157
- // disallow spread on html tags directly but allows it on React components
158
- 'react/jsx-props-no-spreading': ['error', {
159
- 'html': 'enforce',
160
- 'custom': 'ignore',
161
- }]
162
- },
190
+ rules: baseRules,
163
191
 
164
192
  overrides: [{
165
- files: ['*.spec.js', '*.test.js', '*.pact.js', '*spec.jsx'],
193
+ files: [
194
+ '**/*.ts',
195
+ '**/*.tsx',
196
+ ],
197
+ extends: [
198
+ 'airbnb', // Many strict rules for ECMAScript and React
199
+ 'airbnb-typescript',
200
+ 'airbnb/hooks',
201
+ 'plugin:jest-dom/recommended',
202
+ 'plugin:testing-library/react',
203
+ ],
204
+ parser: '@typescript-eslint/parser',
205
+ plugins: [
206
+ 'react-hooks',
207
+ '@typescript-eslint',
208
+ ],
209
+ rules: {
210
+ ...baseRules,
211
+ 'indent': 'off',
212
+ '@typescript-eslint/indent': ['error', 2],
213
+ 'object-curly-spacing': 'off',
214
+ '@typescript-eslint/object-curly-spacing': ['error', 'never'],
215
+ 'space-before-function-paren': 'off',
216
+ '@typescript-eslint/space-before-function-paren': ['error', 'always'],
217
+ '@typescript-eslint/no-var-requires': 'off',
218
+ '@typescript-eslint/no-explicit-any': 'off',
219
+ 'no-use-before-define': 'off',
220
+ '@typescript-eslint/no-use-before-define': ['error'],
221
+ 'react/require-default-props': 'off',
222
+ 'react/prop-types': 'off',
223
+ 'import/no-extraneous-dependencies': ['error', {
224
+ devDependencies: [
225
+ '**/*.spec.ts',
226
+ '**/*.spec.tsx',
227
+ '**/stories.tsx',
228
+ ],
229
+ }],
230
+ }
231
+ }, {
232
+ files: ['*.spec.js', '*.spec.ts', '*.spec.jsx', '*.spec.tsx'],
166
233
  rules: {
167
234
  'global-require': 'off',
168
235
  'jsx-a11y/anchor-is-valid': 'off',
236
+ },
237
+ },
238
+ {
239
+ files: [
240
+ '**/reducers/**/*.js',
241
+ '**/reducers/**/*.ts'
242
+ ],
243
+ rules: {
244
+ 'default-param-last' : 'off'
169
245
  }
170
- }]
246
+ }],
171
247
  };
package/package.json CHANGED
@@ -1,35 +1,39 @@
1
1
  {
2
2
  "name": "@kununu/eslint-config",
3
- "version": "2.0.0",
3
+ "version": "2.2.1",
4
4
  "description": "kununu's ESLint config",
5
5
  "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
6
  "repository": "kununu/javascript",
10
7
  "keywords": [
11
8
  "eslint",
12
9
  "eslintconfig",
13
10
  "config",
14
11
  "kununu",
15
- "javascript"
12
+ "javascript",
13
+ "typescript"
16
14
  ],
17
15
  "author": "kununu",
18
16
  "license": "MIT",
19
17
  "bugs": {
20
- "url": "https://github.com/kununu/javascript/issues"
18
+ "url": "https://github.com/kununu/eslint-config/issues"
21
19
  },
22
- "homepage": "https://github.com/kununu/javascript#readme",
20
+ "homepage": "https://github.com/kununu/eslint-config#readme",
23
21
  "dependencies": {
24
- "@babel/core": "7.13.8",
25
- "@babel/eslint-parser": "7.13.8",
26
- "@babel/eslint-plugin": "7.13.0",
27
- "eslint": "7.21.0",
28
- "eslint-config-airbnb": "18.2.1",
22
+ "@babel/core": "7.16.0",
23
+ "@babel/eslint-parser": "7.16.3",
24
+ "@babel/eslint-plugin": "7.14.5",
25
+ "@typescript-eslint/eslint-plugin": "5.5.0",
26
+ "@typescript-eslint/parser": "5.5.0",
27
+ "eslint": "8.4.0",
28
+ "eslint-config-airbnb": "19.0.2",
29
+ "eslint-config-airbnb-typescript": "16.1.0",
29
30
  "eslint-import-resolver-alias": "1.1.2",
30
- "eslint-plugin-import": "2.22.1",
31
- "eslint-plugin-jsx-a11y": "6.4.1",
32
- "eslint-plugin-react": "7.22.0",
33
- "eslint-plugin-react-hooks": "4.2.0"
31
+ "eslint-plugin-import": "2.25.3",
32
+ "eslint-plugin-jest-dom": "3.9.2",
33
+ "eslint-plugin-jsx-a11y": "6.5.1",
34
+ "eslint-plugin-react": "7.27.1",
35
+ "eslint-plugin-react-hooks": "4.3.0",
36
+ "eslint-plugin-testing-library": "5.0.1",
37
+ "typescript": "4.5.2"
34
38
  }
35
39
  }