@luxass/eslint-config 4.2.8 → 4.2.9

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/dist/index.cjs CHANGED
@@ -93,7 +93,7 @@ module.exports = __toCommonJS(src_exports);
93
93
  // src/factory.ts
94
94
  var import_node_process3 = __toESM(require("process"), 1);
95
95
  var import_node_fs = require("fs");
96
- var import_local_pkg3 = require("local-pkg");
96
+ var import_local_pkg4 = require("local-pkg");
97
97
 
98
98
  // src/configs/comments.ts
99
99
  var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
@@ -830,25 +830,21 @@ async function ensure(packages) {
830
830
  return;
831
831
  }
832
832
  ;
833
- const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i));
833
+ const nonExistingPackages = packages.filter((i) => i && !(0, import_local_pkg.isPackageExists)(i));
834
834
  if (nonExistingPackages.length === 0) {
835
835
  return;
836
836
  }
837
- ;
838
837
  const { default: prompts } = await import("prompts");
839
838
  const { result } = await prompts([
840
839
  {
841
- name: "result",
842
840
  message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
841
+ name: "result",
843
842
  type: "confirm"
844
843
  }
845
844
  ]);
846
845
  if (result) {
847
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, {
848
- dev: true
849
- }));
846
+ await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
850
847
  }
851
- ;
852
848
  }
853
849
  function resolveSubOptions(options, key) {
854
850
  return typeof options[key] === "boolean" ? {} : options[key] || {};
@@ -2023,29 +2019,29 @@ async function react(options = {}) {
2023
2019
  // src/configs/frameworks/astro.ts
2024
2020
  async function astro(options) {
2025
2021
  const {
2026
- a11y = false,
2027
2022
  files = [GLOB_ASTRO],
2028
2023
  overrides = {},
2029
2024
  typescript: typescript2 = true,
2030
2025
  stylistic: stylistic2 = true
2031
2026
  } = options;
2027
+ await ensure([
2028
+ "eslint-plugin-astro",
2029
+ "astro-eslint-parser"
2030
+ ]);
2032
2031
  const [
2033
2032
  pluginAstro,
2034
2033
  parserAstro,
2035
- parserTs,
2036
- pluginA11y
2034
+ parserTs
2037
2035
  ] = await Promise.all([
2038
2036
  interop(import("eslint-plugin-astro")),
2039
2037
  interop(import("astro-eslint-parser")),
2040
- interop(import("@typescript-eslint/parser")),
2041
- ...a11y ? [interop(import("eslint-plugin-jsx-a11y"))] : []
2038
+ interop(import("@typescript-eslint/parser"))
2042
2039
  ]);
2043
2040
  return [
2044
2041
  {
2045
2042
  name: "luxass:astro:setup",
2046
2043
  plugins: {
2047
- astro: pluginAstro,
2048
- ...a11y ? { "jsx-a11y": pluginA11y } : {}
2044
+ astro: pluginAstro
2049
2045
  }
2050
2046
  },
2051
2047
  {
@@ -2167,18 +2163,21 @@ async function tailwindcss(options = {}) {
2167
2163
 
2168
2164
  // src/configs/formatters.ts
2169
2165
  var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
2166
+ var import_local_pkg3 = require("local-pkg");
2170
2167
  async function formatters(options = {}, stylistic2 = {}) {
2171
- await ensure([
2172
- "eslint-plugin-format"
2173
- ]);
2174
2168
  if (options === true) {
2175
2169
  options = {
2170
+ astro: (0, import_local_pkg3.isPackageExists)("astro"),
2176
2171
  css: true,
2177
2172
  graphql: true,
2178
2173
  html: true,
2179
2174
  markdown: true
2180
2175
  };
2181
2176
  }
2177
+ await ensure([
2178
+ "eslint-plugin-format",
2179
+ options.astro ? "prettier-plugin-astro" : void 0
2180
+ ]);
2182
2181
  const {
2183
2182
  indent,
2184
2183
  quotes,
@@ -2309,6 +2308,27 @@ async function formatters(options = {}, stylistic2 = {}) {
2309
2308
  }
2310
2309
  });
2311
2310
  }
2311
+ if (options.astro) {
2312
+ configs.push({
2313
+ name: "luxass:formatter:astro",
2314
+ files: [GLOB_ASTRO],
2315
+ languageOptions: {
2316
+ parser: parserPlain2
2317
+ },
2318
+ rules: {
2319
+ "format/prettier": [
2320
+ "error",
2321
+ {
2322
+ ...prettierOptions,
2323
+ parser: "astro",
2324
+ plugins: [
2325
+ "prettier-plugin-astro"
2326
+ ]
2327
+ }
2328
+ ]
2329
+ }
2330
+ });
2331
+ }
2312
2332
  if (options.graphql) {
2313
2333
  configs.push({
2314
2334
  name: "luxass:formatter:graphql",
@@ -2416,9 +2436,9 @@ async function luxass(options = {}, ...userConfigs) {
2416
2436
  nextjs: enableNextJS = false,
2417
2437
  react: enableReact = false,
2418
2438
  tailwindcss: enableTailwindCSS = false,
2419
- typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
2439
+ typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
2420
2440
  unocss: enableUnoCSS = false,
2421
- vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
2441
+ vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
2422
2442
  } = options;
2423
2443
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2424
2444
  if (stylisticOptions && !("jsx" in stylisticOptions)) {
package/dist/index.d.cts CHANGED
@@ -324,12 +324,6 @@ interface AstroOptions {
324
324
  * @default true
325
325
  */
326
326
  typescript?: boolean;
327
- /**
328
- * Enable React A11y support.
329
- *
330
- * @default false
331
- */
332
- a11y?: boolean;
333
327
  /**
334
328
  * Glob patterns for Astro files.
335
329
  *
@@ -481,6 +475,12 @@ interface FormattersOptions {
481
475
  * When set to `true`, it will use Prettier.
482
476
  */
483
477
  markdown?: "prettier" | "dprint" | boolean;
478
+ /**
479
+ * Enable formatting support for Astro.
480
+ *
481
+ * Currently only support Prettier.
482
+ */
483
+ astro?: "prettier" | boolean;
484
484
  /**
485
485
  * Enable formatting support for GraphQL.
486
486
  */
@@ -728,7 +728,7 @@ declare function toArray<T>(value: T | T[]): T[];
728
728
  declare function interop<T>(m: Awaitable<T>): Promise<T extends {
729
729
  default: infer U;
730
730
  } ? U : T>;
731
- declare function ensure(packages: string[]): Promise<void>;
731
+ declare function ensure(packages: (string | undefined)[]): Promise<void>;
732
732
  type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
733
733
  declare function resolveSubOptions<K extends keyof ConfigOptions>(options: ConfigOptions, key: K): ResolvedOptions<ConfigOptions[K]>;
734
734
  declare function getOverrides<K extends keyof ConfigOptions>(options: ConfigOptions, key: K): any;
package/dist/index.d.ts CHANGED
@@ -324,12 +324,6 @@ interface AstroOptions {
324
324
  * @default true
325
325
  */
326
326
  typescript?: boolean;
327
- /**
328
- * Enable React A11y support.
329
- *
330
- * @default false
331
- */
332
- a11y?: boolean;
333
327
  /**
334
328
  * Glob patterns for Astro files.
335
329
  *
@@ -481,6 +475,12 @@ interface FormattersOptions {
481
475
  * When set to `true`, it will use Prettier.
482
476
  */
483
477
  markdown?: "prettier" | "dprint" | boolean;
478
+ /**
479
+ * Enable formatting support for Astro.
480
+ *
481
+ * Currently only support Prettier.
482
+ */
483
+ astro?: "prettier" | boolean;
484
484
  /**
485
485
  * Enable formatting support for GraphQL.
486
486
  */
@@ -728,7 +728,7 @@ declare function toArray<T>(value: T | T[]): T[];
728
728
  declare function interop<T>(m: Awaitable<T>): Promise<T extends {
729
729
  default: infer U;
730
730
  } ? U : T>;
731
- declare function ensure(packages: string[]): Promise<void>;
731
+ declare function ensure(packages: (string | undefined)[]): Promise<void>;
732
732
  type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
733
733
  declare function resolveSubOptions<K extends keyof ConfigOptions>(options: ConfigOptions, key: K): ResolvedOptions<ConfigOptions[K]>;
734
734
  declare function getOverrides<K extends keyof ConfigOptions>(options: ConfigOptions, key: K): any;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/factory.ts
2
2
  import process3 from "node:process";
3
3
  import { existsSync } from "node:fs";
4
- import { isPackageExists as isPackageExists3 } from "local-pkg";
4
+ import { isPackageExists as isPackageExists4 } from "local-pkg";
5
5
 
6
6
  // src/configs/comments.ts
7
7
  import eslintCommentsPlugin from "@eslint-community/eslint-plugin-eslint-comments";
@@ -738,25 +738,21 @@ async function ensure(packages) {
738
738
  return;
739
739
  }
740
740
  ;
741
- const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
741
+ const nonExistingPackages = packages.filter((i) => i && !isPackageExists(i));
742
742
  if (nonExistingPackages.length === 0) {
743
743
  return;
744
744
  }
745
- ;
746
745
  const { default: prompts } = await import("prompts");
747
746
  const { result } = await prompts([
748
747
  {
749
- name: "result",
750
748
  message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
749
+ name: "result",
751
750
  type: "confirm"
752
751
  }
753
752
  ]);
754
753
  if (result) {
755
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, {
756
- dev: true
757
- }));
754
+ await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
758
755
  }
759
- ;
760
756
  }
761
757
  function resolveSubOptions(options, key) {
762
758
  return typeof options[key] === "boolean" ? {} : options[key] || {};
@@ -1931,29 +1927,29 @@ async function react(options = {}) {
1931
1927
  // src/configs/frameworks/astro.ts
1932
1928
  async function astro(options) {
1933
1929
  const {
1934
- a11y = false,
1935
1930
  files = [GLOB_ASTRO],
1936
1931
  overrides = {},
1937
1932
  typescript: typescript2 = true,
1938
1933
  stylistic: stylistic2 = true
1939
1934
  } = options;
1935
+ await ensure([
1936
+ "eslint-plugin-astro",
1937
+ "astro-eslint-parser"
1938
+ ]);
1940
1939
  const [
1941
1940
  pluginAstro,
1942
1941
  parserAstro,
1943
- parserTs,
1944
- pluginA11y
1942
+ parserTs
1945
1943
  ] = await Promise.all([
1946
1944
  interop(import("eslint-plugin-astro")),
1947
1945
  interop(import("astro-eslint-parser")),
1948
- interop(import("@typescript-eslint/parser")),
1949
- ...a11y ? [interop(import("eslint-plugin-jsx-a11y"))] : []
1946
+ interop(import("@typescript-eslint/parser"))
1950
1947
  ]);
1951
1948
  return [
1952
1949
  {
1953
1950
  name: "luxass:astro:setup",
1954
1951
  plugins: {
1955
- astro: pluginAstro,
1956
- ...a11y ? { "jsx-a11y": pluginA11y } : {}
1952
+ astro: pluginAstro
1957
1953
  }
1958
1954
  },
1959
1955
  {
@@ -2075,18 +2071,21 @@ async function tailwindcss(options = {}) {
2075
2071
 
2076
2072
  // src/configs/formatters.ts
2077
2073
  import * as parserPlain2 from "eslint-parser-plain";
2074
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
2078
2075
  async function formatters(options = {}, stylistic2 = {}) {
2079
- await ensure([
2080
- "eslint-plugin-format"
2081
- ]);
2082
2076
  if (options === true) {
2083
2077
  options = {
2078
+ astro: isPackageExists3("astro"),
2084
2079
  css: true,
2085
2080
  graphql: true,
2086
2081
  html: true,
2087
2082
  markdown: true
2088
2083
  };
2089
2084
  }
2085
+ await ensure([
2086
+ "eslint-plugin-format",
2087
+ options.astro ? "prettier-plugin-astro" : void 0
2088
+ ]);
2090
2089
  const {
2091
2090
  indent,
2092
2091
  quotes,
@@ -2217,6 +2216,27 @@ async function formatters(options = {}, stylistic2 = {}) {
2217
2216
  }
2218
2217
  });
2219
2218
  }
2219
+ if (options.astro) {
2220
+ configs.push({
2221
+ name: "luxass:formatter:astro",
2222
+ files: [GLOB_ASTRO],
2223
+ languageOptions: {
2224
+ parser: parserPlain2
2225
+ },
2226
+ rules: {
2227
+ "format/prettier": [
2228
+ "error",
2229
+ {
2230
+ ...prettierOptions,
2231
+ parser: "astro",
2232
+ plugins: [
2233
+ "prettier-plugin-astro"
2234
+ ]
2235
+ }
2236
+ ]
2237
+ }
2238
+ });
2239
+ }
2220
2240
  if (options.graphql) {
2221
2241
  configs.push({
2222
2242
  name: "luxass:formatter:graphql",
@@ -2324,9 +2344,9 @@ async function luxass(options = {}, ...userConfigs) {
2324
2344
  nextjs: enableNextJS = false,
2325
2345
  react: enableReact = false,
2326
2346
  tailwindcss: enableTailwindCSS = false,
2327
- typescript: enableTypeScript = isPackageExists3("typescript"),
2347
+ typescript: enableTypeScript = isPackageExists4("typescript"),
2328
2348
  unocss: enableUnoCSS = false,
2329
- vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
2349
+ vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
2330
2350
  } = options;
2331
2351
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2332
2352
  if (stylisticOptions && !("jsx" in stylisticOptions)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxass/eslint-config",
3
- "version": "4.2.8",
3
+ "version": "4.2.9",
4
4
  "description": "ESLint config for @luxass",
5
5
  "type": "module",
6
6
  "author": {