1.6.5 • Published 6 days ago

eslint-config-beslogic v1.6.5

Weekly downloads
-
License
MIT
Repository
-
Last release
6 days ago

Eslint Config Beslogic

Installation and usage

Run npm i --save-dev eslint-config-beslogic eslint-plugin-total-functions

Depending on your needs, you will need to also install other peer dependencies for linting.

In your .eslintrc file, add "extends": "beslogic/<preset>" (see all available presets below)

For stylistic rules, it is highly recommended to use a dedicated formatter over ESLint. Read more here: https://typescript-eslint.io/docs/linting/troubleshooting/formatting/\ A dprint preset is offered below.

Parallel configurations

These are configuration files you'll have to update manually to best work with these presets.

package.json

Add the following scripts and engines:

"scripts": {
  "eslint": "eslint ./ --ignore-path .gitignore",
  "lint": "dprint check && npm run eslint",
  "lint:fix": "dprint fmt && npm run eslint -- --fix"
},
"// node 16": "14 won't install peer deps properly + prefer EventTarget (only available node 16)",
"engines": {
  "node": ">=16",
  "npm": ">=8"
}

Base tsconfig.json

Extend the following in your base tsconfig.json (follow link for more details):

typescript@>=5.0:

"extends": ["eslint-config-beslogic/tsconfig.5.0.json"],

typescript@>=4.3:

"extends": "eslint-config-beslogic/tsconfig.4.3.json",

"No Unchecked Indexed Access" makes index accesses even stricter. You may not want it in your project. You can disable it with "compilerOptions": { "noUncheckedIndexedAccess": false }.

If deploying / bundling with an Angular npm package, also set angularCompilerOptions": { "strictMetadataEmit": true }

.vscode/settings.json and .vscode/extensions.json

Read and copy from VSCode Settings and Extensions

dprint.json

If using the beslogic/dprint preset, use the following:

{
  // https://dprint.dev/config/#extending-a-different-configuration-file
  "extends": "https://raw.githubusercontent.com/BesLogic/beslogic-dprint-configuration/main/dprint.json"
}

If also using beslogic/json-like preset extend from https://raw.githubusercontent.com/BesLogic/beslogic-dprint-configuration/main/dprint-json-like.json instead.

Patched packages

The following packages cause problems or have other type-safety issues that are automatically patched out by eslint-config-beslogic on install. To see the complete logs, add foreground-scripts=true to a root .npmrc file, or run npm install with --foreground-scripts.

NX/NRWL

NX has a reusable add-linting generator that adds configuration that hides our own and/or conflicts with our best practices. We automatically patch-out that NX generator.

If you have a project that used NX before also using eslint-config-beslogic@>=1.5.2, make sure to remove all @nrwl/* and @angular-eslint/template/process-inline-templates entries from "extends" in all eslint configuration files. You can keep entries generated under "rules".

NX also doesn't support trailing commas in jsonc files. You'll have to make sure that your configurations contains none (and go upvote the referenced issue!).

Angular Material

Angular Material's MatDialogRef defaults it dialog result generic to any. This breaks type safety and is automatically patched out since eslint-config-beslogic@1.5.2.

Presets

Below are all the different configurations you can extend from. You can mix and match as you want if a predefined configuration does not exist for your specific stack. You should import TypeScript configs after regular javascript ones. ie "extends": ["beslogic/node", "beslogic/typescript"] at the root of the configuration.

beslogic

Default preset, extends from beslogic/javascript and beslogic/typescript.

beslogic/jest

Jest and Testing Library configs. Is already extended by beslogic/javascript and beslogic/typescript for all *spec.[jt]s and *.test.[jt]sx files. You should not need to extend from this configuration unless you want to add it to a test file that is not automatically picked up by the naming convention.

beslogic/javascript

Basic javascript configs, is extended by all other configs except beslogic/typescript, beslogic/jest, beslogic/storybook and beslogic/json-like.

beslogic/typescript

Basic TypeScript-specific configs and TSX support, is extended by all other TypeScript exclusive configs. To avoid rules conflicts, it does not already extend from beslogic/javascript. So you should extend from both in a pure TypeScript project. You may also need to specify parserOptions.project. ie: "parserOptions": { "project": ["tsconfig.json"] }, and "parser": "@typescript-eslint/parser".

For the linting to be fully effective, please make sure that your base tsconfig.json extends eslint-config-beslogic/tsconfig.X.X.json (see Parallel configurations).

beslogic/node-js

Configurations for NodeJS backends.

Add the following devDependencies to your package.json:

npm install --save-dev eslint-plugin-n

beslogic/rxjs

Configurations for projects using RxJs. Already extends and beslogic/typescript for TypeScript-specific rules and is already extended by beslogic/angular.

Add the following devDependencies to your package.json:

npm install --save-dev eslint-plugin-rxjs eslint-plugin-total-functions

beslogic/react

Configurations for React projects. Comes with JSX support.

Add the following devDependencies to your package.json:

npm install --save-dev eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component

beslogic/react-native

Configurations for React Native projects, including Expo. Already extends beslogic/react.

Add the following devDependencies to your package.json:

npm install --save-dev eslint-plugin-react-native eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component

beslogic/react-redux

Configurations for React projects using the Redux bindings. Already extends beslogic/react.

Add the following devDependencies to your package.json:

npm install --save-dev eslint-plugin-react-redux eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component

beslogic/mui

MUI/material framework configurations. Already extends beslogic/react and beslogic/typescript.

Add the following devDependencies to your package.json:

npm install --save-dev eslint-plugin-mui eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component eslint-plugin-total-functions

beslogic/angular

Configurations for NGX projects. Comes with html template and inline template support. Already extends beslogic/rxjs and beslogic/typescript. Also extends beslogic/node-js for Javascript files.

For the linting to be fully effective, please make sure that your base tsconfig.json extends eslint-config-beslogic/tsconfig.X.X.json (see Parallel configurations).\ If bundling with an npm package set "strictMetadataEmit": true under angularCompilerOptions.

Add the following devDependencies to your package.json:

npm install --save-dev @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/template-parser github:BesLogic/eslint-plugin-rxjs-angular#dist eslint-plugin-angular-file-naming eslint-plugin-total-functions

beslogic/storybook

Includes strict Storybook ESLint plugin and a custom rule for Angular components. This preset should be added last.

Add the following devDependencies to your package.json:

npm install --save-dev eslint-plugin-storybook

Stylistic Presets

If used, these presets should always come last, in this specific order.

beslogic/dprint

Disables all stylistic rules that are taken care of by dprint.

You must also extend the base configuration in a dprint.json file (see Parallel configurations).

beslogic/json-like

Enforces stylistic rules for JS objects to look like valid JSON objects.

1.6.5

6 days ago

1.6.4

1 month ago

1.6.3

1 month ago

1.6.2

1 month ago

1.6.1

1 month ago

1.6.0

1 month ago

1.5.16

3 months ago

1.5.15

3 months ago

1.5.14

4 months ago

1.5.13

4 months ago

1.5.9

5 months ago

1.5.8

5 months ago

1.5.7

5 months ago

1.5.6

5 months ago

1.5.10

5 months ago

1.5.12

5 months ago

1.5.11

5 months ago

1.5.5

9 months ago

1.5.4

9 months ago

1.5.3

9 months ago

1.5.2

9 months ago

1.5.1

9 months ago

1.5.0

9 months ago

1.4.26

12 months ago

1.4.27

12 months ago

1.4.22

1 year ago

1.4.24

1 year ago

1.4.23

1 year ago

1.4.25

1 year ago

1.4.20

1 year ago

1.4.21

1 year ago

1.4.15

1 year ago

1.4.17

1 year ago

1.4.16

1 year ago

1.4.19

1 year ago

1.4.18

1 year ago

1.4.11

2 years ago

1.4.10

2 years ago

1.4.13

2 years ago

1.4.12

2 years ago

1.4.14

2 years ago

1.4.9

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.10

2 years ago

1.3.11

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.4.8

2 years ago

1.4.7

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.0.60

2 years ago

0.0.59

2 years ago

0.0.58

2 years ago

0.0.57

2 years ago

0.0.56

2 years ago

0.0.55

2 years ago

0.0.54

2 years ago

0.0.53

2 years ago

0.0.52

2 years ago

0.0.51

2 years ago

0.0.50

2 years ago

0.0.49

2 years ago

0.0.48

2 years ago

0.0.47

2 years ago

0.0.46

2 years ago

0.0.44

2 years ago

0.0.43

2 years ago

0.0.42

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago