@shlinkio/eslint-config-js-coding-standard 3.4.0 → 3.5.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
@@ -7,9 +7,12 @@
7
7
 
8
8
  Coding standard used by Shlink JavaScript projects.
9
9
 
10
- This library includes two ESLint configurations, the base one (which includes eslint and typescript recommended rules), and the react-specific one (which includes JSX accessibility, react and react hooks recommended rules).
10
+ This library includes two ESLint configurations on their own entry points:
11
11
 
12
- Default export includes both:
12
+ * `/base`: includes recommended eslint, typescript and imports rules
13
+ * `/react` includes recommended JSX accessibility, react, react hooks and react compiler rules.
14
+
15
+ The default entry point includes both of them:
13
16
 
14
17
  ```js
15
18
  // eslint.config.js
@@ -27,7 +30,7 @@ If the project does not use React, you can just use the base config:
27
30
 
28
31
  ```js
29
32
  // eslint.config.js
30
- import { baseConfig } from '@shlinkio/eslint-config-js-coding-standard';
33
+ import baseConfig from '@shlinkio/eslint-config-js-coding-standard/base';
31
34
 
32
35
  export default [
33
36
  ...baseConfig,
@@ -36,3 +39,17 @@ export default [
36
39
  }
37
40
  ];
38
41
  ```
42
+
43
+ If you need to access react rules independently, use the `/react` entry point:
44
+
45
+ ```js
46
+ // eslint.config.js
47
+ import reactConfig from '@shlinkio/eslint-config-js-coding-standard/react';
48
+
49
+ export default [
50
+ ...reactConfig,
51
+ {
52
+ // Other rules...
53
+ }
54
+ ];
55
+ ```
package/dist/base.js ADDED
@@ -0,0 +1,76 @@
1
+ import eslint from '@eslint/js';
2
+ import tseslint from 'typescript-eslint';
3
+ import importPlugin from 'eslint-plugin-import';
4
+ import stylistic from '@stylistic/eslint-plugin';
5
+ import simpleImportSort from 'eslint-plugin-simple-import-sort';
6
+
7
+ const baseConfig = tseslint.config(
8
+ eslint.configs.recommended,
9
+ ...tseslint.configs.recommended,
10
+ importPlugin.flatConfigs.recommended,
11
+ {
12
+ plugins: {
13
+ '@stylistic': stylistic,
14
+ 'simple-import-sort': simpleImportSort,
15
+ },
16
+ rules: {
17
+ '@stylistic/arrow-parens': 'error',
18
+ '@stylistic/arrow-spacing': 'error',
19
+ '@stylistic/block-spacing': 'error',
20
+ '@stylistic/comma-dangle': ['error', 'always-multiline'],
21
+ '@stylistic/eol-last': 'error',
22
+ '@stylistic/function-call-spacing': 'error',
23
+ '@stylistic/indent': ['error', 2],
24
+ '@stylistic/key-spacing': 'error',
25
+ '@stylistic/keyword-spacing': 'error',
26
+ '@stylistic/max-len': [
27
+ 'error',
28
+ // Do not allow more than 120 characters per line, except for long strings and comments in the same line
29
+ { 'code': 120, 'ignoreComments': true, 'ignoreStrings': true, 'ignoreTemplateLiterals': true },
30
+ ],
31
+ '@stylistic/no-trailing-spaces': 'error',
32
+ '@stylistic/object-curly-spacing': ['error', 'always'],
33
+ '@stylistic/quotes': ['error', 'single'],
34
+ '@stylistic/jsx-quotes': ['error', 'prefer-double'],
35
+ '@stylistic/rest-spread-spacing': 'error',
36
+ '@stylistic/semi': 'error',
37
+ '@stylistic/spaced-comment': 'error',
38
+ '@stylistic/no-multiple-empty-lines': ['error', { 'max': 1 }],
39
+
40
+ '@typescript-eslint/consistent-type-imports': 'error',
41
+
42
+ 'simple-import-sort/imports': ['error', {
43
+ 'groups': [
44
+ // First external imports, then local imports, then styles imports
45
+ ['^', '^\\.', '\\.s?css$']
46
+ ]
47
+ }],
48
+ 'no-restricted-exports': ['error', {
49
+ 'restrictDefaultExports': {
50
+ 'direct': true,
51
+ 'named': true,
52
+ 'defaultFrom': true,
53
+ 'namedFrom': true,
54
+ 'namespaceFrom': true
55
+ }
56
+ }],
57
+
58
+ 'import/no-duplicates': 'error',
59
+
60
+ // Disabled rules from presets
61
+ '@typescript-eslint/ban-types': 'off',
62
+ '@typescript-eslint/no-explicit-any': 'off',
63
+ 'import/no-unresolved': 'off',
64
+ },
65
+ },
66
+ {
67
+ files: ['*.test.*', '*.spec.*'],
68
+ rules: {
69
+ 'prefer-promise-reject-errors': 'off',
70
+ 'no-param-reassign': 'off',
71
+ '@typescript-eslint/no-shadow': 'off',
72
+ },
73
+ },
74
+ );
75
+
76
+ export default baseConfig;
package/dist/index.js CHANGED
@@ -1,112 +1,5 @@
1
- import eslint from '@eslint/js';
2
- import stylistic from '@stylistic/eslint-plugin';
3
- import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
4
- import react from 'eslint-plugin-react';
5
- import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
6
- import simpleImportSort from 'eslint-plugin-simple-import-sort';
7
- import tseslint from 'typescript-eslint';
8
-
9
- export const baseConfig = tseslint.config(
10
- eslint.configs.recommended,
11
- ...tseslint.configs.recommended,
12
- {
13
- plugins: {
14
- '@stylistic': stylistic,
15
- 'simple-import-sort': simpleImportSort,
16
- },
17
- rules: {
18
- '@stylistic/arrow-parens': 'error',
19
- '@stylistic/arrow-spacing': 'error',
20
- '@stylistic/block-spacing': 'error',
21
- '@stylistic/comma-dangle': ['error', 'always-multiline'],
22
- '@stylistic/eol-last': 'error',
23
- '@stylistic/function-call-spacing': 'error',
24
- '@stylistic/indent': ['error', 2],
25
- '@stylistic/key-spacing': 'error',
26
- '@stylistic/keyword-spacing': 'error',
27
- '@stylistic/max-len': [
28
- 'error',
29
- // Do not allow more than 120 characters per line, except for long strings and comments in the same line
30
- { 'code': 120, 'ignoreComments': true, 'ignoreStrings': true, 'ignoreTemplateLiterals': true },
31
- ],
32
- '@stylistic/no-trailing-spaces': 'error',
33
- '@stylistic/object-curly-spacing': ['error', 'always'],
34
- '@stylistic/quotes': ['error', 'single'],
35
- '@stylistic/jsx-quotes': ['error', 'prefer-double'],
36
- '@stylistic/rest-spread-spacing': 'error',
37
- '@stylistic/semi': 'error',
38
- '@stylistic/spaced-comment': 'error',
39
- '@stylistic/no-multiple-empty-lines': ['error', { 'max': 1 }],
40
-
41
- '@typescript-eslint/consistent-type-imports': 'error',
42
-
43
- 'simple-import-sort/imports': ['error', {
44
- 'groups': [
45
- // First external imports, then local imports, then styles imports
46
- ['^', '^\\.', '\\.s?css$']
47
- ]
48
- }],
49
- 'no-restricted-exports': ['error', {
50
- 'restrictDefaultExports': {
51
- 'direct': true,
52
- 'named': true,
53
- 'defaultFrom': true,
54
- 'namedFrom': true,
55
- 'namespaceFrom': true
56
- }
57
- }],
58
-
59
- // Disabled rules from presets
60
- '@typescript-eslint/ban-types': 'off',
61
- '@typescript-eslint/no-explicit-any': 'off',
62
- },
63
- },
64
- {
65
- files: ['*.test.*', '*.spec.*'],
66
- rules: {
67
- 'prefer-promise-reject-errors': 'off',
68
- 'no-param-reassign': 'off',
69
- '@typescript-eslint/no-shadow': 'off',
70
- },
71
- },
72
- );
73
-
74
- export const reactConfig = [
75
- react.configs.flat.recommended,
76
- react.configs.flat['jsx-runtime'],
77
- pluginJsxA11y.flatConfigs.recommended,
78
- {
79
- plugins: {
80
- 'react-hooks': eslintPluginReactHooks,
81
- },
82
- languageOptions: {
83
- parserOptions: {
84
- ecmaFeatures: {
85
- jsx: true,
86
- },
87
- },
88
- },
89
- settings: {
90
- react: {
91
- version: 'detect'
92
- }
93
- },
94
- rules: {
95
- 'react-hooks/rules-of-hooks': 'error',
96
- 'react-hooks/exhaustive-deps': 'error',
97
-
98
- // Disabled rules from presets
99
- 'react/display-name': ['off', { 'ignoreTranspilerName': false }],
100
- 'react/prop-types': 'off',
101
- },
102
- },
103
- {
104
- files: ['*.test.*', '*.spec.*'],
105
- rules: {
106
- 'react/no-children-prop': 'off',
107
- },
108
- },
109
- ];
1
+ import baseConfig from './base.js';
2
+ import reactConfig from './react.js';
110
3
 
111
4
  export default [
112
5
  ...baseConfig,
package/dist/react.js ADDED
@@ -0,0 +1,45 @@
1
+ import react from 'eslint-plugin-react';
2
+ import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
3
+ import reactCompiler from 'eslint-plugin-react-compiler';
4
+ import reactHooks from 'eslint-plugin-react-hooks';
5
+
6
+ const reactConfig = [
7
+ react.configs.flat.recommended,
8
+ react.configs.flat['jsx-runtime'],
9
+ pluginJsxA11y.flatConfigs.recommended,
10
+ reactCompiler.configs.recommended,
11
+ {
12
+ plugins: {
13
+ 'react-hooks': reactHooks,
14
+ },
15
+ languageOptions: {
16
+ parserOptions: {
17
+ ecmaFeatures: {
18
+ jsx: true,
19
+ },
20
+ },
21
+ },
22
+ settings: {
23
+ react: {
24
+ version: 'detect'
25
+ }
26
+ },
27
+ rules: {
28
+ 'react/jsx-tag-spacing': ['error', { beforeClosing: 'never' }],
29
+ 'react-hooks/rules-of-hooks': 'error',
30
+ 'react-hooks/exhaustive-deps': 'error',
31
+
32
+ // Disabled rules from presets
33
+ 'react/display-name': ['off', { 'ignoreTranspilerName': false }],
34
+ 'react/prop-types': 'off',
35
+ },
36
+ },
37
+ {
38
+ files: ['*.test.*', '*.spec.*'],
39
+ rules: {
40
+ 'react/no-children-prop': 'off',
41
+ },
42
+ },
43
+ ];
44
+
45
+ export default reactConfig;
package/package.json CHANGED
@@ -1,8 +1,19 @@
1
1
  {
2
2
  "name": "@shlinkio/eslint-config-js-coding-standard",
3
3
  "description": "Coding standard used by shlink JavaScript projects",
4
- "main": "dist/index.js",
5
4
  "type": "module",
5
+ "main": "dist/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js"
9
+ },
10
+ "./base": {
11
+ "import": "./dist/base.js"
12
+ },
13
+ "./react": {
14
+ "import": "./dist/react.js"
15
+ }
16
+ },
6
17
  "repository": {
7
18
  "type": "git",
8
19
  "url": "git+https://github.com/shlinkio/js-coding-standard.git"
@@ -20,22 +31,38 @@
20
31
  },
21
32
  "homepage": "https://github.com/shlinkio/js-coding-standard",
22
33
  "scripts": {
23
- "build": "mkdir -p dist && rm -rf dist/* && cp index.js dist"
34
+ "build": "mkdir -p dist && rm -rf dist/* && cp *.js dist"
24
35
  },
25
36
  "peerDependencies": {
26
- "@stylistic/eslint-plugin": ">=3.0.1",
37
+ "@stylistic/eslint-plugin": ">=4.2.0",
27
38
  "eslint": "^9.20.1",
39
+ "eslint-plugin-import": "^2.31.0",
28
40
  "eslint-plugin-jsx-a11y": "^6.8.0",
29
41
  "eslint-plugin-react": "^7.34.2",
42
+ "eslint-plugin-react-compiler": "*",
30
43
  "eslint-plugin-react-hooks": "^5.0.0",
31
44
  "eslint-plugin-simple-import-sort": "^12.1.0",
32
- "typescript-eslint": "^8.20"
45
+ "typescript-eslint": "^8.28"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "eslint-plugin-jsx-a11y": {
49
+ "optional": true
50
+ },
51
+ "eslint-plugin-react": {
52
+ "optional": true
53
+ },
54
+ "eslint-plugin-react-compiler": {
55
+ "optional": true
56
+ },
57
+ "eslint-plugin-react-hooks": {
58
+ "optional": true
59
+ }
33
60
  },
34
61
  "devDependencies": {
35
- "typescript": "^5.7.3"
62
+ "typescript": "^5.8.2"
36
63
  },
37
64
  "files": [
38
65
  "dist"
39
66
  ],
40
- "version": "3.4.0"
67
+ "version": "3.5.0"
41
68
  }