Skip to content

Commit

Permalink
fix(1161): use options from 2nd argument (#1174)
Browse files Browse the repository at this point in the history
## Proposed change
use options from 2nd argument

## Related issues

- 🐛 Fixes #1161
  • Loading branch information
matthieu-crouzet authored Dec 21, 2023
2 parents 0ab973f + 3d5130c commit 20a9d14
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Messages =
| 'notInConfigurationInterface'
| 'suggestReplaceO3rCategory';

export default createRule<O3rCategoriesTagsRuleOption[], Messages>({
export default createRule<[O3rCategoriesTagsRuleOption, ...any], Messages>({
name: 'o3r-categories-tags',
meta: {
hasSuggestions: true,
Expand All @@ -37,7 +37,8 @@ export default createRule<O3rCategoriesTagsRuleOption[], Messages>({
type: 'array',
items: {
type: 'string'
}
},
default: []
}
}
}
Expand All @@ -50,14 +51,11 @@ export default createRule<O3rCategoriesTagsRuleOption[], Messages>({
suggestReplaceO3rCategory: 'Replace {{ currentCategory }} by {{ suggestedCategory }}.'
}
},
defaultOptions: [],
create: (context) => {
const options: Required<O3rCategoriesTagsRuleOption> = context.options
.reduce((acc: Required<O3rCategoriesTagsRuleOption>, option) => {
acc.supportedInterfaceNames = (acc.supportedInterfaceNames || []).concat(option.supportedInterfaceNames || []);
acc.globalConfigCategories = (acc.globalConfigCategories || []).concat(option.globalConfigCategories || []);
return acc;
}, { globalConfigCategories: [], supportedInterfaceNames: [] });
defaultOptions: [{
supportedInterfaceNames: defaultSupportedInterfaceNames,
globalConfigCategories: []
}],
create: (context, [options]: [Required<O3rCategoriesTagsRuleOption>]) => {
const globalConfigCategories = new Set(options.globalConfigCategories);
return {
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down

0 comments on commit 20a9d14

Please sign in to comment.