@dsivd/prestations-ng 19.0.6 → 19.0.8-beta.1

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 (36) hide show
  1. package/CHANGELOG.md +37 -4
  2. package/CONTRIBUTING.md +3 -2
  3. package/ESLINT_PLUGIN.md +170 -35
  4. package/UPGRADING_V19.md +22 -145
  5. package/dsivd-prestations-ng-19.0.8-beta.1.tgz +0 -0
  6. package/eslint/component-path.mjs +15 -0
  7. package/eslint/configs/template-base.mjs +2 -2
  8. package/eslint/configs/template-recommended.mjs +15 -6
  9. package/eslint/configs/template-rules.mjs +17 -0
  10. package/eslint/configs/ts-base.mjs +2 -2
  11. package/eslint/configs/ts-recommended.mjs +133 -3
  12. package/eslint/configs/ts-rules.mjs +14 -0
  13. package/eslint/index.mjs +10 -4
  14. package/eslint/rules/no-direct-signal-mutation.mjs +370 -142
  15. package/eslint/rules/no-uninvoked-signal-in-template.mjs +1 -12
  16. package/eslint/signal-kinds.mjs +57 -0
  17. package/eslint/signal-names.mjs +43 -49
  18. package/fesm2022/dsivd-prestations-ng.mjs +487 -487
  19. package/fesm2022/dsivd-prestations-ng.mjs.map +1 -1
  20. package/package.json +1 -1
  21. package/src/eslint/component-path.mjs +15 -0
  22. package/src/eslint/configs/__tests__/configs.test.mjs +113 -48
  23. package/src/eslint/configs/template-base.mjs +2 -2
  24. package/src/eslint/configs/template-recommended.mjs +15 -6
  25. package/src/eslint/configs/template-rules.mjs +17 -0
  26. package/src/eslint/configs/ts-base.mjs +2 -2
  27. package/src/eslint/configs/ts-recommended.mjs +133 -3
  28. package/src/eslint/configs/ts-rules.mjs +14 -0
  29. package/src/eslint/index.mjs +10 -4
  30. package/src/eslint/rules/__tests__/no-direct-signal-mutation.test.mjs +365 -128
  31. package/src/eslint/rules/no-direct-signal-mutation.mjs +370 -142
  32. package/src/eslint/rules/no-uninvoked-signal-in-template.mjs +1 -12
  33. package/src/eslint/signal-kinds.mjs +57 -0
  34. package/src/eslint/signal-names.mjs +43 -49
  35. package/types/dsivd-prestations-ng.d.ts +0 -1
  36. package/dsivd-prestations-ng-19.0.6.tgz +0 -0
@@ -1,6 +1,6 @@
1
1
  // Registers the plugin without enabling any rule. Meant to be used through
2
- // `tsRecommended`, inside the `extends` of a block that already targets `**/*.ts`
3
- // and sets the TypeScript parser.
2
+ // `tsRules` or `tsRecommended`, inside the `extends` of a block that already
3
+ // targets `**/*.ts` and sets the TypeScript parser.
4
4
  const tsBase = (plugin) => ({
5
5
  name: 'prestations-ng/ts-base',
6
6
  plugins: {
@@ -1,11 +1,141 @@
1
- import tsBase from './ts-base.mjs';
1
+ import eslint from '@eslint/js';
2
+ import rxjs from '@smarttools/eslint-plugin-rxjs';
3
+ import angular from 'angular-eslint';
4
+ import importX from 'eslint-plugin-import-x';
5
+ import simpleImportSort from 'eslint-plugin-simple-import-sort';
6
+ import tseslint from 'typescript-eslint';
2
7
 
8
+ import tsRules from './ts-rules.mjs';
9
+
10
+ /**
11
+ * The house TypeScript preset: the shared baselines, this library's own rules, and the
12
+ * conventions every prestations-ng project follows.
13
+ *
14
+ * Meant for the `extends` of a `**\/*.ts` block. It brings its own parser and plugins,
15
+ * so do not spread `angular.configs.tsRecommended` alongside it — declaring the same
16
+ * plugin twice from two different copies makes ESLint fail outright.
17
+ */
3
18
  const tsRecommended = (plugin) => [
4
- tsBase(plugin),
19
+ eslint.configs.recommended,
20
+ ...tseslint.configs.recommended, // covers: no-explicit-any, ban-ts-comment,
21
+ // no-unused-expressions, no-var, no-unused-vars…
22
+ ...tseslint.configs.stylistic, // covers: array-type, consistent-type-assertions,
23
+ // dot-notation, no-inferrable-types (default options),
24
+ // no-empty-function (error), prefer-for-of,
25
+ // prefer-function-type…
26
+ ...angular.configs.tsRecommended, // covers: prefer-inject, no-empty-lifecycle-method,
27
+ // use-lifecycle-interface…
28
+ ...tsRules(plugin),
5
29
  {
6
30
  name: 'prestations-ng/ts-recommended',
31
+ plugins: {
32
+ rxjs,
33
+ 'simple-import-sort': simpleImportSort,
34
+ 'import-x': importX,
35
+ },
7
36
  rules: {
8
- '@dsivd/prestations-ng/no-direct-signal-mutation': 'error',
37
+ // ── @angular-eslint ──────────────────────────────────────────────
38
+ '@angular-eslint/component-selector': [
39
+ 'error',
40
+ {
41
+ type: 'element',
42
+ prefix: 'app',
43
+ style: 'kebab-case',
44
+ },
45
+ ],
46
+ '@angular-eslint/directive-selector': [
47
+ 'error',
48
+ {
49
+ type: 'attribute',
50
+ prefix: 'app',
51
+ style: 'camelCase',
52
+ },
53
+ ],
54
+ '@angular-eslint/no-uncalled-signals': ['error'],
55
+ '@angular-eslint/prefer-signal-model': ['error'],
56
+ '@angular-eslint/prefer-signals': ['error'],
57
+
58
+ // ── @typescript-eslint ───────────────────────────────────────────
59
+ '@typescript-eslint/explicit-function-return-type': [
60
+ 'error',
61
+ {
62
+ allowExpressions: true,
63
+ allowTypedFunctionExpressions: true,
64
+ allowHigherOrderFunctions: true,
65
+ allowDirectConstAssertionInArrowFunctions: true,
66
+ },
67
+ ],
68
+ '@typescript-eslint/explicit-member-accessibility': [
69
+ 'error',
70
+ { accessibility: 'no-public' },
71
+ ],
72
+ '@typescript-eslint/member-ordering': 'error',
73
+ '@typescript-eslint/no-base-to-string': 'warn',
74
+ // stylistic enables no-inferrable-types with default options (ignoreParameters: false);
75
+ // override here to allow typed parameters explicitly
76
+ '@typescript-eslint/no-inferrable-types': [
77
+ 'error',
78
+ { ignoreParameters: true },
79
+ ],
80
+ // stylistic sets no-empty-function to error; downgrade to warn
81
+ '@typescript-eslint/no-empty-function': 'warn',
82
+ '@typescript-eslint/prefer-includes': 'warn',
83
+ '@typescript-eslint/return-await': ['error', 'never'],
84
+ '@typescript-eslint/typedef': ['error', { parameter: true }],
85
+ '@typescript-eslint/unified-signatures': 'error',
86
+ // off here — @typescript-eslint/no-shadow handles it correctly for TS
87
+ 'no-shadow': 'off',
88
+ '@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
89
+ '@typescript-eslint/no-unused-vars': [
90
+ 'error',
91
+ {
92
+ varsIgnorePattern: '^_',
93
+ argsIgnorePattern: '^_',
94
+ caughtErrorsIgnorePattern: '^_',
95
+ },
96
+ ],
97
+
98
+ // ── eslint core ──────────────────────────────────────────────────
99
+ 'arrow-body-style': 'error',
100
+ 'arrow-parens': ['error', 'as-needed'],
101
+ curly: 'error',
102
+ eqeqeq: ['error', 'always'],
103
+ 'guard-for-in': 'error',
104
+ 'no-bitwise': 'error',
105
+ 'no-caller': 'error',
106
+ 'no-console': ['error', { allow: ['log', 'warn', 'error'] }],
107
+ 'no-eval': 'error',
108
+ 'no-extra-boolean-cast': 'off',
109
+ 'no-multiple-empty-lines': 'error',
110
+ 'no-new-wrappers': 'error',
111
+ 'no-restricted-imports': [
112
+ 'error',
113
+ { paths: ['rxjs/Rx', 'primeng/primeng', 'primeng'] },
114
+ ],
115
+ 'no-return-assign': 'error',
116
+ 'no-throw-literal': 'error',
117
+ 'no-undef-init': 'error',
118
+ 'no-useless-concat': 'error',
119
+ 'object-shorthand': ['error', 'always', { avoidQuotes: true }],
120
+ 'one-var': ['error', 'never'],
121
+ 'prefer-arrow-callback': 'error',
122
+ 'prefer-template': 'error',
123
+ radix: 'error',
124
+
125
+ // ── rxjs ─────────────────────────────────────────────────────────
126
+ 'rxjs/no-implicit-any-catch': ['error', { allowExplicitAny: true }],
127
+ 'rxjs/no-sharereplay': 'off',
128
+
129
+ // ── import-x ─────────────────────────────────────────────────────
130
+ 'import-x/no-cycle': ['warn', { maxDepth: 3, ignoreExternal: true }],
131
+ 'import-x/no-deprecated': 'warn',
132
+ 'import-x/first': 'error',
133
+ 'import-x/newline-after-import': 'error',
134
+ 'import-x/no-duplicates': 'error',
135
+
136
+ // ── simple-import-sort ───────────────────────────────────────────
137
+ 'simple-import-sort/imports': 'error',
138
+ 'simple-import-sort/exports': 'error',
9
139
  },
10
140
  },
11
141
  ];
@@ -0,0 +1,14 @@
1
+ import tsBase from './ts-base.mjs';
2
+
3
+ // Only the rules written by this library. `tsRecommended` includes it, alongside the
4
+ // house style; use this layer directly to opt out of the latter.
5
+ const tsRules = (plugin) => [
6
+ tsBase(plugin),
7
+ {
8
+ name: 'prestations-ng/ts-rules',
9
+ rules: {
10
+ '@dsivd/prestations-ng/no-direct-signal-mutation': 'error',
11
+ },
12
+ },
13
+ ];
14
+ export default tsRules;
package/eslint/index.mjs CHANGED
@@ -1,15 +1,21 @@
1
1
  import templateRecommended from './configs/template-recommended.mjs';
2
+ import templateRules from './configs/template-rules.mjs';
2
3
  import tsRecommended from './configs/ts-recommended.mjs';
4
+ import tsRules from './configs/ts-rules.mjs';
3
5
  import rules from './rules/index.mjs';
4
6
 
5
7
  const plugin = {
6
- meta: { name: '@dsivd/prestations-ng' },
7
- rules,
8
+ meta: { name: '@dsivd/prestations-ng' },
9
+ rules,
8
10
  };
9
11
 
10
12
  const configs = {
11
- tsRecommended: tsRecommended(plugin),
12
- templateRecommended: templateRecommended(plugin),
13
+ // The house presets: baselines, this library's rules, and the shared conventions.
14
+ tsRecommended: tsRecommended(plugin),
15
+ templateRecommended: templateRecommended(plugin),
16
+ // Only this library's own rules, for a project that supplies its own style.
17
+ tsRules: tsRules(plugin),
18
+ templateRules: templateRules(plugin),
13
19
  };
14
20
 
15
21
  export { configs, plugin, rules };