@slango.configs/eslint 1.1.42 → 1.1.43

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @slango.configs/eslint@1.1.42 lint /home/runner/work/slango/slango/configs/eslint
2
+ > @slango.configs/eslint@1.1.43 lint /home/runner/work/slango/slango/configs/eslint
3
3
  > eslint . --max-warnings 0
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @slango.configs/eslint
2
2
 
3
+ ## 1.1.43
4
+
5
+ ### Patch Changes
6
+
7
+ - f5a8154: Less strict defaults
8
+
3
9
  ## 1.1.42
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -12,16 +12,16 @@ This package exposes eslint configurations for easy setup, the following presets
12
12
 
13
13
  ## Included plugins/configs
14
14
 
15
- | Name | Available in Preset | Description |
16
- | ---------------------------------------------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------- |
17
- | [`@eslint/js` recommended](https://github.com/eslint/eslint) | `all` | @eslint/js official recommended configuration |
18
- | [`eslint-plugin-eslint-comments` recommended](https://github.com/eslint-community/eslint-plugin-eslint-comments) | `all` | Comments from @eslint-community for comments |
19
- | [`eslint-plugin-perfectionist` recommended natural](https://github.com/azat-io/eslint-plugin-perfectionist) | `all` | Natural Recommended config from perfectionist-plugin-perfectionnist |
20
- | [`eslint-plugin-regex` recommended](https://github.com/ota-meshi/eslint-plugin-regexp) | `all` | Recommended config from regexp-eslint-plugin |
21
- | [`eslint-plugin-prettier` recommended](https://github.com/prettier/eslint-plugin-prettier) | `all` | Prettier official eslint plugin's recommended config |
22
- | [`eslint-plugin-import` recommended](https://github.com/import-js/eslint-plugin-import) | `all` | Prettier official eslint plugin's recommended config |
23
- | [`typescript-eslint` recommendedTypeChecked](https://github.com/typescript-eslint/typescript-eslint) | `all typescript configs` | Typescript Eslint type checked recommended config |
24
- | [`next/core-web-vitals`](https://nextjs.org/docs/app/building-your-application/configuring/eslint) | `typescript-next` | Next.js official eslint config |
15
+ | Name | Available in Preset | Description |
16
+ | ---------------------------------------------------------------------------------------------------------------- | ------------------------ | -------------------------------------------------------- |
17
+ | [`@eslint/js` recommended](https://github.com/eslint/eslint) | `all` | @eslint/js official recommended configuration |
18
+ | [`eslint-plugin-eslint-comments` recommended](https://github.com/eslint-community/eslint-plugin-eslint-comments) | `all` | Comments from @eslint-community for comments |
19
+ | [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) | `all` | Configurable sorting rules with tiered strictness levels |
20
+ | [`eslint-plugin-regex` recommended](https://github.com/ota-meshi/eslint-plugin-regexp) | `all` | Recommended config from regexp-eslint-plugin |
21
+ | [`eslint-plugin-prettier` recommended](https://github.com/prettier/eslint-plugin-prettier) | `all` | Prettier official eslint plugin's recommended config |
22
+ | [`eslint-plugin-import` recommended](https://github.com/import-js/eslint-plugin-import) | `all` | Prettier official eslint plugin's recommended config |
23
+ | [`typescript-eslint` recommendedTypeChecked](https://github.com/typescript-eslint/typescript-eslint) | `all typescript configs` | Typescript Eslint type checked recommended config |
24
+ | [`next/core-web-vitals`](https://nextjs.org/docs/app/building-your-application/configuring/eslint) | `typescript-next` | Next.js official eslint config |
25
25
 
26
26
  ## Usage
27
27
 
@@ -36,21 +36,46 @@ export { default } from '@slango.configs/eslint/{preset-you-wish-to-use}.js';
36
36
 
37
37
  ### Perfectionist rule strictness
38
38
 
39
- Perfectionist sorting rules can be configured with three levels of strictness:
39
+ Perfectionist sorting rules are organized into **tiers** and can be configured with four levels of strictness:
40
40
 
41
- - `off` disables all perfectionist sorting rules
42
- - `relaxed` only enforces module sorting (default)
43
- - `strict` enforces sorting for modules, enums, object types and objects
41
+ | Level | Description | Use Case |
42
+ | ---------- | -------------------------------------------------- | ---------------------------------------- |
43
+ | `off` | All perfectionist rules disabled | When you want no automatic sorting |
44
+ | `relaxed` | Import/export sorting only **(default)** | Universally accepted, industry standard |
45
+ | `moderate` | Adds type sorting (interfaces, unions, enums) | Good for type-heavy TypeScript codebases |
46
+ | `strict` | Full sorting including objects, classes, JSX props | Maximum consistency, use with caution |
44
47
 
45
- To use a custom level, import the corresponding creator and pass an options object. Passing an unknown option or an invalid level throws an error:
48
+ #### Rule tiers
49
+
50
+ **Tier 1 - Import/Export sorting** (`relaxed`+)
51
+
52
+ - `sort-imports`, `sort-named-imports`, `sort-named-exports`, `sort-exports`
53
+ - `sort-import-attributes`, `sort-export-attributes`, `sort-modules`
54
+
55
+ **Tier 2 - Type sorting** (`moderate`+)
56
+
57
+ - `sort-union-types`, `sort-intersection-types`, `sort-heritage-clauses`
58
+ - `sort-object-types`, `sort-interfaces`, `sort-enums`
59
+
60
+ **Tier 3 - Full sorting** (`strict` only)
61
+
62
+ - `sort-objects`, `sort-classes`, `sort-jsx-props`, `sort-decorators`
63
+ - `sort-switch-case`, `sort-variable-declarations`, `sort-array-includes`
64
+ - `sort-sets`, `sort-maps`
65
+
66
+ > **Note**: Tier 3 rules are disabled by default because they can be controversial or break intentional ordering. For example, `sort-decorators` can break functionality when decorator order matters semantically, and `sort-switch-case` often disrupts intentional case ordering (common cases first, fallbacks last).
67
+
68
+ To use a custom level, import the corresponding creator and pass an options object:
46
69
 
47
70
  ```js
48
71
  // eslint.config.js
49
72
  import { createTypescriptConfig } from '@slango.configs/eslint/typescript.js';
50
73
 
51
- export default createTypescriptConfig({ perfectionist: 'strict' });
74
+ export default createTypescriptConfig({ perfectionist: 'moderate' });
52
75
  ```
53
76
 
77
+ Passing an unknown option or an invalid level throws a descriptive error.
78
+
54
79
  ## Things to take into account (and possibly review)
55
80
 
56
81
  - At the time of writing eslint-config-next is not compatible with eslint 9, thus @eslint/compat and @eslint/eslintrc are used
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slango.configs/eslint",
3
- "version": "1.1.42",
3
+ "version": "1.1.43",
4
4
  "private": false,
5
5
  "description": "Slango eslint configs",
6
6
  "type": "module",
package/src/common.js CHANGED
@@ -22,7 +22,8 @@ export const commonConfigs = (files) => {
22
22
  eslintJs.configs.recommended,
23
23
  eslintPluginImportX.flatConfigs.recommended,
24
24
  comments.recommended,
25
- perfectionistPlugin.configs['recommended-natural'],
25
+ // Perfectionist plugin only (no preset) - rules configured via perfectionistLevels
26
+ { plugins: { perfectionist: perfectionistPlugin } },
26
27
  prettierPluginRecommendedConfig,
27
28
  regexPluginConfigs['flat/recommended'],
28
29
  ];
@@ -30,26 +31,132 @@ export const commonConfigs = (files) => {
30
31
  return configs.flatMap((config) => applyFilesGlob(normalizeConfig(config), files));
31
32
  };
32
33
 
33
- const sortModulesRule = ['error', { partitionByNewLine: true }];
34
-
34
+ // Common rule configurations
35
+ const naturalSort = { type: 'natural', order: 'asc' };
36
+ const sortModulesRule = ['error', { ...naturalSort, partitionByNewLine: true }];
37
+ const sortRule = ['error', naturalSort];
38
+
39
+ /**
40
+ * Perfectionist strictness levels:
41
+ *
42
+ * - off: All perfectionist rules disabled
43
+ * - relaxed (default): Core import/export sorting only - universally accepted rules
44
+ * - moderate: Adds type sorting (interfaces, unions, enums) - good for type-heavy codebases
45
+ * - strict: Full sorting including objects, classes, JSX props, switch cases, etc.
46
+ *
47
+ * Rules are organized in tiers:
48
+ * - Tier 1 (relaxed+): Import/export sorting - industry standard, high value
49
+ * - Tier 2 (moderate+): Type-related sorting - consistency for TypeScript
50
+ * - Tier 3 (strict only): Everything else - can be controversial or break intentional ordering
51
+ */
35
52
  export const perfectionistLevels = {
36
53
  off: {
37
- 'perfectionist/sort-enums': 'off',
54
+ // Tier 1: Import/export sorting - ALL OFF
55
+ 'perfectionist/sort-imports': 'off',
56
+ 'perfectionist/sort-named-imports': 'off',
57
+ 'perfectionist/sort-named-exports': 'off',
58
+ 'perfectionist/sort-exports': 'off',
59
+ 'perfectionist/sort-import-attributes': 'off',
60
+ 'perfectionist/sort-export-attributes': 'off',
38
61
  'perfectionist/sort-modules': 'off',
62
+ // Tier 2: Type sorting - ALL OFF
63
+ 'perfectionist/sort-union-types': 'off',
64
+ 'perfectionist/sort-intersection-types': 'off',
65
+ 'perfectionist/sort-heritage-clauses': 'off',
39
66
  'perfectionist/sort-object-types': 'off',
67
+ 'perfectionist/sort-interfaces': 'off',
68
+ 'perfectionist/sort-enums': 'off',
69
+ // Tier 3: Controversial sorting - ALL OFF
40
70
  'perfectionist/sort-objects': 'off',
71
+ 'perfectionist/sort-classes': 'off',
72
+ 'perfectionist/sort-jsx-props': 'off',
73
+ 'perfectionist/sort-decorators': 'off',
74
+ 'perfectionist/sort-switch-case': 'off',
75
+ 'perfectionist/sort-variable-declarations': 'off',
76
+ 'perfectionist/sort-array-includes': 'off',
77
+ 'perfectionist/sort-sets': 'off',
78
+ 'perfectionist/sort-maps': 'off',
41
79
  },
42
80
  relaxed: {
43
- 'perfectionist/sort-enums': 'off',
81
+ // Tier 1: Import/export sorting - ENABLED (industry standard)
82
+ 'perfectionist/sort-imports': sortRule,
83
+ 'perfectionist/sort-named-imports': sortRule,
84
+ 'perfectionist/sort-named-exports': sortRule,
85
+ 'perfectionist/sort-exports': sortRule,
86
+ 'perfectionist/sort-import-attributes': sortRule,
87
+ 'perfectionist/sort-export-attributes': sortRule,
44
88
  'perfectionist/sort-modules': sortModulesRule,
89
+ // Tier 2: Type sorting - OFF
90
+ 'perfectionist/sort-union-types': 'off',
91
+ 'perfectionist/sort-intersection-types': 'off',
92
+ 'perfectionist/sort-heritage-clauses': 'off',
45
93
  'perfectionist/sort-object-types': 'off',
94
+ 'perfectionist/sort-interfaces': 'off',
95
+ 'perfectionist/sort-enums': 'off',
96
+ // Tier 3: Controversial sorting - OFF
97
+ 'perfectionist/sort-objects': 'off',
98
+ 'perfectionist/sort-classes': 'off',
99
+ 'perfectionist/sort-jsx-props': 'off',
100
+ 'perfectionist/sort-decorators': 'off',
101
+ 'perfectionist/sort-switch-case': 'off',
102
+ 'perfectionist/sort-variable-declarations': 'off',
103
+ 'perfectionist/sort-array-includes': 'off',
104
+ 'perfectionist/sort-sets': 'off',
105
+ 'perfectionist/sort-maps': 'off',
106
+ },
107
+ moderate: {
108
+ // Tier 1: Import/export sorting - ENABLED
109
+ 'perfectionist/sort-imports': sortRule,
110
+ 'perfectionist/sort-named-imports': sortRule,
111
+ 'perfectionist/sort-named-exports': sortRule,
112
+ 'perfectionist/sort-exports': sortRule,
113
+ 'perfectionist/sort-import-attributes': sortRule,
114
+ 'perfectionist/sort-export-attributes': sortRule,
115
+ 'perfectionist/sort-modules': sortModulesRule,
116
+ // Tier 2: Type sorting - ENABLED (good for TypeScript codebases)
117
+ 'perfectionist/sort-union-types': sortRule,
118
+ 'perfectionist/sort-intersection-types': sortRule,
119
+ 'perfectionist/sort-heritage-clauses': sortRule,
120
+ 'perfectionist/sort-object-types': sortRule,
121
+ 'perfectionist/sort-interfaces': sortRule,
122
+ 'perfectionist/sort-enums': sortRule,
123
+ // Tier 3: Controversial sorting - OFF
46
124
  'perfectionist/sort-objects': 'off',
125
+ 'perfectionist/sort-classes': 'off',
126
+ 'perfectionist/sort-jsx-props': 'off',
127
+ 'perfectionist/sort-decorators': 'off',
128
+ 'perfectionist/sort-switch-case': 'off',
129
+ 'perfectionist/sort-variable-declarations': 'off',
130
+ 'perfectionist/sort-array-includes': 'off',
131
+ 'perfectionist/sort-sets': 'off',
132
+ 'perfectionist/sort-maps': 'off',
47
133
  },
48
134
  strict: {
49
- 'perfectionist/sort-enums': 'error',
135
+ // Tier 1: Import/export sorting - ENABLED
136
+ 'perfectionist/sort-imports': sortRule,
137
+ 'perfectionist/sort-named-imports': sortRule,
138
+ 'perfectionist/sort-named-exports': sortRule,
139
+ 'perfectionist/sort-exports': sortRule,
140
+ 'perfectionist/sort-import-attributes': sortRule,
141
+ 'perfectionist/sort-export-attributes': sortRule,
50
142
  'perfectionist/sort-modules': sortModulesRule,
51
- 'perfectionist/sort-object-types': 'error',
52
- 'perfectionist/sort-objects': 'error',
143
+ // Tier 2: Type sorting - ENABLED
144
+ 'perfectionist/sort-union-types': sortRule,
145
+ 'perfectionist/sort-intersection-types': sortRule,
146
+ 'perfectionist/sort-heritage-clauses': sortRule,
147
+ 'perfectionist/sort-object-types': sortRule,
148
+ 'perfectionist/sort-interfaces': sortRule,
149
+ 'perfectionist/sort-enums': sortRule,
150
+ // Tier 3: Full sorting - ENABLED (use with caution)
151
+ 'perfectionist/sort-objects': sortRule,
152
+ 'perfectionist/sort-classes': sortRule,
153
+ 'perfectionist/sort-jsx-props': sortRule,
154
+ 'perfectionist/sort-decorators': sortRule,
155
+ 'perfectionist/sort-switch-case': sortRule,
156
+ 'perfectionist/sort-variable-declarations': sortRule,
157
+ 'perfectionist/sort-array-includes': sortRule,
158
+ 'perfectionist/sort-sets': sortRule,
159
+ 'perfectionist/sort-maps': sortRule,
53
160
  },
54
161
  };
55
162