Skip to content

Commit

Permalink
Merge pull request #2 from duckduckgo:prettier-tweaks
Browse files Browse the repository at this point in the history
Changes to support Prettier
  • Loading branch information
muodov authored Nov 4, 2024
2 parents 51dc868 + e179ba6 commit 09f3780
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 36 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# DDG shared eslint configuration

This is a shared eslint configuration used across several DDG projects.

## How to set up your project with this config

- This config is meant to be used with ESLint 9+ AND Prettier, so make sure you are using those in your project.
- add a dev NPM dependency: `github:duckduckgo/eslint-config#<GIT_COMMIT_OR_TAG>`
- in your `eslint.config.js`, import this config and put it in the configuration array. You probably want it after other "recommended" configs, and before project-specific rules.

```js
import someConfig from "some-other-config-you-use";
import ddgConfig from '@duckduckgo/eslint-config'
export default [
someConfig,
...ddgConfig,
{
rules: {
// your project-specific rules here
},
}
];
```

## Prettier is required
This config disables ESLint formatting rules (through `eslint-config-prettier`), so you are expected to rely on Prettier to do the formatting. Make sure you have Prettier set up in your project.

## ESLint plugins
This config **already includes** the following plugins, so you don't need to install them explicitly:
- `eslint-plugin-n`
- `eslint-plugin-import`
- `eslint-plugin-promise`
- `eslint-config-prettier`

It also includes **recommended** configuration from `@eslint/js` (but not for other plugins).

## TypeScript
This config does not include TypeScript-specific rules, and does not depend on `typescript-eslint`. The reason for that is that typescript plugin disables some standard JS rules, and this would mess things up for pure-JS projects. If you are using TypeScript, you can add `typescript-eslint` to your project and configure it separately. You can check existing DDG projects for examples.
38 changes: 2 additions & 36 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import nodePlugin from "eslint-plugin-n";
import importPlugin from 'eslint-plugin-import';
import promisePlugin from 'eslint-plugin-promise';
import js from '@eslint/js';
import eslintConfigPrettier from "eslint-config-prettier";

export default [
js.configs.recommended,
eslintConfigPrettier,

{
plugins: {
Expand All @@ -14,8 +16,6 @@ export default [
},

rules: {
"indent": ["error", 4],

// revised rules from "standard"
"no-var": "warn",
"object-shorthand": [
Expand Down Expand Up @@ -46,10 +46,6 @@ export default [
"ignoreGlobals": true
}
],
"curly": [
"error",
"multi-line"
],
"default-case-last": "error",
"dot-notation": [
"error",
Expand Down Expand Up @@ -92,32 +88,6 @@ export default [
}
],
"no-lone-blocks": "error",
"no-mixed-operators": [
"error",
{
"groups": [
[
"==",
"!=",
"===",
"!==",
">",
">=",
"<",
"<="
],
[
"&&",
"||"
],
[
"in",
"instanceof"
]
],
"allowSamePrecedence": true
}
],
"no-multi-str": "error",
"no-new": "error",
"no-new-func": "error",
Expand Down Expand Up @@ -191,10 +161,6 @@ export default [
"disallowRedundantWrapping": true
}
],
"quote-props": [
"error",
"as-needed"
],
"spaced-comment": [
"error",
"always",
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 @@ -14,6 +14,7 @@
},
"dependencies": {
"@eslint/js": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.11.1",
"eslint-plugin-promise": "^7.1.0"
Expand Down

0 comments on commit 09f3780

Please sign in to comment.