@eienjs/eslint-config 1.9.2 → 1.10.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.
@@ -1,11 +1,11 @@
1
1
  //#region src/cli/constants_generated.ts
2
2
  const versionsMap = {
3
- "@adonisjs/eslint-plugin": "^2.2.1",
4
- "@nuxt/eslint-plugin": "^1.13.0",
5
- "astro-eslint-parser": "^1.2.2",
6
- "eslint": "^9.39.2",
7
- "eslint-plugin-astro": "^1.5.0",
8
- "eslint-plugin-format": "^1.3.1",
3
+ "@adonisjs/eslint-plugin": "^2.2.2",
4
+ "@nuxt/eslint-plugin": "^1.15.2",
5
+ "astro-eslint-parser": "^1.3.0",
6
+ "eslint": "^10.0.2",
7
+ "eslint-plugin-astro": "^1.6.0",
8
+ "eslint-plugin-format": "^2.0.1",
9
9
  "prettier-plugin-astro": "^0.14.1"
10
10
  };
11
11
 
@@ -1,6 +1,6 @@
1
1
  import { getEslintConfigContent } from "../utils.mjs";
2
2
  import process from "node:process";
3
- import fsPromises from "node:fs/promises";
3
+ import fsp from "node:fs/promises";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
6
  import * as p from "@clack/prompts";
@@ -12,13 +12,13 @@ async function updateEslintFiles(result) {
12
12
  const cwd = process.cwd();
13
13
  const pathESLintIgnore = path.join(cwd, ".eslintignore");
14
14
  const pathPackageJSON = path.join(cwd, "package.json");
15
- const pkgContent = await fsPromises.readFile(pathPackageJSON, "utf8");
15
+ const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
16
16
  const configFileName = JSON.parse(pkgContent).type === "module" ? "eslint.config.js" : "eslint.config.mjs";
17
17
  const pathFlatConfig = path.join(cwd, configFileName);
18
18
  const eslintIgnores = [];
19
19
  if (fs.existsSync(pathESLintIgnore)) {
20
20
  p.log.step(c.cyan`Migrating existing .eslintignore`);
21
- const globs = parse(await fsPromises.readFile(pathESLintIgnore, "utf8")).globs();
21
+ const globs = parse(await fsp.readFile(pathESLintIgnore, "utf8")).globs();
22
22
  for (const glob of globs) if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
23
23
  else if (glob.type === "unignore") eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
24
24
  }
@@ -27,7 +27,7 @@ async function updateEslintFiles(result) {
27
27
  if (result.extra.includes("formatter")) configLines.push("formatters: true,");
28
28
  for (const framework of result.frameworks) configLines.push(`${framework}: true,`);
29
29
  const eslintConfigContent = getEslintConfigContent(configLines.map((i) => ` ${i}`).join("\n"));
30
- await fsPromises.writeFile(pathFlatConfig, eslintConfigContent);
30
+ await fsp.writeFile(pathFlatConfig, eslintConfigContent);
31
31
  p.log.success(c.green`Created ${configFileName}`);
32
32
  const files = fs.readdirSync(cwd);
33
33
  const legacyConfig = [];
@@ -2,7 +2,7 @@ import { version } from "../../package.mjs";
2
2
  import { dependenciesMap } from "../constants.mjs";
3
3
  import { versionsMap } from "../constants_generated.mjs";
4
4
  import process from "node:process";
5
- import fsPromises from "node:fs/promises";
5
+ import fsp from "node:fs/promises";
6
6
  import path from "node:path";
7
7
  import * as p from "@clack/prompts";
8
8
  import c from "ansis";
@@ -12,7 +12,7 @@ async function updatePackageJson(result) {
12
12
  const cwd = process.cwd();
13
13
  const pathPackageJSON = path.join(cwd, "package.json");
14
14
  p.log.step(c.cyan`Bumping @eienjs/eslint-config to v${version}`);
15
- const pkgContent = await fsPromises.readFile(pathPackageJSON, "utf8");
15
+ const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
16
16
  const pkg = JSON.parse(pkgContent);
17
17
  pkg.devDependencies = pkg.devDependencies ?? {};
18
18
  pkg.devDependencies["@eienjs/eslint-config"] = `^${version}`;
@@ -38,7 +38,7 @@ async function updatePackageJson(result) {
38
38
  }
39
39
  }
40
40
  if (addedPackages.length > 0) p.note(c.dim(addedPackages.join(", ")), "Added packages");
41
- await fsPromises.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
41
+ await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
42
42
  p.log.success(c.green`Changes wrote to package.json`);
43
43
  }
44
44
 
@@ -1,6 +1,6 @@
1
1
  import { vscodeSettingsString } from "../constants.mjs";
2
2
  import process from "node:process";
3
- import fsPromises from "node:fs/promises";
3
+ import fsp from "node:fs/promises";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
6
  import * as p from "@clack/prompts";
@@ -12,16 +12,16 @@ async function updateVscodeSettings(result) {
12
12
  if (!result.updateVscodeSettings) return;
13
13
  const dotVscodePath = path.join(cwd, ".vscode");
14
14
  const settingsPath = path.join(dotVscodePath, "settings.json");
15
- if (!fs.existsSync(dotVscodePath)) await fsPromises.mkdir(dotVscodePath, { recursive: true });
15
+ if (!fs.existsSync(dotVscodePath)) await fsp.mkdir(dotVscodePath, { recursive: true });
16
16
  if (fs.existsSync(settingsPath)) {
17
- let settingsContent = await fsPromises.readFile(settingsPath, "utf8");
17
+ let settingsContent = await fsp.readFile(settingsPath, "utf8");
18
18
  settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
19
19
  settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
20
20
  settingsContent += `${vscodeSettingsString}}\n`;
21
- await fsPromises.writeFile(settingsPath, settingsContent, "utf8");
21
+ await fsp.writeFile(settingsPath, settingsContent, "utf8");
22
22
  p.log.success(green`Updated .vscode/settings.json`);
23
23
  } else {
24
- await fsPromises.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf8");
24
+ await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf8");
25
25
  p.log.success(green`Created .vscode/settings.json`);
26
26
  }
27
27
  }
@@ -74,7 +74,8 @@ async function adonisjs(options = {}) {
74
74
  name: "eienjs/adonisjs/bin-disables",
75
75
  rules: {
76
76
  ...commonRulesSet,
77
- "@typescript-eslint/no-misused-promises": "off"
77
+ "@typescript-eslint/no-misused-promises": "off",
78
+ "n/prefer-global/process": "off"
78
79
  }
79
80
  },
80
81
  {
@@ -3,7 +3,7 @@ import { ensurePackages, interopDefault, isPackageInScope, parserPlain } from ".
3
3
  import { StylisticConfigDefaults } from "./stylistic.mjs";
4
4
 
5
5
  //#region src/configs/formatters.ts
6
- function mergePrettierOptions(options, overrides = {}) {
6
+ function mergePrettierOptions(options, overrides) {
7
7
  return {
8
8
  ...options,
9
9
  ...overrides,
@@ -1,6 +1,6 @@
1
1
  import { TypedFlatConfigItem } from "../types.mjs";
2
2
 
3
3
  //#region src/configs/ignores.d.ts
4
- declare function ignores(userIgnores?: string[] | ((originals: string[]) => string[])): TypedFlatConfigItem[];
4
+ declare function ignores(userIgnores?: string[] | ((originals: string[]) => string[]), ignoreTypescript?: boolean): TypedFlatConfigItem[];
5
5
  //#endregion
6
6
  export { ignores };
@@ -1,8 +1,9 @@
1
- import { GLOB_EXCLUDE } from "../globs.mjs";
1
+ import { GLOB_EXCLUDE, GLOB_TS, GLOB_TSX } from "../globs.mjs";
2
2
 
3
3
  //#region src/configs/ignores.ts
4
- function ignores(userIgnores = []) {
4
+ function ignores(userIgnores = [], ignoreTypescript = false) {
5
5
  let ignores = [...GLOB_EXCLUDE];
6
+ if (ignoreTypescript) ignores.push(GLOB_TS, GLOB_TSX);
6
7
  ignores = typeof userIgnores === "function" ? userIgnores(ignores) : [...ignores, ...userIgnores];
7
8
  return [{
8
9
  ignores,
@@ -45,7 +45,6 @@ function javascript(options = {}) {
45
45
  "default-case-last": "error",
46
46
  "dot-notation": ["error", { allowKeywords: true }],
47
47
  "eqeqeq": ["error", "smart"],
48
- "logical-assignment-operators": ["error", "never"],
49
48
  "new-cap": ["error", {
50
49
  capIsNew: false,
51
50
  newIsCap: true,
@@ -1,11 +1,15 @@
1
+ import { GLOB_SRC } from "../globs.mjs";
1
2
  import { interopDefault } from "../utils.mjs";
2
3
 
3
4
  //#region src/configs/jsdoc.ts
4
5
  async function jsdoc(options = {}) {
5
6
  const { stylistic = true } = options;
6
7
  return [{
8
+ name: "eienjs/jsdoc/setup",
9
+ plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) }
10
+ }, {
11
+ files: [GLOB_SRC],
7
12
  name: "eienjs/jsdoc/rules",
8
- plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
9
13
  rules: {
10
14
  "jsdoc/check-access": "warn",
11
15
  "jsdoc/check-param-names": "warn",
@@ -9,13 +9,12 @@ async function jsonc(options = {}) {
9
9
  GLOB_JSONC
10
10
  ], overrides = {}, stylistic = true } = options;
11
11
  const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
12
- const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
13
12
  return [{
14
13
  name: "eienjs/jsonc/setup",
15
- plugins: { jsonc: pluginJsonc }
14
+ plugins: { jsonc: await interopDefault(import("eslint-plugin-jsonc")) }
16
15
  }, {
17
16
  files,
18
- languageOptions: { parser: parserJsonc },
17
+ language: "jsonc/x",
19
18
  name: "eienjs/jsonc/rules",
20
19
  rules: {
21
20
  "jsonc/no-bigint-literals": "error",
@@ -1,6 +1,6 @@
1
- import { OptionsComponentExts, OptionsFiles, OptionsOverrides, TypedFlatConfigItem } from "../types.mjs";
1
+ import { OptionsComponentExts, OptionsFiles, OptionsMarkdown, TypedFlatConfigItem } from "../types.mjs";
2
2
 
3
3
  //#region src/configs/markdown.d.ts
4
- declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<TypedFlatConfigItem[]>;
4
+ declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsMarkdown): Promise<TypedFlatConfigItem[]>;
5
5
  //#endregion
6
6
  export { markdown };
@@ -1,10 +1,10 @@
1
1
  import { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN } from "../globs.mjs";
2
- import { interopDefault, parserPlain } from "../utils.mjs";
2
+ import { interopDefault } from "../utils.mjs";
3
3
  import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
4
4
 
5
5
  //#region src/configs/markdown.ts
6
6
  async function markdown(options = {}) {
7
- const { componentExts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
7
+ const { componentExts = [], files = [GLOB_MARKDOWN], gfm = true, overrides = {}, overridesMarkdown = {} } = options;
8
8
  const markdown = await interopDefault(import("@eslint/markdown"));
9
9
  return [
10
10
  {
@@ -19,9 +19,33 @@ async function markdown(options = {}) {
19
19
  },
20
20
  {
21
21
  files,
22
- languageOptions: { parser: parserPlain },
22
+ language: gfm ? "markdown/gfm" : "markdown/commonmark",
23
23
  name: "eienjs/markdown/parser"
24
24
  },
25
+ {
26
+ files,
27
+ name: "eienjs/markdown/rules",
28
+ rules: {
29
+ ...markdown.configs.recommended.at(0)?.rules,
30
+ "markdown/no-missing-label-refs": "off",
31
+ ...overridesMarkdown
32
+ }
33
+ },
34
+ {
35
+ files,
36
+ name: "eienjs/markdown/disables/markdown",
37
+ rules: {
38
+ "@stylistic/indent": "off",
39
+ "command/command": "off",
40
+ "no-irregular-whitespace": "off",
41
+ "perfectionist/sort-exports": "off",
42
+ "perfectionist/sort-imports": "off",
43
+ "regexp/no-legacy-features": "off",
44
+ "regexp/no-missing-g-flag": "off",
45
+ "regexp/no-useless-dollar-replacements": "off",
46
+ "regexp/no-useless-flag": "off"
47
+ }
48
+ },
25
49
  {
26
50
  files: [
27
51
  GLOB_MARKDOWN,
@@ -29,7 +53,7 @@ async function markdown(options = {}) {
29
53
  ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
30
54
  ],
31
55
  languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
32
- name: "eienjs/markdown/disables",
56
+ name: "eienjs/markdown/disables/code",
33
57
  rules: {
34
58
  "@stylistic/comma-dangle": "off",
35
59
  "@stylistic/eol-last": "off",
@@ -1,10 +1,14 @@
1
+ import { GLOB_SRC } from "../globs.mjs";
1
2
  import { pluginNode } from "../plugins.mjs";
2
3
 
3
4
  //#region src/configs/node.ts
4
5
  function node() {
5
6
  return [{
7
+ name: "eienjs/node/setup",
8
+ plugins: { n: pluginNode }
9
+ }, {
10
+ files: [GLOB_SRC],
6
11
  name: "eienjs/node/rules",
7
- plugins: { n: pluginNode },
8
12
  rules: {
9
13
  "n/handle-callback-err": ["error", "^(err|error)$"],
10
14
  "n/no-deprecated-api": "error",
@@ -10,17 +10,16 @@ async function detectCatalogUsage() {
10
10
  return yaml.includes("catalog:") || yaml.includes("catalogs:");
11
11
  }
12
12
  async function pnpm(options) {
13
- const [pluginPnpm, pluginYaml, yamlParser, jsoncParser] = await Promise.all([
13
+ const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
14
14
  interopDefault(import("eslint-plugin-pnpm")),
15
15
  interopDefault(import("eslint-plugin-yml")),
16
- interopDefault(import("yaml-eslint-parser")),
17
- interopDefault(import("jsonc-eslint-parser"))
16
+ interopDefault(import("yaml-eslint-parser"))
18
17
  ]);
19
18
  const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml = true } = options;
20
19
  const configs = [];
21
20
  if (json) configs.push({
22
21
  files: ["package.json", "**/package.json"],
23
- languageOptions: { parser: jsoncParser },
22
+ language: "jsonc/x",
24
23
  name: "eienjs/pnpm/package-json",
25
24
  plugins: { pnpm: pluginPnpm },
26
25
  rules: {
package/dist/factory.mjs CHANGED
@@ -68,7 +68,7 @@ function eienjs(options = {}) {
68
68
  ...enableGitignore
69
69
  })]));
70
70
  const typescriptOptions = resolveSubOptions(options, "typescript");
71
- configs.push(ignores(userIgnores), javascript({
71
+ configs.push(ignores(userIgnores, !enableTypeScript), javascript({
72
72
  isInEditor,
73
73
  overrides: getOverrides(options, "javascript")
74
74
  }), comments(), command(), perfectionist());
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { ConfigNames } from "./typegen.mjs";
2
- import { Awaitable, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsPnpm, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, Rules, StylisticConfig, TypedFlatConfigItem } from "./types.mjs";
1
+ import { ConfigNames, RuleOptions } from "./typegen.mjs";
2
+ import { Awaitable, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsMarkdown, OptionsNuxt, OptionsOverrides, OptionsPnpm, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, Rules, StylisticConfig, TypedFlatConfigItem } from "./types.mjs";
3
3
  import { ResolvedOptions, defaultPluginRenaming, eienjs, getOverrides, resolveSubOptions } from "./factory.mjs";
4
4
  import { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON } from "./config_presets.mjs";
5
5
  import { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML } from "./globs.mjs";
6
6
  import { combine, ensurePackages, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, toArray } from "./utils.mjs";
7
- export { Awaitable, CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsPnpm, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, ResolvedOptions, Rules, StylisticConfig, TypedFlatConfigItem, combine, eienjs as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
7
+ export { Awaitable, CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsMarkdown, OptionsNuxt, OptionsOverrides, OptionsPnpm, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, ResolvedOptions, RuleOptions, Rules, StylisticConfig, TypedFlatConfigItem, combine, eienjs as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
@@ -1,5 +1,5 @@
1
1
  import process from "node:process";
2
- import fsPromises from "node:fs/promises";
2
+ import fsp from "node:fs/promises";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
@@ -14,7 +14,7 @@ async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {})
14
14
  while (directory) {
15
15
  const filePath = isAbsoluteName ? name : path.join(directory, name);
16
16
  try {
17
- const stats = await fsPromises.stat(filePath);
17
+ const stats = await fsp.stat(filePath);
18
18
  if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
19
19
  } catch {}
20
20
  if (directory === stopAt || directory === root) break;
package/dist/package.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.9.2";
2
+ var version = "1.10.0";
3
3
 
4
4
  //#endregion
5
5
  export { version };