Skip to content

Commit

Permalink
Merge pull request #57 from Boehringer-Ingelheim/add-prettier-disable…
Browse files Browse the repository at this point in the history
…-config

Adds a prettier-disable shared config
  • Loading branch information
matzehecht authored Dec 13, 2024
2 parents eb0cb3d + 4e8000c commit 951454d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,26 @@ This shared ESLint configuration is designed to enforce best practices and recom
- [`playwright/prefer-to-have-length`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-to-have-length.md): enforces the use of `.toHaveLength()` instead of `.toEqual(n)` when testing the length of an object.
- [`playwright/require-top-level-describe`](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/require-top-level-describe.md): requires tests to be organized into top-level `describe()` blocks.

### `@boehringer-ingelheim/eslint-config/prettier-disable`

```js
module.exports = {
extends: [
'@boehringer-ingelheim/eslint-config/base/strict',
// Following needs eslint-plugin-prettier to be installed as described by https://github.com/prettier/eslint-plugin-prettier
// Should be second to last
'plugin:prettier/recommended',
// Should be last
'@boehringer-ingelheim/eslint-config/prettier-disable'
],
};
```

This shared ESLint configuration is wrapper around [`eslint-config-disable`](https://github.com/prettier/eslint-config-prettier), which is used to turn off all rules that are unnecessary or might conflict with Prettier. This wrapper reenables a few rules that can be used with our shared configurations as we are using specific options of those rules which are compatible with Prettier (see [Special Rules](https://github.com/prettier/eslint-config-prettier#special-rules)). Following rules are reenabled:

- [`curly`](https://github.com/eslint/eslint/blob/main/docs/src/rules/curly.md) with the (default) option "all": Enforce consistent brace style for all control statements
- [`no-confusing-arrow`](https://github.com/eslint/eslint/blob/main/docs/src/rules/no-confusing-arrow.md) with allowParens `false` and onlyOneSimpleParam `true`: Disallow arrow functions where they could be confused with comparisons.

## Local Development

### Install Dependencies
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@rushstack/eslint-patch": "^1.10.3",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-import": "^2.29.1",
Expand Down
14 changes: 14 additions & 0 deletions prettier-disable/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Workaround to allow ESLint to resolve plugins that were installed
* by an external config, see https://github.com/eslint/eslint/issues/3458.
*/
require('@rushstack/eslint-patch/modern-module-resolution');

/** @type {import('eslint').ESLint.ConfigData & { parserOptions: import('eslint').ESLint.ConfigData['parserOptions'] & import('@typescript-eslint/parser').ParserOptions } } */
module.exports = {
extends: ['prettier'],
rules: {
curly: 'error',
'no-confusing-arrow': ['error', { allowParens: false, onlyOneSimpleParam: false }],
},
};

0 comments on commit 951454d

Please sign in to comment.