eslint-config-fabulator 3.2.0 → 4.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/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## v4.0.0 (2023-12-16)
5
+ ### Fixed
6
+ - [3b2fa3f](https://github.com/fabulator/eslint-config-fabulator/commit/3b2fa3fe3b1f694d677c786dcec30b7369833a00) formatting
7
+
8
+ ### Changed
9
+ - [84e0c6f](https://github.com/fabulator/eslint-config-fabulator/commit/84e0c6fac7572bffda067eaae1e60d9ed32ce20d) Use recommended settings for plugins BREAKING
10
+
4
11
  ## v3.2.0 (2023-12-16)
5
12
  ### Changed
6
13
  - [d54b311](https://github.com/fabulator/eslint-config-fabulator/commit/d54b311c2537244edd9b81d18193fda4ea1b2451) Bump dependencies
package/index.js CHANGED
@@ -1,116 +1,58 @@
1
- const jestConfig = require('./jest');
2
- const reactConfig = require('./react');
1
+ // eslint-disable-next-line canonical/filename-no-index
2
+ const jestConfig = require("./jest");
3
+ const reactConfig = require("./react");
3
4
 
4
- /* eslint-disable max-len */
5
5
  module.exports = {
6
- extends: ['airbnb', 'plugin:promise/recommended', 'plugin:jsx-a11y/recommended', 'plugin:prettier/recommended'],
7
- settings: {
8
- 'import/resolver': {
9
- node: {
10
- moduleDirectory: ['node_modules', 'src'],
11
- extensions: ['.js', '.ts', '.tsx', '.d.ts'],
12
- },
13
- },
6
+ extends: [
7
+ "eslint:recommended",
8
+ "plugin:sonarjs/recommended",
9
+ "plugin:canonical/recommended",
10
+ "plugin:import/recommended",
11
+ "plugin:array-func/recommended",
12
+ "plugin:prettier/recommended",
13
+ ],
14
+ overrides: [
15
+ {
16
+ files: ["*.test.*"],
17
+ ...jestConfig,
14
18
  },
15
- rules: {
16
- 'indent': 0, // checked by prettier
17
- 'max-len': 0, // checked by prettier
18
- 'no-console': 'warn',
19
- 'complexity': [1, 6],
20
- 'curly': [2, 'all'],
21
- 'max-depth': [2, 5],
22
- 'max-lines': [1],
23
- 'max-params': [2, 5],
24
- 'max-nested-callbacks': [2, 5],
25
- 'max-statements': [1, 25],
26
- 'max-statements-per-line': [2, { max: 2 }],
27
- 'arrow-body-style': 0, // return statement sometimes needs to be surrounded by {}
28
- 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], // allow ++ syntax for for each cycle
29
- 'class-methods-use-this': 0, // Do not require this in class methods
30
- 'no-empty-function': 0, // you need this to implement some interfaces
31
- 'no-underscore-dangle': 0, // _ can be user for private methods
32
- 'no-useless-constructor': 0, // sometimes its handy
33
- 'no-param-reassign': 0, // for decorators it's handy
34
- 'promise/avoid-new': 0,
35
- 'promise/always-return': 1,
36
- 'promise/no-return-wrap': 1,
37
- 'promise/param-names': 1,
38
- 'promise/catch-or-return': 2,
39
- 'promise/no-promise-in-callback': 1,
40
- 'promise/no-callback-in-promise': 1,
41
- 'promise/prefer-await-to-callbacks': 2,
42
- 'promise/prefer-await-to-then': 2,
43
- 'filenames/match-exported': [2, null, '\\.config.js$'],
44
- 'array-func/no-unnecessary-this-arg': 2,
45
- 'array-func/prefer-array-from': 0, // I don't like it
46
- 'array-func/avoid-reverse': 2,
47
- 'import/prefer-default-export': 0, // In some cases it is not need
48
- 'import/extensions': [2, { ts: 'never', tsx: 'never' }],
49
- 'import/no-dynamic-require': 0, // we need dynamic import of chunks...
50
- 'import/no-extraneous-dependencies': [2, { devDependencies: ['**/*.test.*', '**/*.config.js', '**/*.config.*'] }],
51
- 'jsx-a11y/anchor-is-valid': 0, // rule does not exist
52
- 'prettier/prettier': ['error', { printWidth: 140, tabWidth: 4, singleQuote: true, quoteProps: 'consistent', trailingComma: 'all' }],
53
- // TODO: :( extending airbnb with react
54
- 'react/function-component-definition': 0,
55
- 'array-func/from-map': 0,
56
- 'no-irregular-whitespace': 0,
57
- 'func-names': 0,
19
+ {
20
+ files: ["*.*sx"],
21
+ ...reactConfig,
58
22
  },
59
- overrides: [
60
- {
61
- files: ['*.ts', '*.tsx'],
62
- parser: '@typescript-eslint/parser',
63
- extends: ['plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended-requiring-type-checking'],
64
- rules: {
65
- 'typescript-sort-keys/interface': 2,
66
- 'typescript-sort-keys/string-enum': 2,
67
- '@typescript-eslint/explicit-module-boundary-types': 0,
68
- 'consistent-return': 0, // types check by typescript
69
- 'camelcase': 0, // using @typescript-eslint/camelcase
70
- 'no-unused-expressions': 0, // conflict with typescript plugin
71
- 'no-undef': 0, // conflict with typescript plugin
72
- 'no-restricted-globals': 0, // conflict with typescript plugin
73
- 'global-require': 0, // conflict with typescript plugin
74
- 'no-unused-vars': 0, // conflict with typescript plugin
75
- 'no-dupe-class-members': 0, // dont work for typescript
76
- '@typescript-eslint/explicit-function-return-type': 0,
77
- '@typescript-eslint/no-namespace': 0,
78
- '@typescript-eslint/no-parameter-properties': 0,
79
- '@typescript-eslint/ban-ts-ignore': 0,
80
- 'no-shadow': 0, // conflict with typescript
81
- },
82
- },
83
- {
84
- files: ['*.config.*'],
85
- rules: {
86
- 'filenames/match-exported': 0,
87
- },
88
- },
89
- {
90
- files: ['*.test.*'],
91
- ...jestConfig,
92
- },
93
- {
94
- files: ['*.jsx', '*.tsx'],
95
- ...reactConfig,
96
- },
97
- {
98
- files: ['*.json'],
99
- rules: {
100
- 'json/sort-package-json': [2, 'standard'],
101
- },
102
- },
103
- ],
104
- parserOptions: {
105
- sourceType: 'module',
106
- ecmaFeatures: {
107
- jsx: true,
108
- impliedStrict: true,
109
- },
23
+ {
24
+ extends: ["plugin:react-hooks/recommended"],
25
+ files: ["use*.*sx", "use*.js", "use*.ts"],
26
+ rules: {
27
+ "react-hooks/exhaustive-deps": "error",
28
+ "react-hooks/rules-of-hooks": "error",
29
+ },
110
30
  },
111
- env: {
112
- es6: true,
113
- browser: true,
31
+ {
32
+ extends: [
33
+ "plugin:@typescript-eslint/strict-type-checked",
34
+ "plugin:typescript-sort-keys/recommended",
35
+ "plugin:import/typescript",
36
+ "plugin:prettier/recommended",
37
+ ],
38
+ files: ["*.tsx", "*.ts"],
39
+ parser: "@typescript-eslint/parser",
114
40
  },
115
- plugins: ['import', 'promise', 'filenames', 'array-func', '@typescript-eslint', 'typescript-sort-keys', 'prettier', 'json-format'],
41
+ {
42
+ files: ["*.json"],
43
+ plugins: ["json-format"],
44
+ rules: {
45
+ "json/sort-package-json": [2, "standard"],
46
+ },
47
+ },
48
+ ],
49
+ parserOptions: {
50
+ ecmaVersion: "latest",
51
+ },
52
+ plugins: ["filenames"],
53
+ reportUnusedDisableDirectives: true,
54
+ rules: {
55
+ "canonical/filename-no-index": "error",
56
+ "filenames/match-exported": [2, null, "\\.config.js$"],
57
+ },
116
58
  };
package/jest.js CHANGED
@@ -1,13 +1,16 @@
1
1
  module.exports = {
2
- extends: ['plugin:jest/recommended'],
3
- plugins: ['jest'],
4
- env: {
5
- jest: true,
6
- },
7
- rules: {
8
- 'compat/compat': 0, // do not check for browser support
9
- 'promise/no-callback-in-promise': 0,
10
- 'sonarjs/no-duplicate-string': 0, // no need for testing env
11
- 'promise/catch-or-return': 0, // no need for testing env
12
- },
2
+ env: {
3
+ jest: true,
4
+ },
5
+ extends: ["plugin:jest/recommended"],
6
+ plugins: ["jest"],
7
+ rules: {
8
+ "compat/compat": 0,
9
+ // no need for testing env
10
+ "promise/catch-or-return": 0,
11
+
12
+ // do not check for browser support
13
+ "promise/no-callback-in-promise": 0,
14
+ "sonarjs/no-duplicate-string": 0, // no need for testing env
15
+ },
13
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-fabulator",
3
- "version": "3.2.0",
3
+ "version": "4.0.0",
4
4
  "description": "Shared ESLint config for fabulator projects",
5
5
  "keywords": [
6
6
  "eslint",
@@ -19,26 +19,26 @@
19
19
  "author": "Michal Ozogán <michal@ozogan.eu>",
20
20
  "main": "index.js",
21
21
  "scripts": {
22
- "lint": "eslint ./ --ext .js --ext .json --config index.js",
22
+ "lint": "eslint ./ --ext .js --ext .json --config index.js --env node",
23
23
  "lint:fix": "npm run lint -- --fix",
24
24
  "release": "semantic-release",
25
25
  "test": "node node_modules/jest/bin/jest.js",
26
26
  "test-and-lint": "npm run test && npm run lint"
27
27
  },
28
28
  "dependencies": {
29
+ "@babel/eslint-parser": "^7.23.3",
29
30
  "@typescript-eslint/eslint-plugin": "^6.14.0",
30
31
  "@typescript-eslint/parser": "^6.14.0",
31
32
  "eslint": "^8.56.0",
32
- "eslint-config-airbnb": "^19.0.4",
33
33
  "eslint-config-prettier": "^9.1.0",
34
34
  "eslint-plugin-array-func": "^4.0.0",
35
+ "eslint-plugin-canonical": "^4.18.0",
35
36
  "eslint-plugin-filenames": "^1.3.2",
36
37
  "eslint-plugin-import": "^2.29.1",
37
38
  "eslint-plugin-jest": "^27.6.0",
38
39
  "eslint-plugin-json-format": "^2.0.1",
39
40
  "eslint-plugin-jsx-a11y": "^6.8.0",
40
41
  "eslint-plugin-prettier": "^5.0.1",
41
- "eslint-plugin-promise": "^6.1.1",
42
42
  "eslint-plugin-react": "^7.33.2",
43
43
  "eslint-plugin-react-hooks": "^4.6.0",
44
44
  "eslint-plugin-sonarjs": "^0.23.0",
@@ -53,6 +53,6 @@
53
53
  "typescript": "^5.3.3"
54
54
  },
55
55
  "peerDependencies": {
56
- "typescript": "^4 || ^5"
56
+ "typescript": "^5"
57
57
  }
58
58
  }
package/react.js CHANGED
@@ -1,27 +1,44 @@
1
1
  module.exports = {
2
- rules: {
3
- 'react/jsx-indent': [2, 4],
4
- 'react/jsx-indent-props': [2, 4],
5
- 'react/sort-comp': [1, { order: ['type-annotations', 'static-methods', 'lifecycle', 'everything-else', 'render'] }],
6
- 'react/jsx-filename-extension': [2, { extensions: ['.tsx', '.jsx'] }],
7
- 'react/jsx-curly-brace-presence': [2, { props: 'always', children: 'never' }],
8
- 'react/prefer-stateless-function': 0, // it should be converter by transpiler
9
- 'react/jsx-fragments': 0, // from with the fragments on Webstorm
10
- 'react/jsx-props-no-spreading': 0,
11
- 'react/require-default-props': 0,
12
- 'react/destructuring-assignment': 0, // no need to destruct everything
13
- 'jsx-a11y/label-has-for': 0, // still rules have some kind of bug. Label have set for, but lint throws an error.
14
- 'jsx-a11y/click-events-have-key-events': 0, // we don't need to be perfect
15
- 'jsx-a11y/href-no-hash': 0, // Definition for rule 'jsx-a11y/href-no-hash' was not found
16
- 'react/function-component-definition': 0,
17
- 'react/react-in-jsx-scope': 0,
18
- 'react/prop-types': 0,
19
- },
20
- plugins: ['react'],
21
- settings: {
22
- react: {
23
- pragma: 'React',
24
- version: '16.7',
25
- },
26
- },
2
+ extends: [
3
+ "plugin:react/recommended",
4
+ "plugin:prettier/recommended",
5
+ "plugin:jsx-a11y/recommended",
6
+ "plugin:react-hooks/recommended",
7
+ ],
8
+ rules: {
9
+ "jsx-a11y/label-has-associated-control": [2, { assert: "htmlFor" }],
10
+ "react/button-has-type": "error",
11
+ "react/display-name": 0,
12
+ "react/function-component-definition": "off",
13
+ "react/jsx-filename-extension": [
14
+ "error",
15
+ { extensions: [".js", ".jsx", ".ts", ".tsx"] },
16
+ ],
17
+ "react/jsx-max-props-per-line": [
18
+ "error",
19
+ { maximum: 1, when: "multiline" },
20
+ ],
21
+ "react/jsx-no-constructed-context-values": 0,
22
+ "react/jsx-no-useless-fragment": "off",
23
+ "react/jsx-one-expression-per-line": "off",
24
+ "react/jsx-props-no-spreading": 0,
25
+ "react/jsx-sort-props": [
26
+ 2,
27
+ {
28
+ callbacksLast: true,
29
+ shorthandFirst: true,
30
+ },
31
+ ],
32
+ "react/no-array-index-key": "error",
33
+ "react/no-danger": "error",
34
+ "react/no-typos": "error",
35
+ "react/no-unstable-nested-components": ["error", { allowAsProps: true }],
36
+ "react/no-unused-class-component-methods": "error",
37
+ "react/no-unused-prop-types": 0,
38
+ "react/prefer-stateless-function": "error",
39
+ "react/prop-types": "off",
40
+ "react/react-in-jsx-scope": 0,
41
+ "react/require-default-props": 0,
42
+ "react/state-in-constructor": "error",
43
+ },
27
44
  };