@lzear/eslint-config 4.2.1 → 4.3.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +47 -49
  3. package/package.json +24 -19
package/README.md CHANGED
@@ -94,7 +94,7 @@ export default config
94
94
 
95
95
  ## Included plugins
96
96
 
97
- `@eslint/js` · `typescript-eslint` · `eslint-plugin-unicorn` · `eslint-plugin-sonarjs` · `eslint-plugin-import-x` · `eslint-plugin-promise` · `eslint-plugin-regexp` · `eslint-plugin-react` · `eslint-plugin-react-hooks` · `eslint-plugin-jsx-a11y` · `eslint-plugin-n` · `@vitest/eslint-plugin` · `eslint-plugin-package-json` · `eslint-config-prettier` · and more.
97
+ `@eslint/js` · `typescript-eslint` · `eslint-plugin-unicorn` · `eslint-plugin-sonarjs` · `eslint-plugin-import-x` · `eslint-plugin-promise` · `eslint-plugin-regexp` · `eslint-plugin-react` · `eslint-plugin-react-hooks` · `eslint-plugin-jsx-a11y` · `eslint-plugin-n` · `@vitest/eslint-plugin` · `eslint-package-json` · `eslint-config-prettier` · and more.
98
98
 
99
99
  ## Part of forge
100
100
 
package/dist/index.js CHANGED
@@ -49,8 +49,8 @@ var simplify = (version) => {
49
49
  const target = `${operator}${major}`;
50
50
  return target === version ? null : target;
51
51
  };
52
- var isIgnored = (pkgName, ignore) => ignore.some(
53
- (pattern) => pattern instanceof RegExp ? pattern.test(pkgName) : pattern === pkgName
52
+ var isIgnored = (packageName, ignore) => ignore.some(
53
+ (pattern) => pattern instanceof RegExp ? pattern.test(packageName) : pattern === packageName
54
54
  );
55
55
  var majorVersionOnly = {
56
56
  meta: {
@@ -86,24 +86,21 @@ var majorVersionOnly = {
86
86
  }
87
87
  },
88
88
  create: (context) => {
89
- const opts = context.options[0];
90
- const ignore = (opts?.ignore ?? []).map(
89
+ const options = context.options[0];
90
+ const ignore = (options?.ignore ?? []).map(
91
91
  (item) => typeof item === "string" ? item : new RegExp(item.regex)
92
92
  );
93
93
  return {
94
- JSONProperty: (rawNode) => {
94
+ Member: (rawNode) => {
95
95
  const node2 = rawNode;
96
- const keyName = node2.key.type === "JSONLiteral" ? String(node2.key.value) : node2.key.name ?? "";
97
- if (!DEP_FIELDS.has(keyName)) return;
98
- const depsNode = node2.value;
99
- if (depsNode.type !== "JSONObjectExpression") return;
100
- for (const prop of depsNode.properties) {
101
- const pkgName = prop.key.type === "JSONLiteral" ? String(prop.key.value) : prop.key.name ?? "";
102
- if (isIgnored(pkgName, ignore)) continue;
103
- const versionNode = prop.value;
104
- if (versionNode.type !== "JSONLiteral") continue;
96
+ if (!DEP_FIELDS.has(node2.name.value)) return;
97
+ const dependenciesNode = node2.value;
98
+ if (dependenciesNode.type !== "Object") return;
99
+ for (const member of dependenciesNode.members) {
100
+ if (isIgnored(member.name.value, ignore)) continue;
101
+ const versionNode = member.value;
102
+ if (versionNode.type !== "String") continue;
105
103
  const version = versionNode.value;
106
- if (typeof version !== "string") continue;
107
104
  const suggested = simplify(version);
108
105
  if (!suggested) continue;
109
106
  context.report({
@@ -124,12 +121,12 @@ import path from "path";
124
121
  // utils.ts
125
122
  var interopDefault = async (m) => {
126
123
  const resolved = await m;
127
- const mod = resolved.default ?? resolved;
128
- if (mod.__esModule) {
129
- const inner = mod.default;
124
+ const module_ = resolved.default ?? resolved;
125
+ if (module_.__esModule) {
126
+ const inner = module_.default;
130
127
  if (inner !== void 0) return inner;
131
128
  }
132
- return mod;
129
+ return module_;
133
130
  };
134
131
 
135
132
  // plugin/rules/prefer-relative-imports.ts
@@ -144,10 +141,10 @@ var toRelative = (from, importPath, context) => {
144
141
  if (!rel) return null;
145
142
  if (!rel.startsWith(".")) rel = `./${rel}`;
146
143
  if (!path.extname(importPath)) {
147
- const ext = path.extname(rel);
148
- if (ext) {
149
- const withoutExt = rel.slice(0, -ext.length);
150
- rel = withoutExt.endsWith("/index") ? withoutExt.slice(0, -"/index".length) || "." : withoutExt;
144
+ const extension = path.extname(rel);
145
+ if (extension) {
146
+ const withoutExtension = rel.slice(0, -extension.length);
147
+ rel = withoutExtension.endsWith("/index") ? withoutExtension.slice(0, -"/index".length) || "." : withoutExtension;
151
148
  if (!rel.startsWith(".")) rel = `./${rel}`;
152
149
  }
153
150
  }
@@ -174,8 +171,8 @@ var preferRelativeImports = {
174
171
  }
175
172
  },
176
173
  create: (context) => {
177
- const opts = context.options[0];
178
- const maxParentPrefixes = opts?.maxParentPrefixes ?? 1;
174
+ const options = context.options[0];
175
+ const maxParentPrefixes = options?.maxParentPrefixes ?? 1;
179
176
  const filename = context.physicalFilename;
180
177
  const check = (source) => {
181
178
  const importPath = source.value;
@@ -246,8 +243,8 @@ var core = (local) => {
246
243
  groups: [
247
244
  [
248
245
  "^node:",
249
- l && String.raw`^@?(?!` + l + String.raw`\/)\w`,
250
- l && String.raw`^@` + l + String.raw`\/`,
246
+ l && "^@?(?!" + l + String.raw`\/)\w`,
247
+ l && "^@" + l + String.raw`\/`,
251
248
  "^",
252
249
  String.raw`^\.`,
253
250
  String.raw`^.+\.s?css$`
@@ -288,8 +285,14 @@ var core = (local) => {
288
285
  "sonarjs/todo-tag": 0,
289
286
  "sonarjs/void-use": 0,
290
287
  ...unicornPlugin.configs.recommended.rules,
288
+ "unicorn/consistent-boolean-name": 0,
289
+ // a bit annoying
290
+ "unicorn/name-replacements": 0,
291
+ // i like my abbreviations
291
292
  "unicorn/no-abusive-eslint-disable": 0,
292
293
  "unicorn/no-null": 0,
294
+ "unicorn/prefer-await": 0,
295
+ // await fn().catch() is convenient
293
296
  "unicorn/prevent-abbreviations": 0,
294
297
  "unicorn/switch-case-braces": [2, "avoid"]
295
298
  };
@@ -380,27 +383,22 @@ var node = async (config) => {
380
383
  };
381
384
 
382
385
  // configs/package-json.ts
383
- import * as packageJsonPlugin from "eslint-plugin-package-json";
384
- import * as jsoncParser from "jsonc-eslint-parser";
385
- var packageJson = () => ({
386
- name: "lzear/package-json",
387
- files: ["**/package.json"],
388
- plugins: {
389
- lzear: plugin,
390
- "package-json": packageJsonPlugin
391
- },
392
- languageOptions: {
393
- parser: jsoncParser
394
- },
395
- rules: {
396
- ...packageJsonPlugin.configs.recommended.rules,
397
- "lzear/major-version-only": 2,
398
- "package-json/repository-shorthand": [2, { form: "shorthand" }]
386
+ import packageJsonPlugin from "eslint-package-json";
387
+ var packageJson = () => [
388
+ packageJsonPlugin.configs.recommended,
389
+ {
390
+ name: "lzear/package-json",
391
+ files: ["**/package.json"],
392
+ plugins: {
393
+ lzear: plugin
394
+ },
395
+ rules: {
396
+ "lzear/major-version-only": 2
397
+ }
399
398
  }
400
- });
399
+ ];
401
400
 
402
401
  // configs/prettier.ts
403
- import "eslint";
404
402
  import prettierConfig from "eslint-plugin-prettier/recommended";
405
403
  var { curly: _curly, ...prettierRules } = prettierConfig.rules ?? {};
406
404
  var prettier = {
@@ -423,7 +421,7 @@ var react = async (config) => {
423
421
  const [
424
422
  reactCompilerPlugin,
425
423
  reactHooksPlugin,
426
- reactPerfPlugin,
424
+ reactPerformancePlugin,
427
425
  reactPlugin,
428
426
  reactXPlugin,
429
427
  reactDomPlugin,
@@ -447,20 +445,20 @@ var react = async (config) => {
447
445
  "react-compiler": reactCompilerPlugin,
448
446
  "react-dom": reactDomPlugin,
449
447
  "react-hooks": reactHooksPlugin,
450
- "react-perf": reactPerfPlugin,
448
+ "react-perf": reactPerformancePlugin,
451
449
  "react-web-api": reactWebApiPlugin,
452
450
  "react-x": reactXPlugin
453
451
  },
454
452
  rules: {
455
453
  "react-compiler/react-compiler": 2,
456
454
  ...reactHooksPlugin.configs.recommended.rules,
457
- ...reactPerfPlugin.configs.recommended.rules,
455
+ ...reactPerformancePlugin.configs.recommended.rules,
458
456
  "react-perf/jsx-no-new-function-as-prop": 0,
459
457
  "react-perf/jsx-no-new-object-as-prop": 0,
460
458
  ...reactPlugin.configs.recommended.rules,
461
459
  "react/react-in-jsx-scope": 0,
462
460
  "react/no-unknown-property": [2, { ignore: ["jsx", "global"] }],
463
- ...config.typescript ? reactXPlugin.configs["recommended-typescript"].rules : reactXPlugin.configs.recommended.rules,
461
+ ...reactXPlugin.configs[config.typescript ? "recommended-typescript" : "recommended"].rules,
464
462
  ...reactDomPlugin.configs.recommended.rules,
465
463
  ...reactWebApiPlugin.configs.recommended.rules
466
464
  },
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "@lzear/eslint-config",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "Shared ESLint flat config for lzear repos",
5
+ "license": "MIT",
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "git+https://github.com/lzear/forge.git",
8
9
  "directory": "packages/eslint-config"
9
10
  },
10
11
  "author": "lzear",
11
- "license": "MIT",
12
- "sideEffects": false,
13
12
  "type": "module",
14
13
  "exports": {
15
14
  ".": {
@@ -17,15 +16,30 @@
17
16
  "default": "./dist/index.js"
18
17
  }
19
18
  },
20
- "files": [
21
- "dist"
22
- ],
19
+ "sideEffects": false,
20
+ "engines": {
21
+ "node": ">=24"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "provenance": true
26
+ },
23
27
  "scripts": {
24
28
  "build": "tsup",
25
29
  "dev": "tsup --watch",
26
30
  "test": "vitest run",
27
31
  "typecheck": "tsc --noEmit"
28
32
  },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "keywords": [
37
+ "eslint",
38
+ "eslint-config",
39
+ "eslintconfig",
40
+ "flat-config",
41
+ "lint"
42
+ ],
29
43
  "dependencies": {
30
44
  "@eslint-community/eslint-plugin-eslint-comments": "^4",
31
45
  "@eslint/js": "^10",
@@ -34,11 +48,11 @@
34
48
  "eslint-config-prettier": "^10",
35
49
  "eslint-import-resolver-typescript": "^4",
36
50
  "eslint-module-utils": "^2",
51
+ "eslint-package-json": "^0.1",
37
52
  "eslint-plugin-de-morgan": "^2",
38
53
  "eslint-plugin-import-x": "^4",
39
54
  "eslint-plugin-jsx-a11y": "^6",
40
55
  "eslint-plugin-n": "^18",
41
- "eslint-plugin-package-json": "^1",
42
56
  "eslint-plugin-prefer-arrow": "^1",
43
57
  "eslint-plugin-prettier": "^5",
44
58
  "eslint-plugin-promise": "^7",
@@ -52,28 +66,19 @@
52
66
  "eslint-plugin-regexp": "^3",
53
67
  "eslint-plugin-simple-import-sort": "^13",
54
68
  "eslint-plugin-sonarjs": "^4",
55
- "eslint-plugin-unicorn": "^64",
69
+ "eslint-plugin-unicorn": "^71",
56
70
  "globals": "^17",
57
- "jsonc-eslint-parser": "^3",
58
71
  "prettier": "^3",
59
72
  "typescript-eslint": "^8"
60
73
  },
61
74
  "devDependencies": {
62
- "@lzear/configs": "4.2.1",
75
+ "@lzear/configs": "4.3.0",
63
76
  "@vitest/coverage-v8": "^4",
64
77
  "eslint": "^10",
65
78
  "tsup": "^8",
66
- "typescript": "^6",
67
79
  "vitest": "^4"
68
80
  },
69
81
  "peerDependencies": {
70
- "eslint": "^9"
71
- },
72
- "engines": {
73
- "node": ">=24"
74
- },
75
- "publishConfig": {
76
- "access": "public",
77
- "provenance": true
82
+ "eslint": "^10"
78
83
  }
79
84
  }