@shelf/eslint-config 5.0.0 → 5.1.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/README.md CHANGED
@@ -22,28 +22,6 @@ export default [...tsConfig];
22
22
 
23
23
  ### Frontend
24
24
 
25
- #### JavaScript with React `eslint.config.js`
26
-
27
- ```js
28
- import feConfig from '@shelf/eslint-config/frontend';
29
-
30
- export default [
31
- ...feConfig,
32
- {
33
- settings: {
34
- react: {
35
- version: '16.7.0',
36
- },
37
- },
38
- rules: {
39
- "react/prop-types": "warn"
40
- }
41
- }
42
- ];
43
- ```
44
-
45
- #### TypeScript or TypeScript + Next `eslint.config.js`
46
-
47
25
  ```js
48
26
  import feTsConfig from '@shelf/eslint-config/frontend-typescript';
49
27
 
@@ -52,13 +30,10 @@ export default [
52
30
  {
53
31
  settings: {
54
32
  react: {
55
- version: '16.7.0',
33
+ version: 'detect',
56
34
  },
57
35
  },
58
- rules: {
59
- "react/prop-types": "warn"
60
- }
61
- }
36
+ },
62
37
  ];
63
38
  ```
64
39
 
package/base.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import jestFormatting from 'eslint-plugin-jest-formatting';
2
- import jsonFormat from 'eslint-plugin-json-format';
3
2
  import prettier from 'eslint-plugin-prettier';
4
3
  import jestPlugin from 'eslint-plugin-jest';
5
4
  import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
@@ -26,7 +25,6 @@ export default [
26
25
  eslintPluginPrettierRecommended,
27
26
  {
28
27
  plugins: {
29
- 'json-format': jsonFormat,
30
28
  prettier,
31
29
  '@stylistic/js': stylisticJs,
32
30
  },
package/common/env.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import globals from 'globals';
2
- import jest from 'eslint-plugin-jest';
3
2
 
4
3
  export default {
5
4
  ...globals.jest,
6
- ...jest.environments.globals.globals,
7
5
  ...globals.node,
8
6
  };
@@ -1,17 +1,25 @@
1
- import node from "eslint-plugin-node";
2
- import testingLibrary from "eslint-plugin-testing-library";
3
- import {fixupPluginRules} from '@eslint/compat';
4
- import tsParser from "@typescript-eslint/parser";
5
- import path from "node:path";
6
- import { fileURLToPath } from "node:url";
7
- import js from "@eslint/js";
8
- import { FlatCompat } from "@eslint/eslintrc";
9
- import tsEslint from 'typescript-eslint'
1
+ import node from 'eslint-plugin-n';
2
+ import testingLibrary from 'eslint-plugin-testing-library';
3
+ import {fixupConfigRules, fixupPluginRules} from '@eslint/compat';
4
+ import tsParser from '@typescript-eslint/parser';
5
+ import path from 'node:path';
6
+ import {fileURLToPath} from 'node:url';
7
+ import js from '@eslint/js';
8
+ import {FlatCompat} from '@eslint/eslintrc';
9
+ import tsEslint from 'typescript-eslint';
10
10
  import overrides from './common/overrides.js';
11
11
  import youDontNeedLodash from './rules/you-dont-need-lodash.js';
12
- import typescriptRules from './rules/typescript.js'
13
- import consistentTypeImports from './rules/consistent-type-imports.js'
14
- import frontendConfig from './frontend.js'
12
+ import typescriptRules from './rules/typescript.js';
13
+ import consistentTypeImports from './rules/consistent-type-imports.js';
14
+ import sonarjs from 'eslint-plugin-sonarjs';
15
+ import eslintConfigPrettier from 'eslint-config-prettier';
16
+ import baseConfig from './base.js';
17
+ import react from 'eslint-plugin-react';
18
+ import reactHooks from 'eslint-plugin-react-hooks';
19
+ import _import from 'eslint-plugin-import';
20
+ import globals from 'globals';
21
+ import env from './common/env.js';
22
+ import restrictedPackagesImport from './rules/restricted-packages-import.js';
15
23
 
16
24
  const __filename = fileURLToPath(import.meta.url);
17
25
  const __dirname = path.dirname(__filename);
@@ -21,25 +29,45 @@ const compat = new FlatCompat({
21
29
  });
22
30
 
23
31
  const testingLibraryReact = {
24
- rules: compat.extends("plugin:testing-library/react")[0].rules,
25
- files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)']
32
+ rules: compat.extends('plugin:testing-library/react')[0].rules,
33
+ files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
26
34
  };
27
35
 
28
- export default [...compat.extends(
29
- "plugin:you-dont-need-lodash-underscore/compatible",
30
- ), ...tsEslint.configs.recommended,
31
- ...frontendConfig,
36
+ export default [
37
+ ...compat.extends('plugin:you-dont-need-lodash-underscore/compatible'),
38
+ ...tsEslint.configs.recommended,
39
+ ...fixupConfigRules(compat.extends('plugin:react/recommended', 'plugin:react-hooks/recommended')),
40
+ sonarjs.configs.recommended,
41
+ eslintConfigPrettier,
42
+ ...baseConfig,
43
+ {
44
+ rules: {
45
+ ...restrictedPackagesImport,
46
+ 'no-console': 'error',
47
+ 'react-hooks/exhaustive-deps': 'error',
48
+ 'sonarjs/cognitive-complexity': ['error', 18],
49
+ '@stylistic/js/multiline-comment-style': 'off',
50
+ 'no-unreachable': 'error',
51
+ 'react/react-in-jsx-scope': 'off',
52
+ },
53
+ },
32
54
  testingLibraryReact,
33
55
  {
34
56
  plugins: {
57
+ react: fixupPluginRules(react),
58
+ 'react-hooks': fixupPluginRules(reactHooks),
59
+ import: fixupPluginRules(_import),
35
60
  '@typescript-eslint': tsEslint.plugin,
36
61
  node,
37
- "testing-library": fixupPluginRules(testingLibrary),
62
+ 'testing-library': fixupPluginRules(testingLibrary),
38
63
  },
39
64
 
40
65
  languageOptions: {
66
+ globals: {
67
+ ...env,
68
+ ...globals.browser,
69
+ },
41
70
  parser: tsParser,
42
-
43
71
  parserOptions: {
44
72
  ecmaFeatures: {
45
73
  jsx: true,
@@ -49,45 +77,47 @@ export default [...compat.extends(
49
77
 
50
78
  rules: {
51
79
  // Often test name starts with component name which are always capitalized
52
- "jest/lowercase-name": "off",
53
- "react/prop-types": "off",
54
- "react/display-name": "warn",
55
- "testing-library/await-async-queries": "error",
56
- "testing-library/no-await-sync-queries": "error",
80
+ 'jest/lowercase-name': 'off',
81
+ 'react/prop-types': 'off',
82
+ 'react/display-name': 'warn',
83
+ 'testing-library/await-async-queries': 'error',
84
+ 'testing-library/no-await-sync-queries': 'error',
57
85
  // 'testing-library/no-wait-for-empty-callback': 'error',
58
86
  // It's enabled in overrides
59
- "testing-library/no-debugging-utils": "off",
60
- "testing-library/consistent-data-testid": [2, {
61
- testIdPattern: "^(([a-z])+(-)*)+$",
62
- }],
87
+ 'testing-library/no-debugging-utils': 'off',
88
+ 'testing-library/consistent-data-testid': [
89
+ 2,
90
+ {
91
+ testIdPattern: '^(([a-z])+(-)*)+$',
92
+ },
93
+ ],
63
94
  ...consistentTypeImports,
64
95
  // it fail to compile TS on react static class properties (displayName | defaultProps | etc..)
65
- "@typescript-eslint/explicit-member-accessibility": 0,
66
- "@typescript-eslint/consistent-type-assertions": "warn",
96
+ '@typescript-eslint/explicit-member-accessibility': 0,
97
+ '@typescript-eslint/consistent-type-assertions': 'warn',
67
98
  // Don`t need for typescript files
68
- "@typescript-eslint/no-empty-function": "off",
99
+ '@typescript-eslint/no-empty-function': 'off',
69
100
  ...typescriptRules,
70
- "@typescript-eslint/no-unused-vars": ["error", {ignoreRestSiblings: true}],
101
+ '@typescript-eslint/no-unused-vars': ['error', {ignoreRestSiblings: true}],
71
102
  ...youDontNeedLodash,
72
103
  },
73
104
  },
74
105
  overrides.allowRequireInConfigs,
75
106
  overrides.noExplicitsInTests,
76
107
  overrides.noCastWithJestMock,
108
+ overrides.noTSRulesWithJSON,
77
109
  {
78
- files: ["**/*.test.{ts,tsx,js}", "**/mocks.ts", "**/mock.js"],
79
-
110
+ files: ['**/*.test.{ts,tsx,js}', '**/mocks.ts', '**/mock.js'],
80
111
  rules: {
81
- camelcase: "off",
82
- "sonarjs/no-duplicate-string": "off",
83
- "testing-library/no-debugging-utils": "error",
112
+ camelcase: 'off',
113
+ 'sonarjs/no-duplicate-string': 'off',
114
+ 'testing-library/no-debugging-utils': 'error',
84
115
  },
85
116
  },
86
117
  {
87
- files: ["**/*.styled.{ts,tsx}"],
88
-
118
+ files: ['**/*.styled.{ts,tsx}'],
89
119
  rules: {
90
- "sonarjs/no-nested-template-literals": "off",
120
+ 'sonarjs/no-nested-template-literals': 'off',
91
121
  },
92
- }
122
+ },
93
123
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shelf/eslint-config",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "ESLint Config for Shelf Projects",
5
5
  "license": "MIT",
6
6
  "repository": "shelfio/eslint-config",
@@ -13,15 +13,14 @@
13
13
  "node": ">=8.10"
14
14
  },
15
15
  "scripts": {
16
- "test": "echo ok"
16
+ "test": "echo ok",
17
+ "prepare": "husky"
17
18
  },
18
19
  "files": [
19
20
  "common",
20
21
  "rules",
21
22
  "base.js",
22
- "frontend.js",
23
23
  "frontend-typescript.js",
24
- "meteor.js",
25
24
  "typescript.js"
26
25
  ],
27
26
  "main": "base.js",
@@ -34,39 +33,35 @@
34
33
  },
35
34
  "type": "module",
36
35
  "dependencies": {
37
- "@babel/eslint-parser": "7.26.8",
38
- "@babel/eslint-plugin": "7.25.9",
39
36
  "@eslint/compat": "1.2.6",
40
37
  "@eslint/eslintrc": "3.2.0",
41
38
  "@eslint/js": "9.20.0",
42
39
  "@stylistic/eslint-plugin-js": "2.13.0",
43
40
  "@types/eslint__js": "8.42.3",
44
- "@typescript-eslint/eslint-plugin": "8.24.1",
45
- "@typescript-eslint/parser": "8.24.1",
46
- "eslint-config-next": "15.1.7",
47
- "eslint-config-prettier": "10.0.1",
41
+ "@typescript-eslint/eslint-plugin": "8.26.0",
42
+ "@typescript-eslint/parser": "8.26.0",
43
+ "eslint-config-next": "15.2.3",
44
+ "eslint-config-prettier": "10.1.1",
48
45
  "eslint-plugin-babel": "5.3.1",
49
46
  "eslint-plugin-import": "2.31.0",
50
47
  "eslint-plugin-jest": "28.11.0",
51
48
  "eslint-plugin-jest-formatting": "3.1.0",
52
- "eslint-plugin-json-format": "2.0.1",
53
49
  "eslint-plugin-jsx": "0.1.0",
54
- "eslint-plugin-n": "17.15.1",
55
- "eslint-plugin-node": "11.1.0",
50
+ "eslint-plugin-n": "17.16.2",
56
51
  "eslint-plugin-prettier": "5.2.3",
57
52
  "eslint-plugin-react": "7.37.4",
58
- "eslint-plugin-react-hooks": "5.1.0",
53
+ "eslint-plugin-react-hooks": "5.2.0",
59
54
  "eslint-plugin-shelf-no-need-lodash-methods": "2.0.8",
60
55
  "eslint-plugin-sonarjs": "3.0.2",
61
56
  "eslint-plugin-testing-library": "7.1.1",
62
57
  "eslint-plugin-you-dont-need-lodash-underscore": "6.14.0",
63
58
  "globals": "15.15.0",
64
- "typescript-eslint": "8.24.1"
59
+ "typescript-eslint": "8.26.0"
65
60
  },
66
61
  "devDependencies": {
67
- "husky": "8.0.3",
68
- "lint-staged": "15.4.3",
69
- "prettier": "3.5.1"
62
+ "husky": "9.1.7",
63
+ "lint-staged": "15.5.0",
64
+ "prettier": "3.5.3"
70
65
  },
71
66
  "peerDependencies": {
72
67
  "eslint": "9.x",
package/typescript.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import jestFormatting from 'eslint-plugin-jest-formatting';
2
- import jsonFormat from 'eslint-plugin-json-format';
3
2
  import prettier from 'eslint-plugin-prettier';
4
3
  import _import from 'eslint-plugin-import';
5
- import node from 'eslint-plugin-node';
4
+ import node from 'eslint-plugin-n';
6
5
  import {fixupPluginRules} from '@eslint/compat';
7
6
  import tsParser from '@typescript-eslint/parser';
8
7
  import path from 'node:path';
@@ -51,7 +50,6 @@ export default [
51
50
  {
52
51
  plugins: {
53
52
  'jest-formatting': jestFormatting,
54
- 'json-format': jsonFormat,
55
53
  prettier,
56
54
  import: fixupPluginRules(_import),
57
55
  node,
@@ -117,6 +115,13 @@ export default [
117
115
  requireReturnForObjectLiteral: true,
118
116
  },
119
117
  ],
118
+ 'id-length': [
119
+ 'warn',
120
+ {
121
+ min: 1,
122
+ max: 14
123
+ },
124
+ ],
120
125
  'no-unreachable': 'error',
121
126
  'require-await': 'error',
122
127
  ...youDontNeedLodash,
package/.husky/_/husky.sh DELETED
@@ -1,31 +0,0 @@
1
- #!/bin/sh
2
- if [ -z "$husky_skip_init" ]; then
3
- debug () {
4
- if [ "$HUSKY_DEBUG" = "1" ]; then
5
- echo "husky (debug) - $1"
6
- fi
7
- }
8
-
9
- readonly hook_name="$(basename "$0")"
10
- debug "starting $hook_name..."
11
-
12
- if [ "$HUSKY" = "0" ]; then
13
- debug "HUSKY env variable is set to 0, skipping hook"
14
- exit 0
15
- fi
16
-
17
- if [ -f ~/.huskyrc ]; then
18
- debug "sourcing ~/.huskyrc"
19
- . ~/.huskyrc
20
- fi
21
-
22
- export readonly husky_skip_init=1
23
- sh -e "$0" "$@"
24
- exitCode="$?"
25
-
26
- if [ $exitCode != 0 ]; then
27
- echo "husky - $hook_name hook exited with code $exitCode (error)"
28
- fi
29
-
30
- exit $exitCode
31
- fi
package/CHANGELOG.md DELETED
@@ -1,12 +0,0 @@
1
- ## 3.0.0
2
-
3
- Override recommended no explicit type any in tests
4
-
5
- ## 2.0.0
6
-
7
- Removed separate file for testing-library, added testing-library rules to `frontend-typescript.js`.
8
- Extended `frontend.js` in `frontend-typescript.js` and `frontend-typescript-vue.js`.
9
-
10
- ## 1.0.0
11
-
12
- Breaking changes of the eslint-config-prettier 8.0.0
package/frontend.js DELETED
@@ -1,71 +0,0 @@
1
- import { FlatCompat } from '@eslint/eslintrc';
2
- import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
3
- import react from "eslint-plugin-react";
4
- import _import from "eslint-plugin-import";
5
- import sonarjs from "eslint-plugin-sonarjs";
6
- import globals from "globals";
7
- import babelParser from "@babel/eslint-parser";
8
- import path from "node:path";
9
- import { fileURLToPath } from "node:url";
10
- import js from "@eslint/js";
11
- import reactHooks from 'eslint-plugin-react-hooks';
12
- import eslintConfigPrettier from 'eslint-config-prettier';
13
- import env from './common/env.js';
14
- import restrictedPackagesImport from './rules/restricted-packages-import.js';
15
- import baseConfig from './base.js';
16
-
17
-
18
- const __filename = fileURLToPath(import.meta.url);
19
- const __dirname = path.dirname(__filename);
20
- const compat = new FlatCompat({
21
- baseDirectory: __dirname,
22
- recommendedConfig: js.configs.recommended,
23
- });
24
-
25
- export default [...fixupConfigRules(compat.extends(
26
- "plugin:react/recommended",
27
- "plugin:react-hooks/recommended",
28
- )),
29
- sonarjs.configs.recommended,
30
- eslintConfigPrettier,
31
- ...baseConfig,
32
- {
33
- plugins: {
34
- react: fixupPluginRules(react),
35
- 'react-hooks': fixupPluginRules(reactHooks),
36
- import: fixupPluginRules(_import),
37
- },
38
-
39
- languageOptions: {
40
- globals: {
41
- ...globals.browser,
42
- ...env,
43
- },
44
-
45
- parser: babelParser,
46
- ecmaVersion: 5,
47
- sourceType: "commonjs",
48
-
49
- parserOptions: {
50
- ecmaFeatures: {
51
- jsx: true,
52
- },
53
- }
54
- },
55
-
56
- rules: {
57
- ...restrictedPackagesImport,
58
- "no-console": "error",
59
- "react-hooks/exhaustive-deps": "error",
60
- "sonarjs/cognitive-complexity": ["error", 18],
61
- "@stylistic/js/multiline-comment-style": "off",
62
- "no-unreachable": "error",
63
- "react/react-in-jsx-scope": "off",
64
- },
65
- }, {
66
- files: ["**/*.test.{ts,tsx}"],
67
-
68
- rules: {
69
- "sonarjs/no-duplicate-string": "off",
70
- },
71
- }];
package/meteor.js DELETED
@@ -1,71 +0,0 @@
1
- import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
2
- import babel from "@babel/eslint-plugin";
3
- import react from "eslint-plugin-react";
4
- import prettier from "eslint-plugin-prettier";
5
- import _import from "eslint-plugin-import";
6
- import globals from "globals";
7
- import babelParser from "@babel/eslint-parser";
8
- import path from "node:path";
9
- import { fileURLToPath } from "node:url";
10
- import js from "@eslint/js";
11
- import { FlatCompat } from "@eslint/eslintrc";
12
- import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
13
- import importOrder from './rules/import-order.js';
14
- import paddingLineBetweenStatements from './rules/padding-line-between-statements.js';
15
- import stylisticJs from '@stylistic/eslint-plugin-js';
16
-
17
-
18
- const __filename = fileURLToPath(import.meta.url);
19
- const __dirname = path.dirname(__filename);
20
- const compat = new FlatCompat({
21
- baseDirectory: __dirname,
22
- recommendedConfig: js.configs.recommended,
23
- });
24
-
25
- export default [...fixupConfigRules(compat.extends(
26
- "plugin:react/recommended",
27
- )),
28
- eslintPluginPrettierRecommended,
29
- {
30
- plugins: {
31
- babel,
32
- react: fixupPluginRules(react),
33
- prettier,
34
- import: fixupPluginRules(_import),
35
- '@stylistic/js': stylisticJs,
36
- },
37
-
38
- languageOptions: {
39
- globals: {
40
- ...globals.node,
41
- ...globals.browser,
42
- ...globals.meteor,
43
- },
44
-
45
- parser: babelParser,
46
-
47
- parserOptions: {
48
- ecmaFeatures: {
49
- jsx: true,
50
- },
51
-
52
- allowImportExportEverywhere: false,
53
- codeFrame: false,
54
- },
55
- },
56
-
57
- rules: {
58
- "prettier/prettier": "error",
59
- ...importOrder,
60
- ...paddingLineBetweenStatements,
61
- "comma-dangle": "off",
62
- camelcase: "error",
63
- eqeqeq: ["error", "smart"],
64
- "new-cap": "error",
65
- "no-extend-native": "error",
66
- "no-use-before-define": ["error", "nofunc"],
67
- "@stylistic/js/multiline-comment-style": ["error", "separate-lines"],
68
- "no-unreachable": "error",
69
- "require-await": "error",
70
- },
71
- }];