@mouse_484/eslint-config 5.4.4 → 5.5.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/bin/cli.js +15 -6
- package/jsconfig.json +3 -7
- package/package.json +2 -2
- package/scripts/typegen.js +2 -2
- package/src/configs/tailwind.js +1 -1
- package/src/configs/typescript.js +1 -1
- package/src/index.d.ts +3 -0
- package/src/index.js +21 -1
- package/src/lib/factory.js +4 -4
package/bin/cli.js
CHANGED
|
@@ -22,8 +22,12 @@ function logger(message) {
|
|
|
22
22
|
/**
|
|
23
23
|
* @type {(...args: Parameters<typeof import("package-manager-detector/commands").resolveCommand>) => Promise<void>}
|
|
24
24
|
*/
|
|
25
|
-
function runAgentCommand(agent, command_, args_) {
|
|
26
|
-
const
|
|
25
|
+
async function runAgentCommand(agent, command_, args_) {
|
|
26
|
+
const result = resolveCommand(agent, command_, args_)
|
|
27
|
+
if (!result) {
|
|
28
|
+
throw new Error(`Unsupported package manager or command: ${agent} ${command_}`)
|
|
29
|
+
}
|
|
30
|
+
const { command, args } = result
|
|
27
31
|
console.info(`Running command: ${command} ${args.join(' ')}`)
|
|
28
32
|
return new Promise((resolve, reject) => {
|
|
29
33
|
const child = spawn(
|
|
@@ -82,10 +86,14 @@ async function main() {
|
|
|
82
86
|
|
|
83
87
|
logger('Updating package.json scripts')
|
|
84
88
|
const packageJsonPath = path.join(cwd, 'package.json')
|
|
89
|
+
|
|
90
|
+
const packageJsonRaw = await readFile(packageJsonPath, 'utf8')
|
|
85
91
|
/**
|
|
86
|
-
* @type {{ scripts
|
|
92
|
+
* @type {{ scripts?: Record<string, string>, type?: "module" }}
|
|
87
93
|
*/
|
|
88
|
-
|
|
94
|
+
// eslint-disable-next-line ts/no-unsafe-assignment
|
|
95
|
+
const packageJson = JSON.parse(packageJsonRaw) ?? {}
|
|
96
|
+
|
|
89
97
|
packageJson.scripts = {
|
|
90
98
|
...packageJson.scripts,
|
|
91
99
|
'lint': 'eslint .',
|
|
@@ -113,10 +121,11 @@ async function main() {
|
|
|
113
121
|
'run',
|
|
114
122
|
['lint:fix'],
|
|
115
123
|
).catch((error) => {
|
|
116
|
-
|
|
124
|
+
if (error instanceof Error) {
|
|
125
|
+
logger(`Linting failed: ${error.message}`)
|
|
126
|
+
}
|
|
117
127
|
})
|
|
118
128
|
}
|
|
119
129
|
|
|
120
|
-
console.info('---------------- Setting up @mouse_484/eslint-config ----------------')
|
|
121
130
|
await main()
|
|
122
131
|
console.info('---------------- Setup Complete ----------------')
|
package/jsconfig.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mouse_484/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.5.0",
|
|
5
5
|
"author": "mouse_484",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/mouse484/config/tree/main/packages/eslint",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"main": "src/index.js",
|
|
19
19
|
"types": "src/index.d.ts",
|
|
20
20
|
"bin": {
|
|
21
|
-
"setup": "
|
|
21
|
+
"setup-eslint-mouse-config": "bin/cli.js"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"typegen": "node scripts/typegen.js"
|
package/scripts/typegen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { writeFile } from 'node:fs/promises'
|
|
2
2
|
import eslintPluginBetterTailwindcss from 'eslint-plugin-better-tailwindcss'
|
|
3
3
|
import { pluginsToRulesDTS } from 'eslint-typegen/core'
|
|
4
4
|
|
|
@@ -6,4 +6,4 @@ const dts = await pluginsToRulesDTS({
|
|
|
6
6
|
tailwind: eslintPluginBetterTailwindcss,
|
|
7
7
|
})
|
|
8
8
|
|
|
9
|
-
await
|
|
9
|
+
await writeFile('./src/lib/rules.gen.d.ts', dts)
|
package/src/configs/tailwind.js
CHANGED
|
@@ -6,7 +6,7 @@ export default createConfigs({
|
|
|
6
6
|
baseWithOption: 'typescript',
|
|
7
7
|
configs: [
|
|
8
8
|
(meta) => {
|
|
9
|
-
if (meta && 'tsconfigPath' in meta && meta.tsconfigPath) {
|
|
9
|
+
if (meta && 'tsconfigPath' in meta && meta.tsconfigPath !== undefined) {
|
|
10
10
|
return {
|
|
11
11
|
name: 'type-aware',
|
|
12
12
|
files: [GLOB_TS],
|
package/src/index.d.ts
CHANGED
|
@@ -19,6 +19,9 @@ type Config = Awaitable<
|
|
|
19
19
|
>
|
|
20
20
|
export interface Options extends OptionsConfig, Omit<TypedFlatConfigItem, 'files'> {
|
|
21
21
|
tailwind?: false | { entryPoint: string }
|
|
22
|
+
typescript?: OptionsConfig['typescript'] & {
|
|
23
|
+
allowJS?: boolean
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export declare function mouse(
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import antfu from '@antfu/eslint-config'
|
|
1
|
+
import antfu, { GLOB_JS, GLOB_JSX } from '@antfu/eslint-config'
|
|
2
2
|
import astro from './configs/astro.js'
|
|
3
3
|
import base from './configs/base.js'
|
|
4
4
|
import perfectionist from './configs/perfectionist.js'
|
|
@@ -37,7 +37,27 @@ async function mouse(options, ...userConfigs) {
|
|
|
37
37
|
ignores: typeof options?.ignores === 'function' ? options.ignores([]) : options?.ignores,
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param {import("eslint").Linter.Config} config
|
|
43
|
+
*/
|
|
44
|
+
const overrideTypeScriptAllowJS = (config) => {
|
|
45
|
+
if (!options?.typescript?.allowJS) {
|
|
46
|
+
return config
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
...config,
|
|
50
|
+
files: [...(config.files ?? []), GLOB_JS, GLOB_JSX],
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
40
54
|
return antfu(normalizedOptions, ...configs, ...userConfigs)
|
|
55
|
+
.overrides({
|
|
56
|
+
'antfu/typescript/parser': overrideTypeScriptAllowJS,
|
|
57
|
+
'antfu/typescript/type-aware-parser': overrideTypeScriptAllowJS,
|
|
58
|
+
'antfu/typescript/rules': overrideTypeScriptAllowJS,
|
|
59
|
+
'antfu/typescript/rules-type-aware': overrideTypeScriptAllowJS,
|
|
60
|
+
})
|
|
41
61
|
}
|
|
42
62
|
|
|
43
63
|
export default mouse
|
package/src/lib/factory.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param {string} name
|
|
4
|
-
* @param {(keyof import('..').Options)[]} withOptions
|
|
4
|
+
* @param {(keyof import('..').Options)[]?} withOptions
|
|
5
5
|
* @param {Omit<import('@antfu/eslint-config').TypedFlatConfigItem,'name'>} config
|
|
6
6
|
* @returns {(options: import('..').Options) => import('@antfu/eslint-config').TypedFlatConfigItem|[]} _
|
|
7
7
|
*/
|
|
@@ -29,10 +29,10 @@ export function createConfigs({ name, baseWithOption, configs }) {
|
|
|
29
29
|
throw new Error('baseWithOption is required when configItem is a function')
|
|
30
30
|
}
|
|
31
31
|
const meta = options[baseWithOption]
|
|
32
|
-
// @ts-
|
|
33
|
-
configItem = configItem(typeof meta === 'object' ? meta : undefined)
|
|
32
|
+
// @ts-expect-error: may be undefined
|
|
33
|
+
configItem = configItem(typeof meta === 'object' ? meta : undefined)
|
|
34
34
|
}
|
|
35
|
-
if (
|
|
35
|
+
if (configItem === undefined) {
|
|
36
36
|
return []
|
|
37
37
|
}
|
|
38
38
|
const { name: configName, withOptions = [], ...restConfig } = configItem
|