@kununu/eslint-config 2.0.1 → 2.3.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.
Files changed (3) hide show
  1. package/README.md +6 -3
  2. package/index.js +226 -156
  3. package/package.json +24 -17
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,179 @@
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
+
25
+ // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
26
+ 'react/no-direct-mutation-state': 'error', // Use .setState() always (Airbnb rule change)
27
+
28
+ // https://github.com/babel/babel/tree/main/eslint/babel-eslint-plugin#rules
29
+ '@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)
30
+
31
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/
32
+ 'import/order': ['error', { // Make import sort order an error (Airbnb rule change)
33
+ 'newlines-between': 'always',
34
+ groups: [
35
+ 'builtin', // import fs from 'fs';
36
+ 'external', // import chalk from 'chalk';
37
+ 'internal', // import foo from 'src/foo';
38
+ 'parent', // import qux from '../qux';
39
+ 'sibling', // import bar from './bar';
40
+ 'index', // import main from './';
41
+ ],
42
+ }],
43
+
44
+ 'import/no-useless-path-segments': ['error', {
45
+ 'noUselessIndex': true,
46
+ }],
47
+
48
+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md#rule-details
49
+ // allow `Link` to have `to` and not the mandatory `href`
50
+ 'jsx-a11y/anchor-is-valid': ['error', {
51
+ components: ['Link'],
52
+ specialLink: ['to'],
53
+ }],
54
+
55
+ // https://eslint.org/docs/rules/no-confusing-arrow
56
+ // turn off to prevent conflict with
57
+ // https://eslint.org/docs/rules/arrow-body-style
58
+ 'no-confusing-arrow': 'off',
59
+
60
+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
61
+ // 'label' tags need 'htmlFor' prop, but nesting is not required
62
+ 'jsx-a11y/label-has-for': ['error', {
63
+ 'required': 'id',
64
+ }],
65
+
66
+ // https://eslint.org/docs/rules/padding-line-between-statements
67
+ // enforce empty lines after variable declarations
68
+ 'padding-line-between-statements': ['error', {
69
+ 'blankLine': 'always', 'prev': ['const', 'let', 'var'], 'next': '*',
70
+ }, {
71
+ 'blankLine': 'any', 'prev': ['const', 'let', 'var'], 'next': ['const', 'let', 'var'],
72
+ }],
73
+
74
+ // https://www.npmjs.com/package/eslint-plugin-react-hooks
75
+ // enforces the rules of react-hooks (call at top level and only from functional components; checks dependencies)
76
+ 'react-hooks/rules-of-hooks': 'error',
77
+ 'react-hooks/exhaustive-deps': 'warn',
78
+
79
+ // https://eslint.org/docs/rules/no-underscore-dangle
80
+ // no underscores at either the beginning or end of an identifier
81
+ 'no-underscore-dangle': ['error', {'allow': ['__NEXT_DATA__', '__NEXT_REDUX_STORE__']}],
82
+
83
+ 'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 1 }],
84
+
85
+ // https://eslint.org/docs/rules/eol-last
86
+ // require newline at the end of files
87
+ 'eol-last': ['error', 'always'],
88
+
89
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md
90
+ // enforce defaultProps declarations alphabetical sorting
91
+ 'react/jsx-sort-default-props': ['error', {
92
+ 'ignoreCase': true
93
+ }],
94
+
95
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
96
+ // enforce props alphabetical sorting
97
+ 'react/jsx-sort-props': ['error', {
98
+ 'ignoreCase': true
99
+ }],
100
+
101
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
102
+ // enforce propTypes declarations alphabetical sorting
103
+ 'react/sort-prop-types': ['error', {
104
+ 'ignoreCase': true
105
+ }],
106
+
107
+ // https://eslint.org/docs/rules/sort-keys
108
+ // require object keys to be sorted
109
+ 'sort-keys': ['error', 'asc', {'caseSensitive': false, 'natural': false}],
110
+
111
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
112
+ // enforces where React component static properties should be positioned
113
+ 'react/static-property-placement': ['error', 'property assignment'],
114
+
115
+ // https://eslint.org/docs/rules/indent
116
+ // enforces a consistent 2 spaces indentation style
117
+ 'indent': ['error', 2, {
118
+ 'SwitchCase': 1
119
+ }],
120
+
121
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
122
+ // enforces the state initialization style to be either in a constructor or with a class property
123
+ 'react/state-in-constructor': 'off',
124
+
125
+ // https://eslint.org/docs/rules/arrow-parens
126
+ // enforces no braces where they can be omitted
127
+ 'arrow-parens': ['error', 'as-needed'],
128
+
129
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
130
+ 'import/extensions': ['error', 'ignorePackages', {
131
+ 'js': 'never',
132
+ 'jsx': 'never',
133
+ 'ts': 'never',
134
+ 'tsx': 'never',
135
+ 'scss': 'ignorePackages',
136
+ 'json': 'always'
137
+ }],
138
+
139
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
140
+ // disallow spread on html tags directly but allows it on React components
141
+ 'react/jsx-props-no-spreading': ['error', {
142
+ 'html': 'enforce',
143
+ 'custom': 'ignore',
144
+ }],
145
+
146
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
147
+ 'react/function-component-definition': 'off',
148
+ 'prefer-promise-reject-errors': 'off',
149
+ 'react-hooks/exhaustive-deps': 'off',
150
+ 'no-restricted-exports' : 'off',
151
+
152
+ 'testing-library/prefer-screen-queries': 'off',
153
+ 'testing-library/render-result-naming-convention': 'off',
154
+
155
+ 'indent': 'off',
156
+
157
+ 'prettier/prettier': [
158
+ 'error',
159
+ {
160
+ 'arrowParens': 'avoid',
161
+ 'bracketSpacing': false,
162
+ 'semi': true,
163
+ 'singleQuote': true,
164
+ 'trailingComma': 'all',
165
+ },
166
+ ],
167
+ };
168
+
1
169
  module.exports = {
2
- extends: 'airbnb', // Many strict rules for ECMAScript and React
170
+ extends: [
171
+ 'airbnb', // Many strict rules for ECMAScript and React
172
+ 'airbnb/hooks',
173
+ 'plugin:jest-dom/recommended',
174
+ 'plugin:prettier/recommended',
175
+ 'plugin:testing-library/react'
176
+ ],
3
177
 
4
178
  parser: '@babel/eslint-parser',
5
179
 
@@ -11,167 +185,63 @@ module.exports = {
11
185
  env: {
12
186
  browser: true,
13
187
  jest: true,
188
+ node: true,
189
+ es6: true,
14
190
  },
15
191
 
16
- settings: {
17
- 'import/resolver': {
18
- node: { paths: (process.env.NODE_PATH || "").split(":").filter(String) } // If ENV['NODE_PATH'] was provided we want to use it with eslint too
19
- }
20
- },
21
-
22
- rules: {
23
- 'import/no-extraneous-dependencies': ['error', {
24
- devDependencies: [
25
- '**/*.test.js',
26
- '**/*.test.jsx',
27
- '**/*.spec.js',
28
- '**/*.spec.jsx',
29
- '**/*.pact.js',
30
- '*/test-*/*.js',
31
- '*/test-*/*.jsx',
32
- ],
33
- }],
34
- 'max-len': 'off', // Sometimes longer lines are more readable (Airbnb rule change)
35
- 'no-param-reassign': ['error', {props: false}],
36
- 'no-prototype-builtins': 'off', // Objects aren't created that don't extend from Object.prototype (Airbnb rule change)
37
- 'object-curly-spacing': 'off', // Disabled in favor of @babel/object-curly-spacing in order to avoid false positives with ECMAScript modules (Airbnb rule change)
38
- 'space-before-function-paren': ['error', {
39
- anonymous: 'always', // const foo = function () {}
40
- named: 'always', // function foo () {} (Airbnb rule change)
41
- asyncArrow: 'always', // const foo = async (a) => await a
42
- }],
43
-
44
- // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
45
- 'react/no-direct-mutation-state': 'error', // Use .setState() always (Airbnb rule change)
46
-
47
- // https://github.com/babel/babel/tree/main/eslint/babel-eslint-plugin#rules
48
- '@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)
49
-
50
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/
51
- 'import/order': ['error', { // Make import sort order an error (Airbnb rule change)
52
- 'newlines-between': 'always',
53
- groups: [
54
- 'builtin', // import fs from 'fs';
55
- 'external', // import chalk from 'chalk';
56
- 'internal', // import foo from 'src/foo';
57
- 'parent', // import qux from '../qux';
58
- 'sibling', // import bar from './bar';
59
- 'index', // import main from './';
60
- ],
61
- }],
62
-
63
- 'import/no-useless-path-segments': ['error', {
64
- 'noUselessIndex': true,
65
- }],
66
-
67
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md#rule-details
68
- // allow `Link` to have `to` and not the mandatory `href`
69
- 'jsx-a11y/anchor-is-valid': ['error', {
70
- components: ['Link'],
71
- specialLink: ['to'],
72
- }],
73
-
74
- // https://eslint.org/docs/rules/operator-linebreak
75
- 'operator-linebreak': ['error', 'after'],
76
-
77
- // https://eslint.org/docs/rules/no-confusing-arrow
78
- // turn off to prevent conflict with
79
- // https://eslint.org/docs/rules/arrow-body-style
80
- 'no-confusing-arrow': 'off',
81
-
82
- // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
83
- // 'label' tags need 'htmlFor' prop, but nesting is not required
84
- 'jsx-a11y/label-has-for': ['error', {
85
- 'required': 'id',
86
- }],
87
-
88
- // https://eslint.org/docs/rules/padding-line-between-statements
89
- // enforce empty lines after variable declarations
90
- 'padding-line-between-statements': ['error', {
91
- 'blankLine': 'always', 'prev': ['const', 'let', 'var'], 'next': '*',
92
- }, {
93
- 'blankLine': 'any', 'prev': ['const', 'let', 'var'], 'next': ['const', 'let', 'var'],
94
- }],
95
-
96
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
97
- // jsx props should be on separate lines each
98
- 'react/jsx-max-props-per-line': ['error', {'maximum': 1}],
99
-
100
- // https://www.npmjs.com/package/eslint-plugin-react-hooks
101
- // enforces the rules of react-hooks (call at top level and only from functional components; checks dependencies)
102
- 'react-hooks/rules-of-hooks': 'error',
103
- 'react-hooks/exhaustive-deps': 'warn',
104
-
105
- // https://eslint.org/docs/rules/no-underscore-dangle
106
- // no underscores at either the beginning or end of an identifier
107
- 'no-underscore-dangle': ['error', {'allow': ['__NEXT_DATA__', '__NEXT_REDUX_STORE__']}],
108
-
109
- 'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 1 }],
110
-
111
- // https://eslint.org/docs/rules/eol-last
112
- // require newline at the end of files
113
- 'eol-last': ['error', 'always'],
114
-
115
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md
116
- // enforce defaultProps declarations alphabetical sorting
117
- 'react/jsx-sort-default-props': ['error', {
118
- 'ignoreCase': true
119
- }],
120
-
121
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
122
- // enforce props alphabetical sorting
123
- 'react/jsx-sort-props': ['error', {
124
- 'ignoreCase': true
125
- }],
126
-
127
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
128
- // enforce propTypes declarations alphabetical sorting
129
- 'react/sort-prop-types': ['error', {
130
- 'ignoreCase': true
131
- }],
132
-
133
- // https://eslint.org/docs/rules/sort-keys
134
- // require object keys to be sorted
135
- 'sort-keys': ['error', 'asc', {'caseSensitive': false, 'natural': false}],
136
-
137
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
138
- // enforces where React component static properties should be positioned
139
- 'react/static-property-placement': ['error', 'property assignment'],
140
-
141
- // https://eslint.org/docs/rules/indent
142
- // enforces a consistent 2 spaces indentation style
143
- 'indent': ['error', 2, {
144
- 'SwitchCase': 1
145
- }],
146
-
147
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
148
- // enforces the state initialization style to be either in a constructor or with a class property
149
- 'react/state-in-constructor': 'off',
150
-
151
- // https://eslint.org/docs/rules/arrow-parens
152
- // enforces no braces where they can be omitted
153
- 'arrow-parens': ['error', 'as-needed'],
154
-
155
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
156
- 'import/extensions': ['error', 'ignorePackages', {
157
- 'js': 'never',
158
- 'jsx': 'never',
159
- 'scss': 'ignorePackages'
160
- }],
161
-
162
- // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
163
- // disallow spread on html tags directly but allows it on React components
164
- 'react/jsx-props-no-spreading': ['error', {
165
- 'html': 'enforce',
166
- 'custom': 'ignore',
167
- }]
168
- },
192
+ rules: baseRules,
169
193
 
170
194
  overrides: [{
171
- files: ['*.spec.js', '*.test.js', '*.pact.js', '*spec.jsx'],
195
+ files: [
196
+ '**/*.ts',
197
+ '**/*.tsx',
198
+ ],
199
+ extends: [
200
+ 'airbnb', // Many strict rules for ECMAScript and React
201
+ 'airbnb-typescript',
202
+ 'airbnb/hooks',
203
+ 'plugin:jest-dom/recommended',
204
+ 'plugin:prettier/recommended',
205
+ 'plugin:testing-library/react',
206
+ ],
207
+ parser: '@typescript-eslint/parser',
208
+ plugins: [
209
+ 'react-hooks',
210
+ '@typescript-eslint',
211
+ ],
212
+ rules: {
213
+ ...baseRules,
214
+ '@typescript-eslint/indent': 'off',
215
+ 'object-curly-spacing': 'off',
216
+ '@typescript-eslint/object-curly-spacing': ['error', 'never'],
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'],
172
233
  rules: {
173
234
  'global-require': 'off',
174
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'
175
245
  }
176
- }]
246
+ }],
177
247
  };
package/package.json CHANGED
@@ -1,35 +1,42 @@
1
1
  {
2
2
  "name": "@kununu/eslint-config",
3
- "version": "2.0.1",
3
+ "version": "2.3.0",
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
- "repository": "kununu/javascript",
6
+ "repository": "kununu/eslint-config",
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",
30
+ "eslint-config-prettier": "8.3.0",
29
31
  "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"
32
+ "eslint-plugin-import": "2.25.3",
33
+ "eslint-plugin-jest-dom": "3.9.2",
34
+ "eslint-plugin-jsx-a11y": "6.5.1",
35
+ "eslint-plugin-prettier": "4.0.0",
36
+ "eslint-plugin-react": "7.27.1",
37
+ "eslint-plugin-react-hooks": "4.3.0",
38
+ "eslint-plugin-testing-library": "5.0.1",
39
+ "prettier": "2.5.1",
40
+ "typescript": "4.5.2"
34
41
  }
35
42
  }