Skip to content

Commit

Permalink
[ngx-component-display] Ignore ModalComponent
Browse files Browse the repository at this point in the history
+ Add a message to let dev knows they have to call it maybe Dialog Or
  Modal if the component is a dialog or a modal
  • Loading branch information
k.lourenco committed Nov 10, 2023
1 parent c7120a3 commit f941ad8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ _Ensure Angular components have a display property set._

Config:

- `ignore`: classes whose names match this regular expression (defined as string) will be ignored (default: `'^.*DialogComponent$'`)
- `ignore`: classes whose names match this regular expression (defined as string) will be ignored (default: `'^.*(?:Dialog|Modal)Component$'`)
- `propertyName`: name of the display property (default: `'cdsDisplay'`)

Why?
Expand Down Expand Up @@ -218,7 +218,7 @@ When using `.reduce()`, it may be tempting to do something like this for the sak
const mappedById = myArray.reduce((acc, entity) => ({ ...acc, [entity.id]: entity }), {});
```

However, spreading the accumulator at every iteration results in an operation with O(n^2) time & spatial complexity.
However, spreading the accumulator at every iteration results in an operation with O(n^2) time & spatial complexity.

This rule helps ensure that `.reduce()` is an O(n) operation. For example:

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/ngx-component-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
recommended: 'error',
},
messages: {
missingProperty: `Missing '{{ propertyName }}' property in component '{{ name }}'. Please define '@HostBinding('class.cds-display-block') readonly {{ propertyName }} = true;'. Valid values: cds-display-block, cds-display-inline, cds-display-inline-block`,
missingProperty: `Missing '{{ propertyName }}' property in component '{{ name }}'. Please define '@HostBinding('class.cds-display-block') readonly {{ propertyName }} = true;'. Valid values: cds-display-block, cds-display-inline, cds-display-inline-block. With the default config, this rule is disabled for components whose names end with 'DialogComponent' or 'ModalComponent'.`,
missingReadonly: `'{{ propertyName }}' property should be 'readonly' in component '{{ name }}'`,
invalidValue: `{{ propertyName }} value should be 'true' in component '{{ name }}'`,
missingDecorator: `'{{ propertyName }}' property should be decorated with '@HostBinding()' in component '{{ name }}'`,
Expand All @@ -32,7 +32,7 @@ module.exports = {

create(context) {
const options = context.options[0] || {};
const ignore = new RegExp(options.ignore || '^.*DialogComponent$');
const ignore = new RegExp(options.ignore || '^.*(?:Dialog|Modal)Component$');
const propertyName = options.propertyName || 'cdsDisplay';

return {
Expand Down

0 comments on commit f941ad8

Please sign in to comment.