@kirklin/eslint-config 2.1.0 → 2.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/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/factory.ts
2
2
  import process3 from "process";
3
3
  import fs from "fs";
4
- import { isPackageExists as isPackageExists3 } from "local-pkg";
4
+ import { isPackageExists as isPackageExists4 } from "local-pkg";
5
5
 
6
6
  // src/plugins.ts
7
7
  import { default as default2 } from "eslint-plugin-kirklin";
@@ -52,6 +52,7 @@ var GLOB_VUE = "**/*.vue";
52
52
  var GLOB_YAML = "**/*.y?(a)ml";
53
53
  var GLOB_TOML = "**/*.toml";
54
54
  var GLOB_HTML = "**/*.htm?(l)";
55
+ var GLOB_ASTRO = "**/*.astro";
55
56
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
56
57
  var GLOB_TESTS = [
57
58
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -94,6 +95,7 @@ var GLOB_EXCLUDE = [
94
95
  "**/.cache",
95
96
  "**/.output",
96
97
  "**/.vite-inspect",
98
+ "**/.yarn",
97
99
  "**/CHANGELOG*.md",
98
100
  "**/*.min.*",
99
101
  "**/LICENSE*",
@@ -135,7 +137,7 @@ async function imports(options = {}) {
135
137
  "kirklin/no-import-dist": "error",
136
138
  "kirklin/no-import-node-modules-by-path": "error",
137
139
  ...stylistic2 ? {
138
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
140
+ "import/newline-after-import": ["error", { count: 1 }]
139
141
  } : {}
140
142
  }
141
143
  },
@@ -414,18 +416,14 @@ async function ensurePackages(packages) {
414
416
  if (process.env.CI || process.stdout.isTTY === false) {
415
417
  return;
416
418
  }
417
- const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
419
+ const nonExistingPackages = packages.filter((i) => i && !isPackageExists(i));
418
420
  if (nonExistingPackages.length === 0) {
419
421
  return;
420
422
  }
421
- const { default: prompts } = await import("prompts");
422
- const { result } = await prompts([
423
- {
424
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
425
- name: "result",
426
- type: "confirm"
427
- }
428
- ]);
423
+ const p = await import("@clack/prompts");
424
+ const result = await p.confirm({
425
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
426
+ });
429
427
  if (result) {
430
428
  await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
431
429
  }
@@ -673,6 +671,9 @@ async function perfectionist() {
673
671
  ];
674
672
  }
675
673
 
674
+ // src/configs/formatters.ts
675
+ import { isPackageExists as isPackageExists2 } from "local-pkg";
676
+
676
677
  // src/configs/stylistic.ts
677
678
  var StylisticConfigDefaults = {
678
679
  indent: 2,
@@ -723,17 +724,24 @@ async function stylistic(options = {}) {
723
724
 
724
725
  // src/configs/formatters.ts
725
726
  async function formatters(options = {}, stylistic2 = {}) {
726
- await ensurePackages([
727
- "eslint-plugin-format"
728
- ]);
729
727
  if (options === true) {
730
728
  options = {
729
+ astro: isPackageExists2("astro"),
731
730
  css: true,
732
731
  graphql: true,
733
732
  html: true,
734
- markdown: true
733
+ markdown: true,
734
+ slidev: isPackageExists2("@slidev/cli")
735
735
  };
736
736
  }
737
+ await ensurePackages([
738
+ "eslint-plugin-format",
739
+ options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
740
+ options.astro ? "prettier-plugin-astro" : void 0
741
+ ]);
742
+ if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
743
+ throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
744
+ }
737
745
  const {
738
746
  indent,
739
747
  quotes,
@@ -842,8 +850,10 @@ async function formatters(options = {}, stylistic2 = {}) {
842
850
  }
843
851
  if (options.markdown) {
844
852
  const formater = options.markdown === true ? "prettier" : options.markdown;
853
+ const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
845
854
  configs.push({
846
855
  files: [GLOB_MARKDOWN],
856
+ ignores: GLOB_SLIDEV,
847
857
  languageOptions: {
848
858
  parser: parserPlain
849
859
  },
@@ -863,6 +873,50 @@ async function formatters(options = {}, stylistic2 = {}) {
863
873
  ]
864
874
  }
865
875
  });
876
+ if (options.slidev) {
877
+ configs.push({
878
+ files: GLOB_SLIDEV,
879
+ languageOptions: {
880
+ parser: parserPlain
881
+ },
882
+ name: "kirklin:formatter:slidev",
883
+ rules: {
884
+ "format/prettier": [
885
+ "error",
886
+ {
887
+ printWidth: 120,
888
+ ...prettierOptions,
889
+ embeddedLanguageFormatting: "off",
890
+ parser: "slidev",
891
+ plugins: [
892
+ "prettier-plugin-slidev"
893
+ ]
894
+ }
895
+ ]
896
+ }
897
+ });
898
+ }
899
+ }
900
+ if (options.astro) {
901
+ configs.push({
902
+ files: [GLOB_ASTRO],
903
+ languageOptions: {
904
+ parser: parserPlain
905
+ },
906
+ name: "kirklin:formatter:astro",
907
+ rules: {
908
+ "format/prettier": [
909
+ "error",
910
+ {
911
+ ...prettierOptions,
912
+ parser: "astro",
913
+ plugins: [
914
+ "prettier-plugin-astro"
915
+ ]
916
+ }
917
+ ]
918
+ }
919
+ });
866
920
  }
867
921
  if (options.graphql) {
868
922
  configs.push({
@@ -886,7 +940,7 @@ async function formatters(options = {}, stylistic2 = {}) {
886
940
  }
887
941
 
888
942
  // src/configs/react.ts
889
- import { isPackageExists as isPackageExists2 } from "local-pkg";
943
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
890
944
  var ReactRefreshAllowConstantExportPackages = [
891
945
  "vite"
892
946
  ];
@@ -911,7 +965,7 @@ async function react(options = {}) {
911
965
  interopDefault(import("eslint-plugin-react-refresh"))
912
966
  ]);
913
967
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
914
- (i) => isPackageExists2(i)
968
+ (i) => isPackageExists3(i)
915
969
  );
916
970
  return [
917
971
  {
@@ -1268,6 +1322,8 @@ async function svelte(options = {}) {
1268
1322
  { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
1269
1323
  ],
1270
1324
  ...stylistic2 ? {
1325
+ "style/indent": "off",
1326
+ // superseded by svelte/indent
1271
1327
  "style/no-trailing-spaces": "off",
1272
1328
  // superseded by svelte/no-trailing-spaces
1273
1329
  "svelte/derived-has-same-inputs-outputs": "error",
@@ -1585,6 +1641,26 @@ async function vue(options = {}) {
1585
1641
  ]);
1586
1642
  return [
1587
1643
  {
1644
+ // This allows Vue plugin to work with auto imports
1645
+ // https://github.com/vuejs/eslint-plugin-vue/pull/2422
1646
+ languageOptions: {
1647
+ globals: {
1648
+ computed: "readonly",
1649
+ defineEmits: "readonly",
1650
+ defineExpose: "readonly",
1651
+ defineProps: "readonly",
1652
+ onMounted: "readonly",
1653
+ onUnmounted: "readonly",
1654
+ reactive: "readonly",
1655
+ ref: "readonly",
1656
+ shallowReactive: "readonly",
1657
+ shallowRef: "readonly",
1658
+ toRef: "readonly",
1659
+ toRefs: "readonly",
1660
+ watch: "readonly",
1661
+ watchEffect: "readonly"
1662
+ }
1663
+ },
1588
1664
  name: "kirklin:vue:setup",
1589
1665
  plugins: {
1590
1666
  vue: pluginVue
@@ -1830,6 +1906,54 @@ async function toml(options = {}) {
1830
1906
  ];
1831
1907
  }
1832
1908
 
1909
+ // src/configs/astro.ts
1910
+ async function astro(options = {}) {
1911
+ const {
1912
+ files = [GLOB_ASTRO],
1913
+ overrides = {},
1914
+ stylistic: stylistic2 = true
1915
+ } = options;
1916
+ const [
1917
+ pluginAstro,
1918
+ parserAstro,
1919
+ parserTs
1920
+ ] = await Promise.all([
1921
+ interopDefault(import("eslint-plugin-astro")),
1922
+ interopDefault(import("astro-eslint-parser")),
1923
+ interopDefault(import("@typescript-eslint/parser"))
1924
+ ]);
1925
+ return [
1926
+ {
1927
+ name: "kirklin:astro:setup",
1928
+ plugins: {
1929
+ astro: pluginAstro
1930
+ }
1931
+ },
1932
+ {
1933
+ files,
1934
+ languageOptions: {
1935
+ parser: parserAstro,
1936
+ parserOptions: {
1937
+ extraFileExtensions: [".astro"],
1938
+ parser: parserTs
1939
+ }
1940
+ },
1941
+ name: "kirklin:astro:rules",
1942
+ rules: {
1943
+ "astro/no-set-html-directive": "off",
1944
+ ...stylistic2 ? {
1945
+ "style/indent": "off",
1946
+ "style/jsx-closing-tag-location": "off",
1947
+ "style/jsx-indent": "off",
1948
+ "style/jsx-one-expression-per-line": "off",
1949
+ "style/no-multiple-empty-lines": "off"
1950
+ } : {},
1951
+ ...overrides
1952
+ }
1953
+ }
1954
+ ];
1955
+ }
1956
+
1833
1957
  // src/factory.ts
1834
1958
  var flatConfigProps = [
1835
1959
  "name",
@@ -1850,14 +1974,15 @@ var VuePackages = [
1850
1974
  ];
1851
1975
  async function kirklin(options = {}, ...userConfigs) {
1852
1976
  const {
1977
+ astro: enableAstro = false,
1853
1978
  componentExts = [],
1854
1979
  gitignore: enableGitignore = true,
1855
- isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1980
+ isInEditor = !!((process3.env.VSCODE_PID || process3.env.VSCODE_CWD || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1856
1981
  react: enableReact = false,
1857
1982
  svelte: enableSvelte = false,
1858
- typescript: enableTypeScript = isPackageExists3("typescript"),
1983
+ typescript: enableTypeScript = isPackageExists4("typescript"),
1859
1984
  unocss: enableUnoCSS = false,
1860
- vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
1985
+ vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
1861
1986
  } = options;
1862
1987
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1863
1988
  if (stylisticOptions && !("jsx" in stylisticOptions)) {
@@ -1940,6 +2065,12 @@ async function kirklin(options = {}, ...userConfigs) {
1940
2065
  overrides: getOverrides(options, "unocss")
1941
2066
  }));
1942
2067
  }
2068
+ if (enableAstro) {
2069
+ configs.push(astro({
2070
+ overrides: getOverrides(options, "astro"),
2071
+ stylistic: stylisticOptions
2072
+ }));
2073
+ }
1943
2074
  if (options.jsonc ?? true) {
1944
2075
  configs.push(
1945
2076
  jsonc({
@@ -2008,6 +2139,7 @@ function getOverrides(options, key) {
2008
2139
  var src_default = kirklin;
2009
2140
  export {
2010
2141
  GLOB_ALL_SRC,
2142
+ GLOB_ASTRO,
2011
2143
  GLOB_CSS,
2012
2144
  GLOB_EXCLUDE,
2013
2145
  GLOB_HTML,
@@ -2033,6 +2165,7 @@ export {
2033
2165
  GLOB_VUE,
2034
2166
  GLOB_YAML,
2035
2167
  StylisticConfigDefaults,
2168
+ astro,
2036
2169
  combine,
2037
2170
  comments,
2038
2171
  src_default as default,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@kirklin/eslint-config",
3
3
  "type": "module",
4
- "version": "2.1.0",
5
- "packageManager": "pnpm@8.15.1",
4
+ "version": "2.2.0",
5
+ "packageManager": "pnpm@8.15.5",
6
6
  "description": "Kirk Lin's ESLint config",
7
7
  "author": "Kirk Lin (https://github.com/kirklin/)",
8
8
  "license": "MIT",
@@ -26,18 +26,28 @@
26
26
  ],
27
27
  "peerDependencies": {
28
28
  "@unocss/eslint-plugin": ">=0.50.0",
29
+ "astro-eslint-parser": "^0.16.3",
29
30
  "eslint": ">=8.40.0",
31
+ "eslint-plugin-astro": "^0.31.4",
30
32
  "eslint-plugin-format": ">=0.1.0",
31
33
  "eslint-plugin-react": "^7.33.2",
32
34
  "eslint-plugin-react-hooks": "^4.6.0",
33
35
  "eslint-plugin-react-refresh": "^0.4.4",
34
36
  "eslint-plugin-svelte": "^2.34.1",
37
+ "prettier-plugin-astro": "^0.13.0",
38
+ "prettier-plugin-slidev": "^1.0.5",
35
39
  "svelte-eslint-parser": "^0.33.1"
36
40
  },
37
41
  "peerDependenciesMeta": {
38
42
  "@unocss/eslint-plugin": {
39
43
  "optional": true
40
44
  },
45
+ "astro-eslint-parser": {
46
+ "optional": true
47
+ },
48
+ "eslint-plugin-astro": {
49
+ "optional": true
50
+ },
41
51
  "eslint-plugin-format": {
42
52
  "optional": true
43
53
  },
@@ -53,6 +63,12 @@
53
63
  "eslint-plugin-svelte": {
54
64
  "optional": true
55
65
  },
66
+ "prettier-plugin-astro": {
67
+ "optional": true
68
+ },
69
+ "prettier-plugin-slidev": {
70
+ "optional": true
71
+ },
56
72
  "svelte-eslint-parser": {
57
73
  "optional": true
58
74
  }
@@ -60,36 +76,36 @@
60
76
  "dependencies": {
61
77
  "@antfu/eslint-define-config": "1.23.0-2",
62
78
  "@antfu/install-pkg": "^0.3.1",
63
- "@eslint-types/jsdoc": "48.0.4",
64
- "@eslint-types/typescript-eslint": "^6.19.1",
65
- "@eslint-types/unicorn": "^50.0.1",
66
- "@stylistic/eslint-plugin": "^1.6.0",
67
- "@typescript-eslint/eslint-plugin": "^6.21.0",
68
- "@typescript-eslint/parser": "^6.21.0",
69
- "eslint-config-flat-gitignore": "^0.1.2",
79
+ "@clack/prompts": "^0.7.0",
80
+ "@eslint-types/jsdoc": "48.2.1",
81
+ "@eslint-types/typescript-eslint": "^7.2.0",
82
+ "@eslint-types/unicorn": "^51.0.1",
83
+ "@stylistic/eslint-plugin": "^1.7.0",
84
+ "@typescript-eslint/eslint-plugin": "^7.3.1",
85
+ "@typescript-eslint/parser": "^7.3.1",
86
+ "eslint-config-flat-gitignore": "^0.1.3",
70
87
  "eslint-merge-processors": "^0.1.0",
71
88
  "eslint-plugin-eslint-comments": "^3.2.0",
72
89
  "eslint-plugin-i": "^2.29.1",
73
- "eslint-plugin-jsdoc": "^48.0.5",
74
- "eslint-plugin-jsonc": "^2.13.0",
90
+ "eslint-plugin-jsdoc": "^48.2.1",
91
+ "eslint-plugin-jsonc": "^2.14.1",
75
92
  "eslint-plugin-kirklin": "^1.1.0",
76
- "eslint-plugin-markdown": "^3.0.1",
93
+ "eslint-plugin-markdown": "^4.0.1",
77
94
  "eslint-plugin-n": "^16.6.2",
78
95
  "eslint-plugin-no-only-tests": "^3.1.0",
79
- "eslint-plugin-perfectionist": "^2.5.0",
80
- "eslint-plugin-toml": "^0.9.2",
81
- "eslint-plugin-unicorn": "^50.0.1",
82
- "eslint-plugin-unused-imports": "^3.0.0",
83
- "eslint-plugin-vitest": "^0.3.21",
84
- "eslint-plugin-vue": "^9.21.1",
85
- "eslint-plugin-yml": "^1.12.2",
96
+ "eslint-plugin-perfectionist": "^2.7.0",
97
+ "eslint-plugin-toml": "^0.10.0",
98
+ "eslint-plugin-unicorn": "^51.0.1",
99
+ "eslint-plugin-unused-imports": "^3.1.0",
100
+ "eslint-plugin-vitest": "^0.3.26",
101
+ "eslint-plugin-vue": "^9.23.0",
102
+ "eslint-plugin-yml": "^1.13.1",
86
103
  "eslint-processor-vue-blocks": "^0.1.1",
87
- "globals": "^13.24.0",
104
+ "globals": "^14.0.0",
88
105
  "jsonc-eslint-parser": "^2.4.0",
89
106
  "local-pkg": "^0.5.0",
90
107
  "parse-gitignore": "^2.0.0",
91
108
  "picocolors": "^1.0.0",
92
- "prompts": "^2.4.2",
93
109
  "toml-eslint-parser": "^0.9.3",
94
110
  "vue-eslint-parser": "^9.4.2",
95
111
  "yaml-eslint-parser": "^1.2.2",
@@ -98,36 +114,40 @@
98
114
  "devDependencies": {
99
115
  "@antfu/eslint-plugin-prettier": "5.0.1-1",
100
116
  "@antfu/ni": "^0.21.12",
101
- "@stylistic/eslint-plugin-migrate": "^1.6.0",
102
- "@types/eslint": "^8.56.2",
117
+ "@stylistic/eslint-plugin-migrate": "^1.7.0",
118
+ "@types/eslint": "^8.56.6",
103
119
  "@types/fs-extra": "^11.0.4",
104
- "@types/node": "^20.11.16",
120
+ "@types/node": "^20.11.30",
105
121
  "@types/prompts": "^2.4.9",
106
122
  "@types/yargs": "^17.0.32",
107
- "@unocss/eslint-plugin": "^0.58.5",
108
- "bumpp": "^9.3.0",
109
- "eslint": "npm:eslint-ts-patch@8.56.0-0",
123
+ "@unocss/eslint-plugin": "^0.58.6",
124
+ "astro-eslint-parser": "^0.16.3",
125
+ "bumpp": "^9.4.0",
126
+ "eslint": "npm:eslint-ts-patch@8.57.0-0",
110
127
  "eslint-flat-config-viewer": "^0.1.11",
128
+ "eslint-plugin-astro": "^0.32.0",
111
129
  "eslint-plugin-format": "^0.1.0",
112
- "eslint-plugin-react": "^7.33.2",
130
+ "eslint-plugin-react": "^7.34.1",
113
131
  "eslint-plugin-react-hooks": "^4.6.0",
114
- "eslint-plugin-react-refresh": "^0.4.5",
132
+ "eslint-plugin-react-refresh": "^0.4.6",
115
133
  "eslint-plugin-svelte": "^2.35.1",
116
- "eslint-ts-patch": "8.56.0-0",
117
- "esno": "^4.0.0",
134
+ "eslint-ts-patch": "8.57.0-0",
135
+ "esno": "^4.7.0",
118
136
  "execa": "^8.0.1",
119
137
  "fast-glob": "^3.3.2",
120
138
  "fs-extra": "^11.2.0",
121
139
  "lint-staged": "^15.2.2",
140
+ "prettier-plugin-astro": "^0.13.0",
141
+ "prettier-plugin-slidev": "^1.0.5",
122
142
  "rimraf": "^5.0.5",
123
- "simple-git-hooks": "^2.9.0",
124
- "svelte": "^4.2.10",
143
+ "simple-git-hooks": "^2.11.0",
144
+ "svelte": "^4.2.12",
125
145
  "svelte-eslint-parser": "^0.33.1",
126
- "tsup": "^8.0.1",
127
- "typescript": "^5.3.3",
128
- "vitest": "^1.2.2",
129
- "vue": "^3.4.15",
130
- "@kirklin/eslint-config": "2.1.0"
146
+ "tsup": "^8.0.2",
147
+ "typescript": "^5.4.2",
148
+ "vitest": "^1.4.0",
149
+ "vue": "^3.4.21",
150
+ "@kirklin/eslint-config": "2.2.0"
131
151
  },
132
152
  "simple-git-hooks": {
133
153
  "pre-commit": "pnpm lint-staged"