@dsivd/prestations-ng 19.2.0-beta.8 → 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 +15 -6
- package/UPGRADING_V19.md +13 -0
- package/dsivd-prestations-ng-19.2.0-beta.9.tgz +0 -0
- package/eslint/configs/spec-ts-recommended.mjs +34 -0
- package/eslint/index.mjs +17 -0
- package/fesm2022/dsivd-prestations-ng.mjs +79 -102
- package/fesm2022/dsivd-prestations-ng.mjs.map +1 -1
- package/package.json +1 -1
- package/src/eslint/configs/__tests__/configs.test.mjs +46 -2
- package/src/eslint/configs/spec-ts-recommended.mjs +34 -0
- package/src/eslint/index.mjs +17 -0
- package/types/dsivd-prestations-ng.d.ts +23 -11
- package/dsivd-prestations-ng-19.2.0-beta.8.tgz +0 -0
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import vitest from '@vitest/eslint-plugin';
|
|
1
2
|
import { builtinRules } from 'eslint/use-at-your-own-risk';
|
|
2
3
|
import { describe, expect, it } from 'vitest';
|
|
3
4
|
|
|
@@ -6,6 +7,10 @@ import prestationsNg, { configs, plugin, rules } from '../../index.mjs';
|
|
|
6
7
|
const PLUGIN_KEY = '@dsivd/prestations-ng';
|
|
7
8
|
|
|
8
9
|
const configNames = Object.keys(configs);
|
|
10
|
+
// The configs of this library's plugin (the preset of the Vitest specs only configures @vitest/eslint-plugin)
|
|
11
|
+
const pluginConfigNames = configNames.filter(
|
|
12
|
+
(name) => name !== 'specTsRecommended',
|
|
13
|
+
);
|
|
9
14
|
|
|
10
15
|
// Configs that only register this library's rules, and the presets built on top of them.
|
|
11
16
|
const RULE_LAYERS = ['tsRules', 'templateRules'];
|
|
@@ -52,6 +57,7 @@ describe('eslint configs', () => {
|
|
|
52
57
|
'templateRecommended',
|
|
53
58
|
'tsRules',
|
|
54
59
|
'templateRules',
|
|
60
|
+
'specTsRecommended',
|
|
55
61
|
]);
|
|
56
62
|
});
|
|
57
63
|
|
|
@@ -88,7 +94,7 @@ describe('eslint configs', () => {
|
|
|
88
94
|
|
|
89
95
|
// Two entries declaring the same plugin key from different copies is a hard ESLint
|
|
90
96
|
// failure, so the preset must register ours exactly once.
|
|
91
|
-
it.each(
|
|
97
|
+
it.each(pluginConfigNames)('%s should register the plugin once', (name) => {
|
|
92
98
|
const declarations = configs[name]
|
|
93
99
|
.map((entry) => entry.plugins?.[PLUGIN_KEY])
|
|
94
100
|
.filter(Boolean);
|
|
@@ -101,7 +107,9 @@ describe('eslint configs', () => {
|
|
|
101
107
|
});
|
|
102
108
|
|
|
103
109
|
it('should enable every rule in at least one config', () => {
|
|
104
|
-
const enabled = new Set(
|
|
110
|
+
const enabled = new Set(
|
|
111
|
+
pluginConfigNames.flatMap((n) => ownIdsOf(configs[n])),
|
|
112
|
+
);
|
|
105
113
|
|
|
106
114
|
for (const ruleName of Object.keys(rules)) {
|
|
107
115
|
expect(enabled).toContain(`${PLUGIN_KEY}/${ruleName}`);
|
|
@@ -118,6 +126,42 @@ describe('eslint configs', () => {
|
|
|
118
126
|
);
|
|
119
127
|
});
|
|
120
128
|
|
|
129
|
+
describe('specTsRecommended', () => {
|
|
130
|
+
const rulesOf = (config) =>
|
|
131
|
+
Object.assign({}, ...config.map((entry) => entry.rules ?? {}));
|
|
132
|
+
|
|
133
|
+
it('should build on the recommended config of @vitest/eslint-plugin', () => {
|
|
134
|
+
expect(configs.specTsRecommended[0]).toBe(vitest.configs.recommended);
|
|
135
|
+
expect(pluginsOf(configs.specTsRecommended)).toEqual({ vitest });
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should count the assertions of the helpers and of the HttpTestingController', () => {
|
|
139
|
+
const [, options] = rulesOf(configs.specTsRecommended)[
|
|
140
|
+
'vitest/expect-expect'
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
expect(options.assertFunctionNames).toEqual(
|
|
144
|
+
expect.arrayContaining([
|
|
145
|
+
'expect',
|
|
146
|
+
'expect*',
|
|
147
|
+
'*.expectOne',
|
|
148
|
+
'*.verify',
|
|
149
|
+
]),
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// An expect which may not run lets a test pass without asserting anything
|
|
154
|
+
it('should keep vitest/no-conditional-expect enabled', () => {
|
|
155
|
+
expect(
|
|
156
|
+
isOff(
|
|
157
|
+
rulesOf(configs.specTsRecommended)[
|
|
158
|
+
'vitest/no-conditional-expect'
|
|
159
|
+
],
|
|
160
|
+
),
|
|
161
|
+
).toBe(false);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
121
165
|
describe('eslint plugin', () => {
|
|
122
166
|
it('should be named after the npm package', () => {
|
|
123
167
|
expect(plugin.meta.name).toBe(PLUGIN_KEY);
|
|
@@ -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/src/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 };
|
|
@@ -1591,15 +1591,20 @@ declare class FoehnMultiselectAutocompleteComponent extends FoehnAutocompleteCom
|
|
|
1591
1591
|
readonly defaultDeleteFocusArea: _angular_core.Signal<ElementRef<any> | undefined>;
|
|
1592
1592
|
readonly defaultElementValuesComputed: _angular_core.Signal<unknown[]>;
|
|
1593
1593
|
readonly autocompleteInputValue: _angular_core.WritableSignal<string | null>;
|
|
1594
|
-
|
|
1594
|
+
/**
|
|
1595
|
+
* Every element is selected: a message replaces the autocomplete (not for an empty list of elements).
|
|
1596
|
+
*/
|
|
1597
|
+
readonly showEmptyListMessage: _angular_core.Signal<boolean>;
|
|
1595
1598
|
readonly srAnnouncements: _angular_core.WritableSignal<string>;
|
|
1599
|
+
protected readonly suggestions: _angular_core.Signal<[]>;
|
|
1596
1600
|
private readonly dictionaryService;
|
|
1597
1601
|
private srAnnouncementClearTimer;
|
|
1598
1602
|
private readonly SR_ANNOUNCEMENT_CLEAR_TIMEOUT_INTERVAL_MS;
|
|
1599
1603
|
private pendingRemovedIndexForFocus;
|
|
1604
|
+
private readonly suggestionsEffect;
|
|
1605
|
+
private readonly autocompleteInputVisibilityEffect;
|
|
1600
1606
|
private readonly selectedElemRefEffect;
|
|
1601
1607
|
ngOnInit(): void;
|
|
1602
|
-
onModelChange(value: any): void;
|
|
1603
1608
|
hasErrorsToDisplay(): boolean;
|
|
1604
1609
|
getLabel(value: any): string | null | undefined;
|
|
1605
1610
|
updateMultiselectAutocomplete(currentModel: unknown[]): void;
|
|
@@ -1608,18 +1613,16 @@ declare class FoehnMultiselectAutocompleteComponent extends FoehnAutocompleteCom
|
|
|
1608
1613
|
removeItem(item: unknown, index: number): void;
|
|
1609
1614
|
trackByFn(index: number): number;
|
|
1610
1615
|
canBeDeleted(index: number): boolean;
|
|
1611
|
-
onAutocompleteElementsLoaded(
|
|
1616
|
+
onAutocompleteElementsLoaded(): void;
|
|
1612
1617
|
getDeleteButtonAriaLabel(element: unknown): string;
|
|
1613
1618
|
hasDefaultDeleteFocusArea(): boolean;
|
|
1614
1619
|
getBadgeLabel(element: any): string;
|
|
1615
|
-
private manageListWhenElementsAreLoaded;
|
|
1616
1620
|
private findElementByModelItem;
|
|
1617
1621
|
private getValidValue;
|
|
1618
1622
|
private focusNextAreaAfterDelete;
|
|
1619
1623
|
private filterAutocompleteElements;
|
|
1620
|
-
private
|
|
1621
|
-
private
|
|
1622
|
-
private showAlertMessageAndHideAutocomplete;
|
|
1624
|
+
private focusAfterAddingAnItem;
|
|
1625
|
+
private applySuggestionsToAutocomplete;
|
|
1623
1626
|
private manageScreenReaderAnnouncement;
|
|
1624
1627
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FoehnMultiselectAutocompleteComponent, never>;
|
|
1625
1628
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FoehnMultiselectAutocompleteComponent, "foehn-multiselect-autocomplete", never, { "elementBadgeLabel": { "alias": "elementBadgeLabel"; "required": false; "isSignal": true; }; "selectedItemsListLegend": { "alias": "selectedItemsListLegend"; "required": false; "isSignal": true; }; "noElementsSelectedLabel": { "alias": "noElementsSelectedLabel"; "required": false; "isSignal": true; }; "excludeFromErrorSummary": { "alias": "excludeFromErrorSummary"; "required": false; "isSignal": true; }; "defaultElementValues": { "alias": "defaultElementValues"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
@@ -2476,13 +2479,18 @@ declare class UploaderHelper {
|
|
|
2476
2479
|
get accept(): string;
|
|
2477
2480
|
set accept(value: string);
|
|
2478
2481
|
getMaxFileSizeInBytesForFormKey(formKey: string): number | undefined | null;
|
|
2479
|
-
|
|
2482
|
+
/**
|
|
2483
|
+
* The maximum size of a file: the one of its form key (application info) and `maxFileSizeInMo` (a limit of the
|
|
2484
|
+
* component), the smallest of both.
|
|
2485
|
+
*/
|
|
2486
|
+
getMaxFileSizeInBytes(formKey: string, maxFileSizeInMo?: number): number | null;
|
|
2487
|
+
isFileTooBig(formKey: string, fileSizeInBytes: number, maxFileSizeInMo?: number): boolean;
|
|
2480
2488
|
isFileTooSmall(fileSizeInBytes: number): boolean;
|
|
2481
2489
|
isFileNameLengthValid(filename: string, overrideMaxFileNameLength?: number): boolean;
|
|
2482
2490
|
isFileNameNameValid(filename: string, overrideIllegalCharacters?: string): boolean;
|
|
2483
2491
|
getFileExtension(filename: string): string;
|
|
2484
2492
|
isFileExtensionValid(fileExtension: string, overrideAcceptedExtensions?: string): boolean;
|
|
2485
|
-
getUniqueErrorByCode(name: string, errorCode: string, fileName: string, customErrors: Record<string, string>, overrideAcceptedExtensions?: string, overrideMaxFileNameLength?: number, overrideIllegalCharacters?: string): FormError;
|
|
2493
|
+
getUniqueErrorByCode(name: string, errorCode: string, fileName: string, customErrors: Record<string, string>, overrideAcceptedExtensions?: string, overrideMaxFileNameLength?: number, overrideIllegalCharacters?: string, maxFileSizeInMo?: number): FormError;
|
|
2486
2494
|
addCustomErrorOrDefault(name: string, destinationErrors: FormError[], errorCode: string, fileName: string, customErrors: Record<string, string>, overrideAcceptedExtensions?: string, overrideMaxFileNameLength?: number, overrideIllegalCharacters?: string): void;
|
|
2487
2495
|
/**
|
|
2488
2496
|
* The default messages of the upload errors, in the current language.
|
|
@@ -2496,7 +2504,7 @@ declare class UploaderHelper {
|
|
|
2496
2504
|
* @deprecated Overwrites the given custom errors with the default messages: use `mergeCustomErrors()`.
|
|
2497
2505
|
*/
|
|
2498
2506
|
createDefaultCustomErrors(customErrors: Record<string, string>): void;
|
|
2499
|
-
getLocalErrors(name: string, files: File[], customErrors: Record<string, string>, overrideAcceptedExtensions?: string, overrideMaxFileNameLength?: number, overrideIllegalCharacters?: string): FormError[];
|
|
2507
|
+
getLocalErrors(name: string, files: File[], customErrors: Record<string, string>, overrideAcceptedExtensions?: string, overrideMaxFileNameLength?: number, overrideIllegalCharacters?: string, maxFileSizeInMo?: number): FormError[];
|
|
2500
2508
|
hasLiveUploadErrors(errors: FormError[]): boolean;
|
|
2501
2509
|
preventAndStop(event: any): void;
|
|
2502
2510
|
getAllFilesCount(data: any): string | null;
|
|
@@ -2572,6 +2580,10 @@ declare abstract class AbstractFoehnUploaderComponent<T> extends FoehnInputCompo
|
|
|
2572
2580
|
toMegaOctets(size: number): number;
|
|
2573
2581
|
hasLiveUploadErrors(): boolean;
|
|
2574
2582
|
protected removeFileOnConfirmation(document: DocumentReference | File): void;
|
|
2583
|
+
/**
|
|
2584
|
+
* A maximum size of each file, in addition to the one of its form key in the application info.
|
|
2585
|
+
*/
|
|
2586
|
+
protected getMaxFileSizeInMo(): number | undefined;
|
|
2575
2587
|
protected displayLocalErrors(files: File[]): FormError[];
|
|
2576
2588
|
protected isMaxSelectionReached(files: File[]): boolean;
|
|
2577
2589
|
protected isMaxFilesCountReached(files: File[]): boolean;
|
|
@@ -2755,9 +2767,9 @@ declare class FoehnBoMultiUploadComponent extends AbstractFoehnUploaderComponent
|
|
|
2755
2767
|
canAddMoreFiles(): boolean;
|
|
2756
2768
|
onFileChange(event: Event): void;
|
|
2757
2769
|
onDrop(event: any): void;
|
|
2770
|
+
protected getMaxFileSizeInMo(): number | undefined;
|
|
2758
2771
|
protected removeFileOnConfirmation(document: DocumentReference | File): void;
|
|
2759
2772
|
private populateFileItemList;
|
|
2760
|
-
private tooBigErrors;
|
|
2761
2773
|
private addFilesLocally;
|
|
2762
2774
|
private toPendingDocument;
|
|
2763
2775
|
private removeDocumentLocally;
|
|
Binary file
|