@lifeofqui/lint-config 1.1.0 → 1.2.1
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 +22 -10
- package/eslint.d.ts +5 -0
- package/eslint.js +18 -0
- package/oxfmt.d.ts +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -52,11 +52,12 @@ export default defineLintConfig()
|
|
|
52
52
|
|
|
53
53
|
Optionen von `defineLintConfig`:
|
|
54
54
|
|
|
55
|
-
| Option | Default | Zweck
|
|
56
|
-
| ------------------ | -------------------- |
|
|
57
|
-
| `ignores` | `[]` | Zusätzliche Ignore-Globs (Nuxt-Build-Ordner sind schon drin)
|
|
58
|
-
| `oxlintConfigFile` | `'./.oxlintrc.json'` | Oxlint-Config des Projekts, deren Regeln ESLint abschaltet
|
|
59
|
-
| `
|
|
55
|
+
| Option | Default | Zweck |
|
|
56
|
+
| ------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `ignores` | `[]` | Zusätzliche Ignore-Globs (Nuxt-Build-Ordner sind schon drin) |
|
|
58
|
+
| `oxlintConfigFile` | `'./.oxlintrc.json'` | Oxlint-Config des Projekts, deren Regeln ESLint abschaltet |
|
|
59
|
+
| `gitignore` | `'.gitignore'` | Ignore-Datei (relativ zum Arbeitsverzeichnis), deren Muster ESLint überspringt, wie Oxlint und Oxfmt. Fehlt sie, passiert nichts; `false` schaltet es ab |
|
|
60
|
+
| `configs` | `[]` | Projektspezifische Flat-Configs, werden nach den geteilten angewendet |
|
|
60
61
|
|
|
61
62
|
**Scripts** (Standard, `npm-run-all` im Projekt)
|
|
62
63
|
|
|
@@ -76,18 +77,29 @@ Optionen von `defineLintConfig`:
|
|
|
76
77
|
## Projektspezifische Anpassungen
|
|
77
78
|
|
|
78
79
|
- **Oxlint**: eigene `rules` / `overrides` in `.oxlintrc.json` nach dem `extends`. Spätere Einträge gewinnen.
|
|
79
|
-
- **Oxfmt**: `export default { ...base, printWidth: 120 }`
|
|
80
|
+
- **Oxfmt**: `export default { ...base, printWidth: 120 }`, zusätzliche Ignores mit `ignorePatterns: [...base.ignorePatterns, 'datei.json']`
|
|
80
81
|
- **ESLint**: `defineLintConfig({ configs: [{ files: ['…'], rules: { … } }] })`
|
|
81
82
|
|
|
82
83
|
## Updates verteilen
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
Tool-Updates kommen per Dependabot (`.github/dependabot.yml`): wöchentlich ein gesammelter PR für alle Minor- und Patch-Updates, Majors als eigene PRs. Regeländerungen werden direkt hier gemacht. Tool-Versionen immer exakt pinnen.
|
|
86
|
+
|
|
87
|
+
1. Die CI prüft jeden PR mit `npm test` (`test/smoke.sh`). Das Skript packt das Paket, installiert es in eine Kopie von `test/fixture` und prüft, dass `eslint`, `oxlint` und `oxfmt` in `node_modules/.bin` liegen. Dann laufen alle drei Tools über das Fixture, und Oxlint und ESLint müssen je einen bekannten Verstoß melden.
|
|
88
|
+
2. Bei größeren Änderungen zusätzlich in einem echten Projekt testen: `npm pack`, dort `npm i -D ../lint-config/lifeofqui-lint-config-<version>.tgz`, dann `npm run lint:check` und `npm run build`.
|
|
89
|
+
3. Nach dem Merge lokal auf `main`: `npm version patch|minor|major` und `git push --follow-tags`. Der Tag startet `.github/workflows/publish.yml`. Der Workflow lässt `npm test` laufen und legt die Version dann per npm Trusted Publishing als Staged Publish ab.
|
|
90
|
+
4. Freigeben: auf npmjs.com im Tab „Staged Packages“ auf Approve klicken, oder `npm stage approve <stage-id>` (beides mit 2FA). Erst dann ist die Version live.
|
|
91
|
+
5. In den Projekten öffnet Dependabot einen PR, die CI prüft ihn mit `npm run lint:check`.
|
|
92
|
+
|
|
93
|
+
Einmalig auf npmjs.com einrichten: Paket → Settings → Trusted Publisher → GitHub Actions mit Owner `LifeOfQui`, Repository `lint-config` und Workflow `publish.yml`. „Allow npm publish“ bleibt aus, damit jede Version die Freigabe mit 2FA braucht.
|
|
88
94
|
|
|
89
95
|
Semver: neue oder verschärfte Regeln und Tool-Updates mit Formatierungsänderungen → `minor`, Lockerungen und Fixes → `patch`, geänderte Datei-Struktur oder Optionen → `major`.
|
|
90
96
|
|
|
97
|
+
## Stolperfalle: Inline-Handler mit mehreren Anweisungen
|
|
98
|
+
|
|
99
|
+
Oxfmt entfernt mit `semi: false` das `;` aus Vue-Handlern wie `@click="a = 1; b = 2"` und schreibt die Anweisungen untereinander. Der Vue-Compiler erkennt mehrere Anweisungen aber nur am `;` und bricht dann den **Build** ab („Error parsing JavaScript expression“). Lint und Typecheck merken davon nichts.
|
|
100
|
+
|
|
101
|
+
Deshalb keine Inline-Handler mit mehreren Anweisungen schreiben, sondern eine Funktion aufrufen (`@click="resetFilters"`). Nach einer Umstellung auf dieses Paket immer auch `npm run build` laufen lassen.
|
|
102
|
+
|
|
91
103
|
## Hinweis zu eslint-plugin-oxlint
|
|
92
104
|
|
|
93
105
|
`eslint-plugin-oxlint` übernimmt bei `extends` keine `categories`. `defineLintConfig` liest deshalb zusätzlich die Basis-Datei direkt ein, damit ESLint alle Regeln abschaltet, die Oxlint über Kategorien abdeckt.
|
package/eslint.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export interface LintConfigOptions {
|
|
|
5
5
|
ignores?: string[]
|
|
6
6
|
/** Oxlint config whose rules ESLint turns off. Defaults to `./.oxlintrc.json`. */
|
|
7
7
|
oxlintConfigFile?: string
|
|
8
|
+
/**
|
|
9
|
+
* Ignore file whose patterns ESLint skips, relative to the working directory. Defaults to
|
|
10
|
+
* `.gitignore`; skipped silently if missing. `false` turns it off.
|
|
11
|
+
*/
|
|
12
|
+
gitignore?: string | false
|
|
8
13
|
/** Project-specific flat configs, applied after the shared ones. */
|
|
9
14
|
configs?: Linter.Config[]
|
|
10
15
|
}
|
package/eslint.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
|
|
2
|
+
import { includeIgnoreFile } from 'eslint/config'
|
|
2
3
|
import skipFormatting from 'eslint-config-prettier'
|
|
3
4
|
import pluginOxlint from 'eslint-plugin-oxlint'
|
|
4
5
|
import pluginVue from 'eslint-plugin-vue'
|
|
6
|
+
import { existsSync } from 'node:fs'
|
|
7
|
+
import { resolve } from 'node:path'
|
|
5
8
|
import { fileURLToPath } from 'node:url'
|
|
6
9
|
|
|
7
10
|
const baseOxlintConfigFile = fileURLToPath(new URL('./oxlintrc.json', import.meta.url))
|
|
@@ -15,14 +18,29 @@ const defaultIgnores = ['**/.output', '**/.data', '**/.nuxt', '**/.nitro', '**/.
|
|
|
15
18
|
* @param {object} [options]
|
|
16
19
|
* @param {string[]} [options.ignores] Extra ignore globs, added to the Nuxt build output dirs.
|
|
17
20
|
* @param {string} [options.oxlintConfigFile] Oxlint config whose rules ESLint turns off.
|
|
21
|
+
* @param {string | false} [options.gitignore] Ignore file whose patterns ESLint skips, relative to the
|
|
22
|
+
* working directory. Skipped silently if missing; `false` turns it off.
|
|
18
23
|
* @param {object[]} [options.configs] Project-specific flat configs, applied after the shared ones.
|
|
19
24
|
*/
|
|
20
25
|
export function defineLintConfig({
|
|
21
26
|
ignores = [],
|
|
22
27
|
oxlintConfigFile = './.oxlintrc.json',
|
|
28
|
+
gitignore = '.gitignore',
|
|
23
29
|
configs = [],
|
|
24
30
|
} = {}) {
|
|
31
|
+
const gitignoreFile = gitignore === false ? null : resolve(gitignore)
|
|
32
|
+
|
|
25
33
|
return [
|
|
34
|
+
// Lint the same files as Oxlint and Oxfmt, which both respect .gitignore
|
|
35
|
+
...(gitignoreFile && existsSync(gitignoreFile)
|
|
36
|
+
? [
|
|
37
|
+
includeIgnoreFile(gitignoreFile, {
|
|
38
|
+
gitignoreResolution: true,
|
|
39
|
+
name: 'lifeofqui/gitignore',
|
|
40
|
+
}),
|
|
41
|
+
]
|
|
42
|
+
: []),
|
|
43
|
+
|
|
26
44
|
...defineConfigWithVueTs(
|
|
27
45
|
{ ignores: [...defaultIgnores, ...ignores] },
|
|
28
46
|
|
package/oxfmt.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifeofqui/lint-config",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Shared ESLint, Oxlint and Oxfmt setup for Vue/Nuxt projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Quirin Koch",
|
|
@@ -31,9 +31,12 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"test": "test/smoke.sh"
|
|
36
|
+
},
|
|
34
37
|
"dependencies": {
|
|
35
38
|
"@vue/eslint-config-typescript": "14.9.0",
|
|
36
|
-
"eslint": "10.
|
|
39
|
+
"eslint": "10.14.0",
|
|
37
40
|
"eslint-config-prettier": "10.1.8",
|
|
38
41
|
"eslint-plugin-oxlint": "1.90.0",
|
|
39
42
|
"eslint-plugin-vue": "10.12.0",
|