diff --git a/README.md b/README.md index ad86e2a..1745539 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,13 @@ npm i @iobroker/eslint-config --save-dev Just extend this project in your lint config in your `eslint.config.mjs`. ```js -import config from '@iobroker/eslint-config'; +import config, { jsdocConfig } from '@iobroker/eslint-config'; -export default [...config]; +export default [...config, ...jsdocConfig]; ``` +You can remove the `jsdocConfig` if you don't want to enforce JSDoc comments. + And create a `prettier.config.mjs` with the following content: ```js @@ -30,9 +32,9 @@ Optionally, if you are using ESM modules, there is an additional config. Your `eslint.config.mjs` would then look like this: ```js -import config, { esmConfig } from '@iobroker/eslint-config'; +import config, { jsdocConfig, esmConfig } from '@iobroker/eslint-config'; -export default [...config, ...esmConfig]; +export default [...config, ...jsdocConfig, ...esmConfig]; ``` ## ReactJS project @@ -40,19 +42,40 @@ export default [...config, ...esmConfig]; To use this config in a ReactJS project, your `eslint.config.mjs` would then look like this: ```js -import config, { reactConfig } from '@iobroker/eslint-config'; +import config, { reactConfig, jsdocConfig } from '@iobroker/eslint-config'; -export default [...config, ...reactConfig]; +export default [...config, ...jsdocConfig, ...reactConfig]; ``` It is suggested to create separate `eslint.config.mjs` files for backend and for ReactJS. +## Hot to migrate from `.eslintrc.json` to `iobroker.eslint-config` + +Execute all previously described steps and then remove the `.eslintrc.json` file. + +You should modify or add the `lint` script in your `package.json`: + +```json +{ + "scripts": { + "lint": "eslint -c eslint.config.mjs src" + } +} +``` + +Where `src` is the folder with your source code. + ## Changelog + +### **WORK IN PROGRESS** + +- (@GermanBluefox) Made jsdoc rules optional + ### 0.1.6 (2024-09-16) - (@GermanBluefox) Enforce the use of template literals instead of string concatenation: "Hello, " + name + "!" => `Hello, ${name}!` diff --git a/eslint.config.mjs b/eslint.config.mjs index 581387d..b800c9f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -150,10 +150,6 @@ export default tseslint.config( }, }, }, - { - plugins: { jsdoc }, - rules: jsdocRules, - }, { rules: generalRules, }, @@ -177,6 +173,13 @@ export const esmConfig = [ }, ]; +export const jsdocConfig = [ + { + plugins: { jsdoc }, + rules: jsdocRules, + }, +]; + export const reactConfig = [ { plugins: {