Skip to content

Commit 324d02e

Browse files
committed
feat: add linter to guard usage
1 parent 4e1a272 commit 324d02e

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

eslint.config.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
// @ts-check
2-
const antfu = require('@antfu/eslint-config').default
2+
import antfu from '@antfu/eslint-config'
3+
import { createSimplePlugin } from 'eslint-factory'
34

4-
module.exports = antfu()
5+
export default antfu(
6+
{},
7+
createSimplePlugin({
8+
include: ['update.mjs'],
9+
name: 'wildcards-check',
10+
create(context) {
11+
return {
12+
Literal(node) {
13+
if (typeof node.value !== 'string')
14+
return
15+
const parts = node.value.split(',')
16+
for (const part of parts) {
17+
if (part.split('*').length > 2) {
18+
context.report({
19+
node,
20+
message: `Only one wildcard is allowed in patterns, but got "${part}"`,
21+
})
22+
}
23+
}
24+
},
25+
}
26+
},
27+
}),
28+
)

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"type": "module",
23
"private": true,
34
"packageManager": "pnpm@8.11.0",
45
"workspaces": [
@@ -18,8 +19,10 @@
1819
"devDependencies": {
1920
"@antfu/eslint-config": "^2.4.2",
2021
"@antfu/ni": "^0.21.12",
22+
"@types/eslint": "^8.44.8",
2123
"@types/vscode": "^1.84.2",
2224
"eslint": "^8.55.0",
25+
"eslint-factory": "^0.0.0",
2326
"ofetch": "^1.3.3",
2427
"tsup": "^8.0.1",
2528
"typescript": "^5.3.3"

pnpm-lock.yaml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)