-
Install the
@davincihealthcare/eslint-plugin-davincipackage as a dev dependencyIf you're using
eslint >= 9.0.0, you'll also need to install the following packages as dev dependencies:@eslint/js@eslint/eslintrc
-
Extend the plugin in the eslint configuration file
.eslintrc.jsmodule.exports = { extends: [ 'plugin:@davincihealthcare/davinci/recommended', ], }
eslint.config.js
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [{
ignores: ["dist", "**/tsconfig.json"],
}, ...compat.extends("plugin:@davincihealthcare/davinci/recommended")];
-
If you're using
Turbomonorepo:-
Install
eslint-config-turboas a dev dependency -
Extend the
eslint-config-turboplugin in your configuration:.eslintrc.js( module.exports = { extends: [ 'plugin:@davincihealthcare/davinci/recommended', 'eslint-config-turbo' ], } );eslint.config.jsimport path from "node:path"; import { fileURLToPath } from "node:url"; import js from "@eslint/js"; import { FlatCompat } from "@eslint/eslintrc"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname, recommendedConfig: js.configs.recommended, allConfig: js.configs.all }); export default [{ ignores: ["dist", "**/tsconfig.json"], }, ...compat.extends("plugin:@davincihealthcare/davinci/recommended", "eslint-config-turbo")];
-
-
In your
package.jsonfile, you should add scripts to perform linting checks and/or automatically fix linting errors where possible- eslint < 9.0.0
package.json{ ... "scripts": { ... "eslint-check": "eslint -c .eslintrc.js --ext \".js,.ts\" ." "eslint-fix": "eslint --fix -c .eslintrc.js --ext \".js,.ts\" ." ... } ... }
- eslint >= 9.0.0
`package.json`
```
{
...
"scripts": {
...
"eslint-check": "eslint ."
"eslint-fix": "eslint --fix ."
...
}
...
}
```
Rules
Levels set by the base, recommended and vue configs.
| Rule | Description | base / recommended | vue |
|---|---|---|---|
no-native-date | Do not use the native Date object, use luxon DateTime | off | error |
no-router-push | Do not use router.push/resolve, use useRouterUtils | error | error |
no-unsafe-url-params | Do not use unsafe URL parameters, use useRouterUtils | error | error |
prefer-lookup-map | Prefer a lookup object over a switch that only maps constant cases to a result | warn | warn |
simple-array-type | Use Type[] for simple arrays of a single type | off | off |
tuple-array-type | Use [Type] to define tuples | off | off |