@dpuse/eslint-config-dpuse 1.1.101 → 1.1.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,9 +31,11 @@ In addition, DPUse provides [Tools](https://www.dpuse.app) used by the applicati
|
|
|
31
31
|
This [package](https://www.npmjs.com/package/@dpuse/eslint-config-dpuse) is available on [npm](https://www.npmjs.com/). Install it with:
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
npm install @dpuse/eslint-config-dpuse
|
|
34
|
+
npm install -D @dpuse/eslint-config-dpuse eslint
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
_Requires [Node.js](https://nodejs.org/) 24 or later, [npm](https://www.npmjs.com/) 12 or later, and `eslint` 10.15.0 or later as a peer dependency._
|
|
38
|
+
|
|
37
39
|
> [!WARNING]
|
|
38
40
|
> This project is not designed for general use. It is custom built for the DPUse CI/CD process. You are welcome to clone and customise it for your own purposes, but you will need to adapt it to your own project structure and tooling.
|
|
39
41
|
|
|
@@ -45,12 +47,70 @@ cd eslint-config-dpuse
|
|
|
45
47
|
npm install
|
|
46
48
|
```
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
_Working on the source also requires [TypeScript](https://www.typescriptlang.org/) 6.0.3 or a later 6.0 release. Later versions, including TypeScript 7, are not supported yet._
|
|
49
51
|
|
|
50
52
|
This repository is managed using the common set of actions provided by [@dpuse/dpuse-development](https://github.com/dpuse/dpuse-development). See the `scripts` block in [package.json](https://github.com/dpuse/eslint-config-dpuse/blob/main/package.json) for details.
|
|
51
53
|
|
|
52
54
|
<!-- USAGE_END -->
|
|
53
55
|
|
|
56
|
+
## Configuration
|
|
57
|
+
|
|
58
|
+
The package uses ESLint's flat configuration format and is published as an ES module. Create `eslint.config.js` in the project root:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import { dpuseESLintConfig } from '@dpuse/eslint-config-dpuse';
|
|
62
|
+
|
|
63
|
+
export default dpuseESLintConfig({
|
|
64
|
+
ignores: ['generated/**'],
|
|
65
|
+
importCoreModules: ['cloudflare:workers'],
|
|
66
|
+
rules: { 'unicorn/no-array-reduce': 'off' }
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Run ESLint from the project root, where it finds `tsconfig.json`.
|
|
71
|
+
|
|
72
|
+
### Options
|
|
73
|
+
|
|
74
|
+
| Option | Default | What it does |
|
|
75
|
+
| :------------------ | :------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------- |
|
|
76
|
+
| `files` | `['eslint.config.js', 'src/**/*.ts', 'tests/**/*.ts', 'vite.config.ts', 'vitest.config.ts']` | The files linted with the type-aware TypeScript rules. |
|
|
77
|
+
| `ignores` | `[]` | Glob patterns to ignore, added to the folders that are always ignored. |
|
|
78
|
+
| `rules` | `{}` | Rule settings for the project. They are applied last, so they override the shared settings. |
|
|
79
|
+
| `importCoreModules` | `[]` | Module names the import rules treat as built in, such as `cloudflare:workers`. |
|
|
80
|
+
| `tsconfigPath` | `'./tsconfig.json'` | The `tsconfig.json` the import resolver reads. |
|
|
81
|
+
| `tsconfigRootDir` | `process.cwd()` | The project's root folder, where type-aware linting starts looking for each file's `tsconfig.json`. |
|
|
82
|
+
|
|
83
|
+
A project that sets up its own TypeScript parser, such as a Vue project, uses `dpuseBaseESLintConfig({ files, ignores, rules })` instead. It adds the shared plugins, rule settings and ignores, but not the TypeScript rules. `files` is required.
|
|
84
|
+
|
|
85
|
+
### What It Includes
|
|
86
|
+
|
|
87
|
+
- [ESLint's recommended rules](https://eslint.org/docs/latest/rules/).
|
|
88
|
+
- [typescript-eslint](https://typescript-eslint.io)'s `strict-type-checked` and `stylistic-type-checked` configurations. Type information comes from the project service, which checks each file with its nearest `tsconfig.json`, as the editor does.
|
|
89
|
+
- The recommended configurations of [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn), [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x) (with the TypeScript resolver), [eslint-plugin-regexp](https://github.com/ota-meshi/eslint-plugin-regexp) and [@eslint-community/eslint-plugin-eslint-comments](https://github.com/eslint-community/eslint-plugin-eslint-comments).
|
|
90
|
+
- [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n)'s checks for syntax and built-in modules that the project's Node.js version does not support.
|
|
91
|
+
- [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier), which turns off the rules that conflict with Prettier.
|
|
92
|
+
- Node.js globals, such as `console` and `process`, in plain JavaScript files (`.js`, `.cjs`, `.mjs`).
|
|
93
|
+
|
|
94
|
+
The plugin rules also apply to JavaScript files outside `files`, such as `.mjs` scripts, but never to files in other languages, such as CSS. These folders are always ignored: `bundle-analysis-reports`, `dependency-check-bin`, `dependency-check-reports`, `dist` and `licenses`.
|
|
95
|
+
|
|
96
|
+
### DPUse Rule Settings
|
|
97
|
+
|
|
98
|
+
| Rule | Setting | Why |
|
|
99
|
+
| :------------------------------------------------------- | :--------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------ |
|
|
100
|
+
| `sort-imports` | Warn. Groups separated by a blank line are sorted separately, ignoring case. | Imports are grouped by where they come from. |
|
|
101
|
+
| `import-x/no-duplicates` | Off | A long import list is split into several one-line imports from the same module. |
|
|
102
|
+
| `@eslint-community/eslint-comments/require-description` | Warn | A comment that switches a rule off should say why. |
|
|
103
|
+
| `unicorn/consistent-boolean-name` | Also allows the subject first, such as `viewportIsWide` | DPUse names a boolean after its subject, then the verb. |
|
|
104
|
+
| `unicorn/consistent-class-member-order` | Private methods after public methods | A private helper sits after the public methods that use it. |
|
|
105
|
+
| `unicorn/filename-case` | camelCase or PascalCase | Vue components use PascalCase file names. |
|
|
106
|
+
| `unicorn/no-asterisk-prefix-in-documentation-comments` | Off | VS Code adds the `*` prefix, and TypeScript drops it when reading the comment. |
|
|
107
|
+
| `unicorn/no-null` | Off | JSON uses `null`. |
|
|
108
|
+
| `unicorn/single-line-block-comment-style` | Off | A short block comment may stay on one line. |
|
|
109
|
+
| `unicorn/switch-case-braces` | Warn, no braces | A `case` needs braces only when it declares a variable. |
|
|
110
|
+
| `unicorn/text-encoding-identifier-case` | `utf-8`, with the dash | `utf-8` is the standard name, used by `TextDecoder` and accepted by Node.js. |
|
|
111
|
+
| `@typescript-eslint/no-unused-vars` | Warn. Names starting with `_` are allowed. | An underscore marks a value that exists only to be discarded. |
|
|
112
|
+
| `@typescript-eslint/no-unsafe-class-instance-assignment` | Off | In typescript-eslint 8.73.0 the rule overflows the stack on Vite and Rolldown plugin types. |
|
|
113
|
+
|
|
54
114
|
<!-- DEPENDENCY_LICENSES_START -->
|
|
55
115
|
|
|
56
116
|
## Dependency Licenses
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dpuse/eslint-config-dpuse",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.103",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Common ESLint configuration used across DPUse projects.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"typescript-eslint": "^8.73.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@dpuse/dpuse-development": "^1.0.
|
|
70
|
+
"@dpuse/dpuse-development": "^1.0.165",
|
|
71
71
|
"@types/node": "^26.6.6",
|
|
72
72
|
"@vitest/coverage-v8": "^5.1.1",
|
|
73
73
|
"eslint": "^10.15.0",
|