diff --git a/docs/lint/html/rules/no-disabled-attribute-on-button.md b/docs/lint/html/rules/no-disabled-attribute-on-button.md
index d9d39ce82c..8f7539cbc7 100644
--- a/docs/lint/html/rules/no-disabled-attribute-on-button.md
+++ b/docs/lint/html/rules/no-disabled-attribute-on-button.md
@@ -9,6 +9,8 @@ _______
[Source code](../../../../lint/src/rules/html/no-disabled-attribute-on-button.ts)
+
+
### Examples
diff --git a/docs/lint/html/rules/themed-component-usages.md b/docs/lint/html/rules/themed-component-usages.md
index a04fe1c770..885a81014b 100644
--- a/docs/lint/html/rules/themed-component-usages.md
+++ b/docs/lint/html/rules/themed-component-usages.md
@@ -11,6 +11,8 @@ _______
[Source code](../../../../lint/src/rules/html/themed-component-usages.ts)
+
+
### Examples
diff --git a/docs/lint/ts/rules/alias-imports.md b/docs/lint/ts/rules/alias-imports.md
index 281c821419..319047e0aa 100644
--- a/docs/lint/ts/rules/alias-imports.md
+++ b/docs/lint/ts/rules/alias-imports.md
@@ -7,6 +7,21 @@ _______
[Source code](../../../../lint/src/rules/ts/alias-imports.ts)
+
+### Options
+
+#### `aliases`
+
+A list of all the imports that you want to alias for clarity. Every alias should be declared in the following format:
+```json
+{
+ "package": "rxjs",
+ "imported": "of",
+ "local": "observableOf"
+}
+```
+
+
### Examples
diff --git a/docs/lint/ts/rules/themed-component-classes.md b/docs/lint/ts/rules/themed-component-classes.md
index e3ca8d6582..ab9bb84632 100644
--- a/docs/lint/ts/rules/themed-component-classes.md
+++ b/docs/lint/ts/rules/themed-component-classes.md
@@ -11,6 +11,8 @@ _______
[Source code](../../../../lint/src/rules/ts/themed-component-classes.ts)
+
+
### Examples
diff --git a/docs/lint/ts/rules/themed-component-selectors.md b/docs/lint/ts/rules/themed-component-selectors.md
index f4d0ea177c..c24263a934 100644
--- a/docs/lint/ts/rules/themed-component-selectors.md
+++ b/docs/lint/ts/rules/themed-component-selectors.md
@@ -17,6 +17,8 @@ _______
[Source code](../../../../lint/src/rules/ts/themed-component-selectors.ts)
+
+
### Examples
diff --git a/docs/lint/ts/rules/themed-component-usages.md b/docs/lint/ts/rules/themed-component-usages.md
index 16ccb701c2..9b7efb42c7 100644
--- a/docs/lint/ts/rules/themed-component-usages.md
+++ b/docs/lint/ts/rules/themed-component-usages.md
@@ -15,6 +15,8 @@ _______
[Source code](../../../../lint/src/rules/ts/themed-component-usages.ts)
+
+
### Examples
diff --git a/docs/lint/ts/rules/themed-decorators.md b/docs/lint/ts/rules/themed-decorators.md
index 72c2d206b9..9b7755c5aa 100644
--- a/docs/lint/ts/rules/themed-decorators.md
+++ b/docs/lint/ts/rules/themed-decorators.md
@@ -7,6 +7,14 @@ _______
[Source code](../../../../lint/src/rules/ts/themed-decorators.ts)
+
+### Options
+
+#### `decorators`
+
+A mapping for all the existing themeable decorators, with the decorator name as the key and the index of the `theme` argument as the value.
+
+
### Examples
diff --git a/docs/lint/ts/rules/themed-wrapper-no-input-defaults.md b/docs/lint/ts/rules/themed-wrapper-no-input-defaults.md
index 045af8b3ad..2653aab3a5 100644
--- a/docs/lint/ts/rules/themed-wrapper-no-input-defaults.md
+++ b/docs/lint/ts/rules/themed-wrapper-no-input-defaults.md
@@ -7,6 +7,8 @@ _______
[Source code](../../../../lint/src/rules/ts/themed-wrapper-no-input-defaults.ts)
+
+
### Examples
diff --git a/docs/lint/ts/rules/unique-decorators.md b/docs/lint/ts/rules/unique-decorators.md
index a0d3ceedc1..09089e67b2 100644
--- a/docs/lint/ts/rules/unique-decorators.md
+++ b/docs/lint/ts/rules/unique-decorators.md
@@ -7,6 +7,14 @@ _______
[Source code](../../../../lint/src/rules/ts/unique-decorators.ts)
+
+### Options
+
+#### `decorators`
+
+The list of all the decorators for which you want to enforce this behavior.
+
+
### Examples
diff --git a/lint/src/rules/html/no-disabled-attribute-on-button.ts b/lint/src/rules/html/no-disabled-attribute-on-button.ts
index bf1a72d70d..6a5fad0081 100644
--- a/lint/src/rules/html/no-disabled-attribute-on-button.ts
+++ b/lint/src/rules/html/no-disabled-attribute-on-button.ts
@@ -33,6 +33,7 @@ export const info = {
[Message.USE_DSBTN_DISABLED]: 'Buttons should use the `dsBtnDisabled` directive instead of the `disabled` attribute.',
},
},
+ optionDocs: [],
defaultOptions: [],
} as DSpaceESLintRuleInfo;
diff --git a/lint/src/rules/html/themed-component-usages.ts b/lint/src/rules/html/themed-component-usages.ts
index e907285dbc..a45d442ac4 100644
--- a/lint/src/rules/html/themed-component-usages.ts
+++ b/lint/src/rules/html/themed-component-usages.ts
@@ -45,6 +45,7 @@ The only exception to this rule are unit tests, where we may want to use the bas
[Message.WRONG_SELECTOR]: 'Themeable components should be used via their ThemedComponent wrapper\'s selector',
},
},
+ optionDocs: [],
defaultOptions: [],
} as DSpaceESLintRuleInfo;
diff --git a/lint/src/rules/ts/alias-imports.ts b/lint/src/rules/ts/alias-imports.ts
index dd0653ea9b..9fca824f6b 100644
--- a/lint/src/rules/ts/alias-imports.ts
+++ b/lint/src/rules/ts/alias-imports.ts
@@ -9,6 +9,7 @@ import { Scope } from '@typescript-eslint/utils/ts-eslint';
import {
DSpaceESLintRuleInfo,
NamedTests,
+ OptionDoc,
} from '../../util/structure';
export enum Message {
@@ -17,13 +18,21 @@ export enum Message {
MULTIPLE_ALIASES = 'multipleAliases',
}
+interface AliasImportOptions {
+ aliases: AliasImportOption[];
+}
+
interface AliasImportOption {
package: string;
imported: string;
local: string;
}
-export const info: DSpaceESLintRuleInfo<[[AliasImportOption]]> = {
+interface AliasImportDocOptions {
+ aliases: OptionDoc;
+}
+
+export const info: DSpaceESLintRuleInfo<[AliasImportOptions], [AliasImportDocOptions]> = {
name: 'alias-imports',
meta: {
docs: {
@@ -36,35 +45,50 @@ export const info: DSpaceESLintRuleInfo<[[AliasImportOption]]> = {
},
fixable: 'code',
type: 'problem',
- schema: [
- {
- type: 'array',
- items: {
- type: 'object',
- properties: {
- package: { type: 'string' },
- imported: { type: 'string' },
- local: { type: 'string' },
- },
+ schema: {
+ type: 'array',
+ items: {
+ type: 'object',
+ properties: {
+ package: { type: 'string' },
+ imported: { type: 'string' },
+ local: { type: 'string' },
},
},
- ],
+ },
},
- defaultOptions: [
- [
- {
- package: 'rxjs',
- imported: 'of',
- local: 'observableOf',
+ optionDocs: [
+ {
+ aliases: {
+ title: '`aliases`',
+ description: `A list of all the imports that you want to alias for clarity. Every alias should be declared in the following format:
+\`\`\`json
+{
+ "package": "rxjs",
+ "imported": "of",
+ "local": "observableOf"
+}
+\`\`\``,
},
- ],
+ },
+ ],
+ defaultOptions: [
+ {
+ aliases: [
+ {
+ package: 'rxjs',
+ imported: 'of',
+ local: 'observableOf',
+ },
+ ],
+ },
],
};
export const rule = ESLintUtils.RuleCreator.withoutDocs({
...info,
create(context: TSESLint.RuleContext, options: any) {
- return options[0].reduce((selectors: any, option: AliasImportOption) => {
+ return (options[0] as AliasImportOptions).aliases.reduce((selectors: any, option: AliasImportOption) => {
selectors[`ImportDeclaration[source.value = "${option.package}"] > ImportSpecifier[imported.name = "${option.imported}"][local.name != "${option.local}"]`] = (node: TSESTree.ImportSpecifier) => handleUnaliasedImport(context, option, node);
return selectors;
}, {});
diff --git a/lint/src/rules/ts/themed-component-classes.ts b/lint/src/rules/ts/themed-component-classes.ts
index c1514fee12..d52e06524d 100644
--- a/lint/src/rules/ts/themed-component-classes.ts
+++ b/lint/src/rules/ts/themed-component-classes.ts
@@ -52,6 +52,7 @@ export const info = {
[Message.WRAPPER_IMPORTS_BASE]: 'Themed component wrapper classes must only import the base class',
},
},
+ optionDocs: [],
defaultOptions: [],
} as DSpaceESLintRuleInfo;
diff --git a/lint/src/rules/ts/themed-component-selectors.ts b/lint/src/rules/ts/themed-component-selectors.ts
index c27fd66d66..e606eb4358 100644
--- a/lint/src/rules/ts/themed-component-selectors.ts
+++ b/lint/src/rules/ts/themed-component-selectors.ts
@@ -53,6 +53,7 @@ Unit tests are exempt from this rule, because they may redefine components using
[Message.THEMED]: 'Theme override of themeable component should have a selector starting with \'ds-themed-\'',
},
},
+ optionDocs: [],
defaultOptions: [],
} as DSpaceESLintRuleInfo;
diff --git a/lint/src/rules/ts/themed-component-usages.ts b/lint/src/rules/ts/themed-component-usages.ts
index 83fe6f8ea8..37eb6dc454 100644
--- a/lint/src/rules/ts/themed-component-usages.ts
+++ b/lint/src/rules/ts/themed-component-usages.ts
@@ -63,6 +63,7 @@ There are a few exceptions where the base class can still be used:
[Message.BASE_IN_MODULE]: 'Base themeable components shouldn\'t be declared in modules',
},
},
+ optionDocs: [],
defaultOptions: [],
} as DSpaceESLintRuleInfo;
diff --git a/lint/src/rules/ts/themed-decorators.ts b/lint/src/rules/ts/themed-decorators.ts
index 58ed21949b..3d2b614b1a 100644
--- a/lint/src/rules/ts/themed-decorators.ts
+++ b/lint/src/rules/ts/themed-decorators.ts
@@ -10,6 +10,7 @@ import { isTestFile } from '../../util/filter';
import {
DSpaceESLintRuleInfo,
NamedTests,
+ OptionDoc,
} from '../../util/structure';
import { getFileTheme } from '../../util/theme-support';
@@ -23,7 +24,11 @@ interface ThemedDecoratorsOption {
decorators: { [name: string]: number };
}
-export const info: DSpaceESLintRuleInfo<[ThemedDecoratorsOption]> = {
+interface ThemedDecoratorsDocsOption {
+ decorators: OptionDoc;
+}
+
+export const info: DSpaceESLintRuleInfo<[ThemedDecoratorsOption], [ThemedDecoratorsDocsOption]> = {
name: 'themed-decorators',
meta: {
docs: {
@@ -47,6 +52,14 @@ export const info: DSpaceESLintRuleInfo<[ThemedDecoratorsOption]> = {
},
],
},
+ optionDocs: [
+ {
+ decorators: {
+ title: '`decorators`',
+ description: 'A mapping for all the existing themeable decorators, with the decorator name as the key and the index of the `theme` argument as the value.',
+ },
+ },
+ ],
defaultOptions: [
{
decorators: {
diff --git a/lint/src/rules/ts/themed-wrapper-no-input-defaults.ts b/lint/src/rules/ts/themed-wrapper-no-input-defaults.ts
index 0af9b8b2e2..359f291707 100644
--- a/lint/src/rules/ts/themed-wrapper-no-input-defaults.ts
+++ b/lint/src/rules/ts/themed-wrapper-no-input-defaults.ts
@@ -26,6 +26,7 @@ export const info: DSpaceESLintRuleInfo = {
type: 'problem',
schema: [],
},
+ optionDocs: [],
defaultOptions: [],
};
diff --git a/lint/src/rules/ts/unique-decorators.ts b/lint/src/rules/ts/unique-decorators.ts
index 659c4f500f..964fc5e07e 100644
--- a/lint/src/rules/ts/unique-decorators.ts
+++ b/lint/src/rules/ts/unique-decorators.ts
@@ -9,6 +9,7 @@ import { isTestFile } from '../../util/filter';
import {
DSpaceESLintRuleInfo,
NamedTests,
+ OptionDoc,
} from '../../util/structure';
export enum Message {
@@ -17,7 +18,15 @@ export enum Message {
const decoratorCalls: Map> = new Map();
-export const info: DSpaceESLintRuleInfo = {
+export interface UniqueDecoratorsOptions {
+ decorators: string[];
+}
+
+export interface UniqueDecoratorsDocOptions {
+ decorators: OptionDoc;
+}
+
+export const info: DSpaceESLintRuleInfo<[UniqueDecoratorsOptions], [UniqueDecoratorsDocOptions]> = {
name: 'unique-decorators',
meta: {
docs: {
@@ -41,6 +50,14 @@ export const info: DSpaceESLintRuleInfo = {
},
],
},
+ optionDocs: [
+ {
+ decorators: {
+ title: '`decorators`',
+ description: 'The list of all the decorators for which you want to enforce this behavior.',
+ },
+ },
+ ],
defaultOptions: [
{
decorators: [
diff --git a/lint/src/util/structure.ts b/lint/src/util/structure.ts
index 326ce93cf6..4993b5f60b 100644
--- a/lint/src/util/structure.ts
+++ b/lint/src/util/structure.ts
@@ -17,12 +17,18 @@ export type Meta = RuleMetaData;
export type Valid = ValidTestCase;
export type Invalid = InvalidTestCase;
-export interface DSpaceESLintRuleInfo {
+export interface DSpaceESLintRuleInfo {
name: string;
meta: Meta,
+ optionDocs: D,
defaultOptions: T,
}
+export interface OptionDoc {
+ title: string;
+ description: string;
+}
+
export interface NamedTests {
plugin: string;
valid: Valid[];
diff --git a/lint/src/util/templates/rule.ejs b/lint/src/util/templates/rule.ejs
index b39d193cc1..06232d021d 100644
--- a/lint/src/util/templates/rule.ejs
+++ b/lint/src/util/templates/rule.ejs
@@ -7,6 +7,11 @@ _______
[Source code](../../../../lint/src/rules/<%- plugin.name.replace('dspace-angular-', '') %>/<%- rule.name %>.ts)
+<% if (rule.optionDocs?.length > 0) { %>
+### Options
+<%- rule.optionDocs.map(optionDoc => Object.keys(optionDoc).map(option => '\n#### ' + optionDoc[option].title + '\n\n' + optionDoc[option].description)) %>
+<% } %>
+
### Examples
<% if (tests.valid) {%>