The PWA's ruleset is configured in
.eslintrc.json and includes base rulesets to extend from, plugins with additional rules as well as a configuration for our custom rules.
To read more about the Intershop PWA's custom rules, see Custom ESLint rules.
An ESLint rule configuration is a key-value-pair of a
rules object in
There are separate rulesets for
Consider the following example:
The key specifies the rule to configure, in this case
The value specifies a rule's options and can be structured in two different ways:
off. This simply enables or disables the rule and sets a severity level.
warn). The following entries are rule-specific configuration and will be passed to the rule.
Refer to the relevant documentation of the standard ESLint ruleset, various plugins or our custom rules to learn more about what each rule does and how to configure them.
To keep the codebase clean, easily maintainable and functional, the Intershop PWA provides a large number of custom ESLint rules.
These rules are located in the
The custom rules are developed separately from the main source code, which uses the compiled rules as a local developer dependency in its
To work with and develop new custom ESLint rules, follow these steps:
ng g eslint-rule (alias
er). This generates a new rule file at
eslint-rules/src/rules and a test file at
helpers.ts to reduce repetition.
RuleTester API that is used in tests. Use
npm run test:eslint-rules to execute your tests.
eslint-rules project with your changes using
eslint-rules/dist folder. A generated
index.ts exports the rules to be consumed in the
.eslintrc.json configuration file.
ESLint: Restart ESLint server command to see your new configuration applied in VSCode. You can access the command via the editor commands (default keybinding:
ctrl + shift + p).