@neolution-ch/eslint-config-neolution 1.0.0 → 1.2.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/CHANGELOG.md CHANGED
@@ -7,12 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.0] - 2022-10-27
11
+
12
+ ### Added
13
+
14
+ - Added typescript to the import/resolver
15
+ - Added deprecated React types to the "ban-types" rule
16
+ - Added "complexity" rule with a maximum of 20
17
+ - Added "max-lines" rule with a maximum of 300 lines
18
+
19
+ ### Changed
20
+
21
+ - Updated "no-empty-function" rule to not allow any empty function
22
+ - Updated "quotes" rule by using the typescript version
23
+ - Updated "react/no-unstable-nested-components" rule to allow component creation inside component props
24
+
25
+ ## [1.1.0] - 2022-10-17
26
+
27
+ ### Added
28
+
29
+ - Added MIT license
30
+ - Enable react-hooks rules
31
+
10
32
  ## [1.0.0] - 2022-10-06
11
33
 
12
34
  ### Added
13
35
 
14
36
  - Initial release
15
37
 
16
- [Unreleased]: https://github.com/neolution-ch/eslint-config-neolution/compare/1.0.0...HEAD
38
+ [Unreleased]: https://github.com/neolution-ch/eslint-config-neolution/compare/1.2.0...HEAD
39
+
40
+ [1.2.0]: https://github.com/neolution-ch/eslint-config-neolution/compare/1.1.0...1.2.0
41
+
42
+ [1.1.0]: https://github.com/neolution-ch/eslint-config-neolution/compare/1.0.0...1.1.0
17
43
 
18
44
  [1.0.0]: https://github.com/neolution-ch/eslint-config-neolution/compare/5f308ef87fa2a779e56cb6af4510baf6e2deeb23...1.0.0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Neolution AG
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/README.md CHANGED
@@ -13,7 +13,7 @@ yarn add -D @neolution-ch/eslint-config-neolution
13
13
 
14
14
  Edit the `.eslintrc.js` of your project:
15
15
 
16
- ```json
16
+ ```js
17
17
  module.exports = {
18
18
  ...
19
19
  extends: ["@neolution-ch/eslint-config-neolution"],
@@ -25,7 +25,7 @@ module.exports = {
25
25
 
26
26
  For React project you might need to adjust the "@typescript-eslint/naming-convention" rule to allow PascalCase for component names.
27
27
 
28
- ```json
28
+ ```js
29
29
  module.exports = {
30
30
  ...
31
31
  rules: {
@@ -42,3 +42,7 @@ module.exports = {
42
42
  ...
43
43
  }
44
44
  ```
45
+
46
+ ## License
47
+
48
+ [MIT](LICENSE.md)
package/index.js CHANGED
@@ -5,6 +5,7 @@ module.exports = {
5
5
  "./rules/import",
6
6
  "./rules/jsdoc",
7
7
  "./rules/react",
8
+ "./rules/react-hooks",
8
9
  "./rules/next",
9
10
  ].map(require.resolve)
10
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neolution-ch/eslint-config-neolution",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "This package provides Neolution's .eslintrc as an extensible shared config.",
5
5
  "homepage": "https://github.com/neolution-ch/eslint-config-neolution",
6
6
  "main": "index.js",
package/rules/eslint.js CHANGED
@@ -4,18 +4,22 @@ module.exports = {
4
4
  ].map(require.resolve),
5
5
 
6
6
  // View link below for eslint rules documentation
7
- // https://eslint.org/docs/latest/rules/
7
+ // https://eslint.org/docs/rules/
8
8
  rules: {
9
9
  // The airbnb config enforce that class methods use "this", but requires changing how you call the method
10
- // https://eslint.org/docs/latest/rules/class-methods-use-this
10
+ // https://eslint.org/docs/rules/class-methods-use-this
11
11
  "class-methods-use-this": "off",
12
12
 
13
+ // The airbnb config disables the complexity, but we want to limit it
14
+ // https://eslint.org/docs/rules/complexity
15
+ complexity: ["error", 20],
16
+
13
17
  // The airbnb config enforces consistent return, but we got problems with some external libraries, TypeScript enforces this anyway
14
- // https://eslint.org/docs/latest/rules/consistent-return
18
+ // https://eslint.org/docs/rules/consistent-return
15
19
  "consistent-return": "off",
16
20
 
17
21
  // The airbnb config forces unix style, but somebody also works on windows
18
- // https://eslint.org/docs/latest/rules/linebreak-style
22
+ // https://eslint.org/docs/rules/linebreak-style
19
23
  "linebreak-style": "off",
20
24
 
21
25
  // The airbnb config limits to 100 ignoring some lines, instad we allow 160 but don't ignore lines
@@ -29,12 +33,20 @@ module.exports = {
29
33
  ignoreRegExpLiterals: false,
30
34
  }],
31
35
 
36
+ // The airbnb disables the max lines, but we want to limit it
37
+ // https://eslint.org/docs/rules/max-lines
38
+ "max-lines": ["error", {
39
+ max: 300,
40
+ skipBlankLines: true,
41
+ skipComments: true
42
+ }],
43
+
32
44
  // The airbnb config disallow await inside of loops, but it cannot always be avoided
33
45
  // https://eslint.org/docs/rules/no-await-in-loop
34
46
  "no-await-in-loop": "off",
35
47
 
36
48
  // The airbnb config disallow use of the continue statement, but it's ok to have it
37
- // https://eslint.org/docs/latest/rules/no-continue
49
+ // https://eslint.org/docs/rules/no-continue
38
50
  "no-continue": "off",
39
51
 
40
52
  // The airbnb config disallow use of unary operators (++ and --), but it's ok to have them
@@ -42,7 +54,7 @@ module.exports = {
42
54
  "no-plusplus": "off",
43
55
 
44
56
  // The airbnb config also restrict ForOfStatement, but we want to use it
45
- // https://eslint.org/docs/latest/rules/no-restricted-syntax
57
+ // https://eslint.org/docs/rules/no-restricted-syntax
46
58
  "no-restricted-syntax": [
47
59
  "error",
48
60
  {
@@ -59,9 +71,5 @@ module.exports = {
59
71
  message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
60
72
  },
61
73
  ],
62
-
63
- // The airbnb config forces single quote, but we prefer double quote
64
- // https://eslint.org/docs/latest/rules/quotes
65
- quotes: ["error", "double", { avoidEscape: true }],
66
74
  },
67
75
  };
package/rules/import.js CHANGED
@@ -10,8 +10,11 @@ module.exports = {
10
10
  settings: {
11
11
  "import/resolver": {
12
12
  node: {
13
- extensions: [".js", ".jsx", ".ts", ".tsx"]
14
- }
13
+ extensions: [".js", ".jsx", ".ts", ".tsx"],
14
+ },
15
+ typescript: {
16
+ alwaysTryTypes: true,
17
+ },
15
18
  },
16
19
  },
17
20
 
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ extends: [
3
+ "eslint-config-airbnb/hooks",
4
+ ].map(require.resolve),
5
+
6
+ // View link below for react-hooks rules documentation
7
+ // https://reactjs.org/docs/hooks-rules.html
8
+ rules: {
9
+ },
10
+ };
package/rules/react.js CHANGED
@@ -21,6 +21,10 @@ module.exports = {
21
21
  // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md
22
22
  "react/jsx-one-expression-per-line": "off",
23
23
 
24
+ // The airbnb config didn't allow component creation inside component props, but we want to allow it
25
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
26
+ "react/no-unstable-nested-components": ["error", { allowAsProps: true }],
27
+
24
28
  // The airbnb config forces a defaultProps definition for every prop, but we don't want it
25
29
  // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
26
30
  "react/require-default-props": "off",
@@ -16,6 +16,18 @@ module.exports = {
16
16
  // View link below for typescript rules documentation
17
17
  // https://typescript-eslint.io/rules/
18
18
  rules: {
19
+ // Disallow certain types
20
+ // https://typescript-eslint.io/rules/ban-types/
21
+ "@typescript-eslint/ban-types": ["error",{
22
+ types: {
23
+ "React.StatelessComponent": { message: "Deprecated: Do not use.", fixWith: "React.ReactElement" },
24
+ StatelessComponent: { message: "Deprecated: Do not use.", fixWith: "ReactElement" },
25
+ "React.FC": { message: "Please use ReactElement + PropsWithChildren", fixWith: "ReactElement" },
26
+ FC: { message: "Please use ReactElement + PropsWithChildren", fixWith: "ReactElement" },
27
+ },
28
+ extendDefaults: true,
29
+ }],
30
+
19
31
  // Enforce one true brace style (same as eslint-config-airbnb-base)
20
32
  // https://typescript-eslint.io/rules/brace-style
21
33
  "@typescript-eslint/brace-style": ["error", "1tbs", { allowSingleLine: true }],
@@ -108,14 +120,10 @@ module.exports = {
108
120
  format: ["PascalCase"],
109
121
  }],
110
122
 
111
- // Disallow empty functions, except for standalone funcs/arrows (same as eslint-config-airbnb-base)
123
+ // Disallow empty functions
112
124
  // https://typescript-eslint.io/rules/no-empty-function
113
125
  "@typescript-eslint/no-empty-function": ["error", {
114
- allow: [
115
- "arrowFunctions",
116
- "functions",
117
- "methods",
118
- ]
126
+ allow: [],
119
127
  }],
120
128
 
121
129
  // Disallow unnecessary parentheses (same as eslint-config-airbnb-base)
@@ -172,6 +180,11 @@ module.exports = {
172
180
  // https://typescript-eslint.io/rules/prefer-readonly-parameter-types
173
181
  "@typescript-eslint/prefer-readonly-parameter-types": "off",
174
182
 
183
+ // Enforce the consistent use of double quotes, but allow single quotes so long as the
184
+ // string contains a quote that would have to be escaped otherwise
185
+ // https://typescript-eslint.io/rules/quotes
186
+ "@typescript-eslint/quotes": ["error", "double", { avoidEscape: true }],
187
+
175
188
  // Require `await` in `async function` (note: this is a horrible rule that should never be used) (same as eslint-config-airbnb-base)
176
189
  // https://typescript-eslint.io/rules/require-await
177
190
  "@typescript-eslint/require-await": "off",