@dsivd/prestations-ng 19.2.0-beta.7 → 19.2.0-beta.9

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/CHANGELOG.md CHANGED
@@ -8,6 +8,32 @@
8
8
 
9
9
  ## [19.2.0] - should be aligned with prestations-be 19.2.x
10
10
 
11
+ ### Added
12
+
13
+ - [eslint/configs/spec-ts-recommended.mjs](projects/prestations-ng/src/eslint/configs/spec-ts-recommended.mjs)
14
+ - New `prestationsNg.configs.specTsRecommended` ESLint config for the Vitest specs, to use in the `extends` of a
15
+ `**/*.spec.ts` block: the `recommended` config of `@vitest/eslint-plugin`, which also counts the assertions of
16
+ the `HttpTestingController` and of the helpers of the specs. It needs `@vitest/eslint-plugin` in the
17
+ devDependencies of your project, only when you use it. See
18
+ [UPGRADING_V19.md](UPGRADING_V19.md#migrate-to-eslint-flat-configuration).
19
+ - [foehn-bo-multi-upload.component.ts](projects/prestations-ng/src/foehn-upload/foehn-bo-multi-upload/foehn-bo-multi-upload.component.ts)
20
+ - New `localUpload` input. When set to `true`, selected files are kept purely local
21
+ (as `DocumentReferenceWithFile`, no `uploadUrl()` call) so they can be cancelled before
22
+ being sent. Files show up immediately in the list with a "pending" indicator (dictionary
23
+ key `foehn-uploader.pending-label`, French default provided) since they're not uploaded
24
+ yet. It is your responsibility to upload/delete them at save time,
25
+ e.g. via the new
26
+ [document-changes.helper.ts](projects/prestations-ng/src/foehn-upload/document-changes.helper.ts)
27
+ (`splitDocumentChanges`) which computes `filesToAdd`/`documentsToDelete` from the model.
28
+ - The default (direct upload) mode is unchanged.
29
+ - New `maxFileSizeInMo` input: a client-side, per-file size limit that doesn't depend on
30
+ the `fileMaxSizeInBytesByFormKey` server configuration (useful for consumers that don't
31
+ expose that config yet). When both are set, the smallest limit applies. A file too big gets
32
+ the usual `413` error, which can be customized with `customErrors` (`{fileName}`,
33
+ `{fileMaxSize}`).
34
+ - New `chooseButtonStyleModifier` input, appended to the choose button's CSS classes
35
+ (e.g. `btn-sm`), mirroring the same input already available on other uploaders.
36
+
11
37
  ### Changed
12
38
 
13
39
  Library now runs as strict mode, which may cause some errors to appear in your project after updating.
@@ -41,7 +67,7 @@ Please check the [UPGRADING_V19.md](UPGRADING_V19.md) guide for more information
41
67
  (_read-only_), `timeslotRemaining` (_read-only_), `canClose` (_read-only_)
42
68
  - `foehn-autocomplete`: `searchValue`, `inputHasFocus`, `hideSuggestions`, `displayedElements`,
43
69
  `notificationMessageUpdated`, `VIEW_PORT_HEIGHT` (_read-only_)
44
- - `foehn-multiselect-autocomplete`: `autocompleteInputValue`, `showEmptyListMessage`, `srAnnouncements`
70
+ - `foehn-multiselect-autocomplete`: `autocompleteInputValue`, `showEmptyListMessage` (_read-only_), `srAnnouncements`
45
71
  - `foehn-select`, `foehn-radio`, `foehn-checkbox` and the autocompletes (`FoehnCheckableGroupComponent`):
46
72
  `groupedElements`
47
73
  - `foehn-radio`: `inputValue`
@@ -98,6 +124,11 @@ Please check the [UPGRADING_V19.md](UPGRADING_V19.md) guide for more information
98
124
 
99
125
  ### Fixed
100
126
 
127
+ - `foehn-multiselect-autocomplete`: the suggestions and the message displayed once every element is selected follow a
128
+ model changed by the project, not only by the user. Once every element was selected, a model set back to some of
129
+ them kept the message and the hidden input; a model selecting every element did not display the message; the
130
+ suggestions still contained the elements selected by the project. An empty list of elements no longer displays
131
+ the message (every element of the list has already been added).
101
132
  - `providePrestationsNgCore()` registers again the HTTP interceptors lost with `FoehnPageModule` in 19.0.0: the
102
133
  `foehn-transmit-waiting-modal` is displayed again during a long transmission, the warning before the expiration of
103
134
  the session receives its date again, and a new version of the application deployed meanwhile is detected again.
package/CONTRIBUTING.md CHANGED
@@ -94,9 +94,10 @@ This project uses a set of scripts to lint and format the code, along with pre-c
94
94
 
95
95
  Important scripts are :
96
96
 
97
- - `npm run lint` : run ESLint and Prettier on all files
97
+ - `npm run lint` : run ESLint and Prettier on all files, and check the types of the TypeScript files compiled by no
98
+ build (`lint:types`: `cypress/`, which Cypress only transpiles, and the configuration files of `tsconfig.config.json`)
98
99
  - `npm run format`: run ESLint and Prettier on all files and fix errors automatically
99
- - `npm run validate`: clean and run all tests
100
+ - `npm run validate`: clean, lint and run all tests
100
101
 
101
102
  **Husky** is used as a pre-commit hook to automatically output linting and formatting errors for staged files before committing.
102
103
  In the end, this utilitary calls `npm run lint-staged` which you can also call yourself of course. To have this pre-commit hook,
package/UPGRADING_V19.md CHANGED
@@ -1064,6 +1064,8 @@ npm install --save-dev eslint-plugin-simple-import-sort@13
1064
1064
  npm install --save-dev eslint-config-prettier@10
1065
1065
  npm install --save-dev eslint-plugin-import-x@4
1066
1066
  npm install --save-dev prettier
1067
+ # only if your project has Vitest specs (see "Migrate to vitest")
1068
+ npm install --save-dev @vitest/eslint-plugin@1
1067
1069
  ```
1068
1070
 
1069
1071
  In your `front` folder, add a `.prettierrc` file with the following content:
@@ -1140,6 +1142,12 @@ export default tseslint.config(
1140
1142
  extends: [...prestationsNg.configs.templateRecommended],
1141
1143
  },
1142
1144
 
1145
+ // ─── Vitest specs (only if your project has Vitest specs) ─────────────────
1146
+ {
1147
+ files: ['**/*.spec.ts'],
1148
+ extends: [...prestationsNg.configs.specTsRecommended],
1149
+ },
1150
+
1143
1151
  // ─── Prettier (must be last — disables formatting rules) ───────────────────
1144
1152
  prettier,
1145
1153
  );
@@ -1150,6 +1158,11 @@ everything: the `eslint`, `typescript-eslint` and `angular-eslint` baselines, th
1150
1158
  accessibility set, the naming and import conventions, and the rules written by the library
1151
1159
  itself. You declare no `plugins` and list no rule.
1152
1160
 
1161
+ `specTsRecommended` is the `recommended` config of `@vitest/eslint-plugin`, which also counts the assertions
1162
+ made by the `HttpTestingController` (`expectOne`, `expectNone`, `verify`) and by helpers named `expect*`,
1163
+ `assert*` or `test*`. The `**/*.spec.ts` pattern does not reach the Cypress `*.spec.cy.ts` files. It needs
1164
+ `@vitest/eslint-plugin` only when you use it: the other configs work without it.
1165
+
1153
1166
  The packages installed above are still required — the library's config imports them from your
1154
1167
  `node_modules` rather than shipping its own copies. For the same reason, do **not** spread
1155
1168
  `angular.configs.tsRecommended` or `angular.configs.templateRecommended` yourself: they are
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The house preset of the Vitest specs: the recommended rules of `@vitest/eslint-plugin`, with the
3
+ * assertions also made by the helpers of the specs and by the `HttpTestingController`.
4
+ *
5
+ * Meant for the `extends` of a `**\/*.spec.ts` block (the Cypress `*.spec.cy.ts` files are not
6
+ * Vitest specs).
7
+ *
8
+ * @param {import('@vitest/eslint-plugin').default} vitest the `@vitest/eslint-plugin` module
9
+ * @returns {import('typescript-eslint').ConfigArray}
10
+ */
11
+ const specTsRecommended = (vitest) => [
12
+ vitest.configs.recommended,
13
+ {
14
+ name: 'prestations-ng/spec-ts-recommended',
15
+ rules: {
16
+ 'vitest/expect-expect': [
17
+ 'error',
18
+ {
19
+ assertFunctionNames: [
20
+ 'expect',
21
+ 'expect*',
22
+ 'assert*',
23
+ 'test*',
24
+ '*.expectOne',
25
+ '*.expectNone',
26
+ '*.verify',
27
+ ],
28
+ },
29
+ ],
30
+ },
31
+ },
32
+ ];
33
+
34
+ export default specTsRecommended;
package/eslint/index.mjs CHANGED
@@ -1,9 +1,17 @@
1
+ import specTsRecommended from './configs/spec-ts-recommended.mjs';
1
2
  import templateRecommended from './configs/template-recommended.mjs';
2
3
  import templateRules from './configs/template-rules.mjs';
3
4
  import tsRecommended from './configs/ts-recommended.mjs';
4
5
  import tsRules from './configs/ts-rules.mjs';
5
6
  import rules from './rules/index.mjs';
6
7
 
8
+ // Only needed by the projects linting Vitest specs: the other configs can be used without it.
9
+ const vitest = await import('@vitest/eslint-plugin').then(
10
+ (module) => module.default,
11
+ () => null,
12
+ );
13
+ const specTsRecommendedConfig = vitest ? specTsRecommended(vitest) : null;
14
+
7
15
  const plugin = {
8
16
  meta: { name: '@dsivd/prestations-ng' },
9
17
  rules,
@@ -16,6 +24,15 @@ const configs = {
16
24
  // Only this library's own rules, for a project that supplies its own style.
17
25
  tsRules: tsRules(plugin),
18
26
  templateRules: templateRules(plugin),
27
+ // The preset of the Vitest specs (needs @vitest/eslint-plugin)
28
+ get specTsRecommended() {
29
+ if (!specTsRecommendedConfig) {
30
+ throw new Error(
31
+ 'prestationsNg.configs.specTsRecommended needs @vitest/eslint-plugin: npm install --save-dev @vitest/eslint-plugin@1',
32
+ );
33
+ }
34
+ return specTsRecommendedConfig;
35
+ },
19
36
  };
20
37
 
21
38
  export { configs, plugin, rules };