@brandsinsurance/eslint-plugin
v5.0.0
Published
ESLint Plugin for custom rules for Brands Insurance
Readme
= @brandsinsurance/eslint-plugin
Plugin for custom ESLint rules for BrandsInsurance
== Installation
You'll first need to install link:https://eslint.org/[ESLint]:
[source, shell]
npm i eslint --save-dev
Next, install @brandsinsurance/eslint-plugin:
[source, shell]
npm install @brandsinsurance/eslint-plugin --save-dev
== Usage
Add @brandsinsurance to the plugins section of your eslint.config.js configuration file.
You can omit the eslint-plugin- prefix:
[source, javascript]
import brands from '@brandsinsurance/eslint-plugin'; import { defineConfig } from 'eslint/config';
export default defineConfig([ { plugins: '@brandsinsurance': brands } ])
Then configure the rules you want to use under the rules section.
[source,javascript]
import brands from '@brandsinsurance/eslint-plugin'; import { defineConfig } from 'eslint/config';
export default defineConfig([ { plugins: '@brandsinsurance': brands, rules: { '@brandsinsurance/spaces-in-ifs': 'error', } } ])
Or, you can extend the built-in configs.
[source,javascript]
// Standard JS import brands from '@brandsinsurance/eslint-plugin'; import { defineConfig } from 'eslint/config';
export default defineConfig([brands.configs.jsGeneric])
// Standard JS, but indent using 4 spaces instead of 2 import brands from '@brandsinsurance/eslint-plugin'; import { defineConfig } from 'eslint/config';
export default defineConfig([ brands.configs.jsGeneric, { rules: { '@stylistic/indent': ['error', 4, { SwitchCase: 1 }] } } ])
// Standard JS, including a list of files to always ignore import brands from '@brandsinsurance/eslint-plugin'; import { defineConfig, globalIgnores } from 'eslint/config';
const listToIgnore = [ // ... ];
export default defineConfig([ globalIgnores(listToIgnore), brands.configs.jsGeneric ])
// TypeScript? import brands from '@brandsinsurance/eslint-plugin'; import { defineConfig } from 'eslint/config';
export default defineConfig([brands.configs.tsGeneric])
// TypeScript, but with TS ESLint's function import brands from '@brandsinsurance/eslint-plugin'; import tseslint from 'typescript-eslint';
export default tseslint.config(brands.configs.tsGeneric)
IMPORTANT: If using import/no-unused-modules (included in all available configs), you must have a .eslintrc
file, even if it's empty. Otherwise, running eslint will error before checking any file.
== Rules
- xref:./docs/rules/array-reduce-second-arg/README.adoc[
array-reduce-second-arg] - xref:./docs/rules/no-spaces-in-catches/README.adoc[
no-spaces-in-catches] - xref:./docs/rules/spaces-in-dowhiles/README.adoc[
spaces-in-dowhiles] - xref:./docs/rules/spaces-in-fors/README.adoc[
spaces-in-fors] - xref:./docs/rules/spaces-in-ifs/README.adoc[
spaces-in-ifs] - xref:./docs/rules/spaces-in-switches/README.adoc[
spaces-in-switches] - xref:./docs/rules/spaces-in-whiles/README.adoc[
spaces-in-whiles]
== Configs
- :xref:./src/configs/ts_generic.ts[
tsGeneric] ** All eslint rules we've discussed, including those linting TypeScript - :xref:./src/configs/js_generic.ts[
jsGeneric] ** All javascript eslint rules we've discussed - :xref:./src/configs/ts_stimulus.ts[
tsStimulus] ** Re-configures some rules meant for stimulus controllers including TypeScript - :xref:./src/configs/js_stimulus.ts[
jsStimulus] ** Re-configures some rules meant for stimulus controllers
== Contributing
See xref:./CONTRIBUTING.adoc[CONTRIBUTING] for how to add your own rule
== Changelog
See xref:./CHANGELOG.adoc[CHANGELOG] see see changes
