Skip to content

Commit 81a1ec4

Browse files
authored
Merge pull request #128 from acelaya-forks/feature/more-plugins
Feature/more plugins
2 parents 538bb01 + 663865c commit 81a1ec4

File tree

7 files changed

+1147
-128
lines changed

7 files changed

+1147
-128
lines changed

CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
66

7+
## [3.5.0] - 2025-03-29
8+
#### Added
9+
* Add `eslint-plugin-import`
10+
* Add `eslint-plugin-react-compiler`
11+
12+
#### Changed
13+
* Expose base and react configs on their own entry points. Default entry point still merges both.
14+
15+
#### Deprecated
16+
* *Nothing*
17+
18+
#### Removed
19+
* *Nothing*
20+
21+
#### Fixed
22+
* *Nothing*
23+
24+
725
## [3.4.1] - 2025-03-28
826
#### Added
927
* *Nothing*

README.md

+20-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
Coding standard used by Shlink JavaScript projects.
99

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:
1111

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:
1316

1417
```js
1518
// eslint.config.js
@@ -27,7 +30,7 @@ If the project does not use React, you can just use the base config:
2730

2831
```js
2932
// eslint.config.js
30-
import { baseConfig } from '@shlinkio/eslint-config-js-coding-standard';
33+
import baseConfig from '@shlinkio/eslint-config-js-coding-standard/base';
3134

3235
export default [
3336
...baseConfig,
@@ -36,3 +39,17 @@ export default [
3639
}
3740
];
3841
```
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+
```

base.js

+76
Original file line numberDiff line numberDiff line change
@@ -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;

index.js

+2-110
Original file line numberDiff line numberDiff line change
@@ -1,113 +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/jsx-tag-spacing': ['error', { beforeClosing: 'never' }],
96-
'react-hooks/rules-of-hooks': 'error',
97-
'react-hooks/exhaustive-deps': 'error',
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-
];
1+
import baseConfig from './base.js';
2+
import reactConfig from './react.js';
1113

1124
export default [
1135
...baseConfig,

0 commit comments

Comments
 (0)