@shlinkio/eslint-config-js-coding-standard 2.5.2 → 3.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.
Files changed (3) hide show
  1. package/README.md +18 -0
  2. package/dist/index.js +109 -73
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -6,3 +6,21 @@
6
6
  [![Paypal Donate](https://img.shields.io/badge/Donate-paypal-blue.svg?style=flat-square&logo=paypal&colorA=cccccc)](https://acel.me/donate)
7
7
 
8
8
  Coding standard used by Shlink JavaScript projects.
9
+
10
+ This library includes two ESLint configurations, the base one, and the react-specific one. Default export includes both:
11
+
12
+ ```js
13
+ // eslint.config.js
14
+ import shlink from '@shlinkio/eslint-config-js-coding-standard';
15
+
16
+ export default shlink;
17
+ ```
18
+
19
+ If the project does not use React, you can just use the base config:
20
+
21
+ ```js
22
+ // eslint.config.js
23
+ import { baseConfig } from '@shlinkio/eslint-config-js-coding-standard';
24
+
25
+ export default baseConfig;
26
+ ```
package/dist/index.js CHANGED
@@ -1,79 +1,115 @@
1
- module.exports = {
2
- extends: [
3
- 'eslint:recommended',
4
- 'plugin:@typescript-eslint/recommended',
5
- 'plugin:react/recommended',
6
- 'plugin:react/jsx-runtime',
7
- 'plugin:react-hooks/recommended'
8
- ],
9
- plugins: ['jsx-a11y', 'simple-import-sort', '@stylistic'],
10
- parserOptions: {
11
- ecmaFeatures: {
12
- jsx: true
13
- }
14
- },
15
- settings: {
16
- react: {
17
- version: 'detect'
18
- }
19
- },
20
- rules: {
21
- '@stylistic/arrow-parens': 'error',
22
- '@stylistic/arrow-spacing': 'error',
23
- '@stylistic/block-spacing': 'error',
24
- '@stylistic/comma-dangle': ['error', 'always-multiline'],
25
- '@stylistic/eol-last': 'error',
26
- '@stylistic/function-call-spacing': 'error',
27
- '@stylistic/indent': ['error', 2],
28
- '@stylistic/key-spacing': 'error',
29
- '@stylistic/keyword-spacing': 'error',
30
- '@stylistic/max-len': [
31
- 'error',
32
- // Do not allow more than 120 characters per line, except for long strings and comments in the same line
33
- { 'code': 120, 'ignoreComments': true, 'ignoreStrings': true, 'ignoreTemplateLiterals': true },
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
+ {
11
+ extends: [
12
+ eslint.configs.recommended,
13
+ ...tseslint.configs.recommended,
34
14
  ],
35
- '@stylistic/no-trailing-spaces': 'error',
36
- '@stylistic/object-curly-spacing': ['error', 'always'],
37
- '@stylistic/quotes': ['error', 'single'],
38
- '@stylistic/jsx-quotes': ['error', 'prefer-double'],
39
- '@stylistic/rest-spread-spacing': 'error',
40
- '@stylistic/semi': 'error',
41
- '@stylistic/spaced-comment': 'error',
42
- '@stylistic/no-multiple-empty-lines': ['error', { 'max': 1 }],
15
+ plugins: {
16
+ '@stylistic': stylistic,
17
+ 'simple-import-sort': simpleImportSort,
18
+ },
19
+ rules: {
20
+ '@stylistic/arrow-parens': 'error',
21
+ '@stylistic/arrow-spacing': 'error',
22
+ '@stylistic/block-spacing': 'error',
23
+ '@stylistic/comma-dangle': ['error', 'always-multiline'],
24
+ '@stylistic/eol-last': 'error',
25
+ '@stylistic/function-call-spacing': 'error',
26
+ '@stylistic/indent': ['error', 2],
27
+ '@stylistic/key-spacing': 'error',
28
+ '@stylistic/keyword-spacing': 'error',
29
+ '@stylistic/max-len': [
30
+ 'error',
31
+ // Do not allow more than 120 characters per line, except for long strings and comments in the same line
32
+ { 'code': 120, 'ignoreComments': true, 'ignoreStrings': true, 'ignoreTemplateLiterals': true },
33
+ ],
34
+ '@stylistic/no-trailing-spaces': 'error',
35
+ '@stylistic/object-curly-spacing': ['error', 'always'],
36
+ '@stylistic/quotes': ['error', 'single'],
37
+ '@stylistic/jsx-quotes': ['error', 'prefer-double'],
38
+ '@stylistic/rest-spread-spacing': 'error',
39
+ '@stylistic/semi': 'error',
40
+ '@stylistic/spaced-comment': 'error',
41
+ '@stylistic/no-multiple-empty-lines': ['error', { 'max': 1 }],
43
42
 
44
- '@typescript-eslint/consistent-type-imports': 'error',
43
+ '@typescript-eslint/consistent-type-imports': 'error',
45
44
 
46
- 'simple-import-sort/imports': ['error', {
47
- 'groups': [
48
- // First external imports, then local imports, then styles imports
49
- ['^', '^\\.', '\\.s?css$']
50
- ]
51
- }],
52
- 'no-restricted-exports': ['error', {
53
- 'restrictDefaultExports': {
54
- 'direct': true,
55
- 'named': true,
56
- 'defaultFrom': true,
57
- 'namedFrom': true,
58
- 'namespaceFrom': true
59
- }
60
- }],
45
+ 'simple-import-sort/imports': ['error', {
46
+ 'groups': [
47
+ // First external imports, then local imports, then styles imports
48
+ ['^', '^\\.', '\\.s?css$']
49
+ ]
50
+ }],
51
+ 'no-restricted-exports': ['error', {
52
+ 'restrictDefaultExports': {
53
+ 'direct': true,
54
+ 'named': true,
55
+ 'defaultFrom': true,
56
+ 'namedFrom': true,
57
+ 'namespaceFrom': true
58
+ }
59
+ }],
61
60
 
62
- // Disabled rules from presets
63
- 'react/display-name': ['off', { 'ignoreTranspilerName': false }],
64
- 'react/prop-types': 'off',
65
- '@typescript-eslint/ban-types': 'off',
66
- '@typescript-eslint/no-explicit-any': 'off'
61
+ // Disabled rules from presets
62
+ '@typescript-eslint/ban-types': 'off',
63
+ '@typescript-eslint/no-explicit-any': '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
+ },
67
73
  },
68
- overrides: [
69
- {
70
- files: ['*.test.*', '*.spec.*'],
71
- rules: {
72
- 'prefer-promise-reject-errors': 'off',
73
- 'no-param-reassign': 'off',
74
- 'react/no-children-prop': 'off',
75
- '@typescript-eslint/no-shadow': 'off'
74
+ );
75
+
76
+ export const reactConfig = tseslint.config(
77
+ {
78
+ plugins: {
79
+ 'jsx-a11y': pluginJsxA11y,
80
+ react,
81
+ 'react-hooks': eslintPluginReactHooks,
82
+ },
83
+ languageOptions: {
84
+ parserOptions: {
85
+ ecmaFeatures: {
86
+ jsx: true,
87
+ },
88
+ },
89
+ },
90
+ settings: {
91
+ react: {
92
+ version: 'detect'
76
93
  }
77
- }
78
- ]
79
- };
94
+ },
95
+ rules: {
96
+ ...pluginJsxA11y.configs.recommended.rules,
97
+ ...eslintPluginReactHooks.configs.recommended.rules,
98
+
99
+ // Disabled rules from presets
100
+ 'react/display-name': ['off', { 'ignoreTranspilerName': false }],
101
+ 'react/prop-types': 'off',
102
+ },
103
+ },
104
+ {
105
+ files: ['*.test.*', '*.spec.*'],
106
+ rules: {
107
+ 'react/no-children-prop': 'off',
108
+ },
109
+ },
110
+ );
111
+
112
+ export default tseslint.config(
113
+ ...baseConfig,
114
+ ...reactConfig,
115
+ );
package/package.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "name": "@shlinkio/eslint-config-js-coding-standard",
3
3
  "description": "Coding standard used by shlink JavaScript projects",
4
4
  "main": "dist/index.js",
5
+ "type": "module",
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "git+https://github.com/shlinkio/js-coding-standard.git"
@@ -23,13 +24,12 @@
23
24
  },
24
25
  "peerDependencies": {
25
26
  "@stylistic/eslint-plugin": "^2.1.0",
26
- "@typescript-eslint/eslint-plugin": "^7.5.0",
27
- "@typescript-eslint/parser": "^7.5.0",
28
27
  "eslint": "^8.57.0",
29
28
  "eslint-plugin-jsx-a11y": "^6.8.0",
30
29
  "eslint-plugin-react": "^7.34.2",
31
30
  "eslint-plugin-react-hooks": "^4.6.2",
32
- "eslint-plugin-simple-import-sort": "^12.1.0"
31
+ "eslint-plugin-simple-import-sort": "^12.1.0",
32
+ "typescript-eslint": "^7.13.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "typescript": "^5.4.5"
@@ -37,5 +37,5 @@
37
37
  "files": [
38
38
  "dist"
39
39
  ],
40
- "version": "2.5.2"
40
+ "version": "3.0.0"
41
41
  }