@lifeofqui/lint-config 1.0.1 → 1.2.0

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 CHANGED
@@ -8,11 +8,19 @@ Das Paket bringt Regeln **und** Tool-Versionen mit: `eslint`, `oxlint` und `oxfm
8
8
 
9
9
  ## Setup in einem Projekt
10
10
 
11
+ Zuerst die bisherigen Lint-Pakete deinstallieren, **dann** das Paket installieren (zwei getrennte Befehle):
12
+
13
+ ```bash
14
+ npm uninstall eslint oxlint oxfmt eslint-plugin-oxlint eslint-plugin-vue @vue/eslint-config-typescript eslint-config-prettier @vue/eslint-config-prettier @nuxt/eslint
15
+ ```
16
+
11
17
  ```bash
12
18
  npm i -D @lifeofqui/lint-config
13
19
  ```
14
20
 
15
- `eslint`, `oxlint`, `oxfmt`, `eslint-plugin-oxlint`, `eslint-plugin-vue`, `@vue/eslint-config-typescript` und `eslint-config-prettier` aus den devDependencies des Projekts entfernen.
21
+ Die Reihenfolge ist wichtig: Liegt beim Install noch eine andere Version von `oxfmt`, `oxlint` oder `eslint` im Projekt, legt npm die mitgelieferte Version verschachtelt unter `node_modules/@lifeofqui/lint-config/node_modules/` ab und das Binary fehlt in `node_modules/.bin`. Prüfen mit `ls node_modules/.bin | grep -E '^(eslint|oxlint|oxfmt)$'`. Falls doch passiert: `npm uninstall @lifeofqui/lint-config` und neu installieren. `npm dedupe` hilft hier nicht.
22
+
23
+ Ist `@nuxt/eslint` auch in `modules` der `nuxt.config.ts` eingetragen, den Eintrag dort ebenfalls entfernen.
16
24
 
17
25
  **`.oxlintrc.json`**
18
26
 
@@ -44,11 +52,12 @@ export default defineLintConfig()
44
52
 
45
53
  Optionen von `defineLintConfig`:
46
54
 
47
- | Option | Default | Zweck |
48
- | ------------------ | -------------------- | --------------------------------------------------------------------- |
49
- | `ignores` | `[]` | Zusätzliche Ignore-Globs (Nuxt-Build-Ordner sind schon drin) |
50
- | `oxlintConfigFile` | `'./.oxlintrc.json'` | Oxlint-Config des Projekts, deren Regeln ESLint abschaltet |
51
- | `configs` | `[]` | Projektspezifische Flat-Configs, werden nach den geteilten angewendet |
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 |
52
61
 
53
62
  **Scripts** (Standard, `npm-run-all` im Projekt)
54
63
 
@@ -68,7 +77,7 @@ Optionen von `defineLintConfig`:
68
77
  ## Projektspezifische Anpassungen
69
78
 
70
79
  - **Oxlint**: eigene `rules` / `overrides` in `.oxlintrc.json` nach dem `extends`. Spätere Einträge gewinnen.
71
- - **Oxfmt**: `export default { ...base, printWidth: 120 }`
80
+ - **Oxfmt**: `export default { ...base, printWidth: 120 }`, zusätzliche Ignores mit `ignorePatterns: [...base.ignorePatterns, 'datei.json']`
72
81
  - **ESLint**: `defineLintConfig({ configs: [{ files: ['…'], rules: { … } }] })`
73
82
 
74
83
  ## Updates verteilen
@@ -80,6 +89,12 @@ Optionen von `defineLintConfig`:
80
89
 
81
90
  Semver: neue oder verschärfte Regeln und Tool-Updates mit Formatierungsänderungen → `minor`, Lockerungen und Fixes → `patch`, geänderte Datei-Struktur oder Optionen → `major`.
82
91
 
92
+ ## Stolperfalle: Inline-Handler mit mehreren Anweisungen
93
+
94
+ 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.
95
+
96
+ 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.
97
+
83
98
  ## Hinweis zu eslint-plugin-oxlint
84
99
 
85
100
  `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
@@ -1,4 +1,4 @@
1
1
  import type { OxfmtConfig } from 'oxfmt'
2
2
 
3
- declare const config: OxfmtConfig
3
+ declare const config: OxfmtConfig & { ignorePatterns: string[] }
4
4
  export default config
package/oxlintrc.json CHANGED
@@ -25,6 +25,7 @@
25
25
  "import/no-duplicates": "error",
26
26
  "import/no-mutable-exports": "error",
27
27
  "import/no-named-default": "error",
28
+ "import/no-unassigned-import": ["warn", { "allow": ["**/*.css"] }],
28
29
  "unicorn/error-message": "error",
29
30
  "unicorn/escape-case": "error",
30
31
  "unicorn/no-abusive-eslint-disable": "error",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifeofqui/lint-config",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Shared ESLint, Oxlint and Oxfmt setup for Vue/Nuxt projects",
5
5
  "license": "MIT",
6
6
  "author": "Quirin Koch",
@@ -37,7 +37,7 @@
37
37
  "eslint-config-prettier": "10.1.8",
38
38
  "eslint-plugin-oxlint": "1.90.0",
39
39
  "eslint-plugin-vue": "10.12.0",
40
- "oxfmt": "0.70.0",
40
+ "oxfmt": "0.75.0",
41
41
  "oxlint": "1.90.0"
42
42
  },
43
43
  "engines": {