Skip to content

Commit

Permalink
Made jsdoc rules optional
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Sep 27, 2024
1 parent 00912d0 commit f49a79e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,29 +32,50 @@ 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

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

<!--
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->

### **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}!`
Expand Down
11 changes: 7 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ export default tseslint.config(
},
},
},
{
plugins: { jsdoc },
rules: jsdocRules,
},
{
rules: generalRules,
},
Expand All @@ -177,6 +173,13 @@ export const esmConfig = [
},
];

export const jsdocConfig = [
{
plugins: { jsdoc },
rules: jsdocRules,
},
];

export const reactConfig = [
{
plugins: {
Expand Down

0 comments on commit f49a79e

Please sign in to comment.