@utoo/lint 0.2.5 → 0.2.6
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/README.md +42 -0
- package/bin/fishlint.js +1 -1
- package/configs/frontend.d.ts +8 -0
- package/index.cjs +9 -2
- package/index.js +9 -2
- package/package.json +15 -8
package/README.md
CHANGED
|
@@ -114,6 +114,48 @@ export default defineConfig({
|
|
|
114
114
|
});
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
+
The packaged frontend preset is also available as a typed config import:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { defineConfig } from "@utoo/lint/config";
|
|
121
|
+
import frontend from "@utoo/lint/configs/frontend";
|
|
122
|
+
|
|
123
|
+
export default defineConfig({
|
|
124
|
+
...frontend,
|
|
125
|
+
rules: {
|
|
126
|
+
...frontend.rules,
|
|
127
|
+
"no-console": "off",
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Use `globalIgnores()` as a separate config entry when files or directories
|
|
133
|
+
must be excluded from every entry:
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { defineConfig, globalIgnores } from "@utoo/lint/config";
|
|
137
|
+
|
|
138
|
+
export default defineConfig(
|
|
139
|
+
globalIgnores(["dist/", ".next/", "**/generated/"]),
|
|
140
|
+
{
|
|
141
|
+
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
142
|
+
rules: {
|
|
143
|
+
"no-debugger": "error"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`globalIgnores()` returns an ignore-only object containing `ignores` and a
|
|
150
|
+
generated `name`. Only such global entries prune directories during target
|
|
151
|
+
discovery. By contrast, `ignores` beside `files`, `rules`, or another config
|
|
152
|
+
key is entry-scoped: it prevents that entry from applying to matching files,
|
|
153
|
+
but does not exclude them from other entries. With no CLI targets, global
|
|
154
|
+
ignores filter the config's `files` patterns, or the current-directory scan
|
|
155
|
+
when no `files` are configured. Directory patterns such as `dist/` and
|
|
156
|
+
`.next/` are relative to the config; use `**/generated/` to match at any depth.
|
|
157
|
+
This intentionally follows [ESLint flat config ignore semantics](https://eslint.org/docs/latest/use/configure/ignore).
|
|
158
|
+
|
|
117
159
|
The two canonical names represent one active config and are not implicitly
|
|
118
160
|
merged. For the npm/Node entry point, discovery is nearest-directory-first.
|
|
119
161
|
Within the same directory, `utlint.config.ts` takes precedence over
|
package/bin/fishlint.js
CHANGED
|
@@ -796,7 +796,7 @@ function isIgnoredTarget(target, patterns) {
|
|
|
796
796
|
}
|
|
797
797
|
|
|
798
798
|
function normalizeIgnoredPattern(pattern) {
|
|
799
|
-
return normalizePath(pattern.replace(/^!/, "").replace(/^\//, ""));
|
|
799
|
+
return normalizePath(pattern.replace(/^!/, "").replace(/^\//, "")).replace(/\/+$/, "");
|
|
800
800
|
}
|
|
801
801
|
|
|
802
802
|
function matchesIgnorePattern(target, pattern) {
|
package/index.cjs
CHANGED
|
@@ -4118,13 +4118,20 @@ function ignorePatternsFromConfig(config) {
|
|
|
4118
4118
|
return config.flatMap((entry) => ignorePatternsFromConfig(entry));
|
|
4119
4119
|
}
|
|
4120
4120
|
|
|
4121
|
-
const flatConfigIgnores = config
|
|
4121
|
+
const flatConfigIgnores = isGlobalIgnoreEntry(config) ? normalizeIgnorePatterns(config.ignores) : [];
|
|
4122
4122
|
return [
|
|
4123
4123
|
...normalizeIgnorePatterns(config.ignorePatterns),
|
|
4124
4124
|
...flatConfigIgnores
|
|
4125
4125
|
];
|
|
4126
4126
|
}
|
|
4127
4127
|
|
|
4128
|
+
function isGlobalIgnoreEntry(config) {
|
|
4129
|
+
if (!config || typeof config !== "object" || !config.ignores) {
|
|
4130
|
+
return false;
|
|
4131
|
+
}
|
|
4132
|
+
return Object.keys(config).every((key) => key === "name" || key === "ignores");
|
|
4133
|
+
}
|
|
4134
|
+
|
|
4128
4135
|
function normalizeIgnorePatterns(patterns) {
|
|
4129
4136
|
if (!patterns) {
|
|
4130
4137
|
return [];
|
|
@@ -4160,7 +4167,7 @@ function normalizeIgnoredPath(filePath, cwd) {
|
|
|
4160
4167
|
}
|
|
4161
4168
|
|
|
4162
4169
|
function normalizeIgnoredPattern(pattern) {
|
|
4163
|
-
return normalizePath(pattern.replace(/^!/, "").replace(/^\//, ""));
|
|
4170
|
+
return normalizePath(pattern.replace(/^!/, "").replace(/^\//, "")).replace(/\/+$/, "");
|
|
4164
4171
|
}
|
|
4165
4172
|
|
|
4166
4173
|
function pathIgnoredByPatterns(target, patterns) {
|
package/index.js
CHANGED
|
@@ -4121,13 +4121,20 @@ function ignorePatternsFromConfig(config) {
|
|
|
4121
4121
|
return config.flatMap((entry) => ignorePatternsFromConfig(entry));
|
|
4122
4122
|
}
|
|
4123
4123
|
|
|
4124
|
-
const flatConfigIgnores = config
|
|
4124
|
+
const flatConfigIgnores = isGlobalIgnoreEntry(config) ? normalizeIgnorePatterns(config.ignores) : [];
|
|
4125
4125
|
return [
|
|
4126
4126
|
...normalizeIgnorePatterns(config.ignorePatterns),
|
|
4127
4127
|
...flatConfigIgnores
|
|
4128
4128
|
];
|
|
4129
4129
|
}
|
|
4130
4130
|
|
|
4131
|
+
function isGlobalIgnoreEntry(config) {
|
|
4132
|
+
if (!config || typeof config !== "object" || !config.ignores) {
|
|
4133
|
+
return false;
|
|
4134
|
+
}
|
|
4135
|
+
return Object.keys(config).every((key) => key === "name" || key === "ignores");
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4131
4138
|
function normalizeIgnorePatterns(patterns) {
|
|
4132
4139
|
if (!patterns) {
|
|
4133
4140
|
return [];
|
|
@@ -4163,7 +4170,7 @@ function normalizeIgnoredPath(filePath, cwd) {
|
|
|
4163
4170
|
}
|
|
4164
4171
|
|
|
4165
4172
|
function normalizeIgnoredPattern(pattern) {
|
|
4166
|
-
return normalizePath(pattern.replace(/^!/, "").replace(/^\//, ""));
|
|
4173
|
+
return normalizePath(pattern.replace(/^!/, "").replace(/^\//, "")).replace(/\/+$/, "");
|
|
4167
4174
|
}
|
|
4168
4175
|
|
|
4169
4176
|
function pathIgnoredByPatterns(target, patterns) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/lint",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Experimental JavaScript and TypeScript linter powered by Yuku",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -42,7 +42,10 @@
|
|
|
42
42
|
"import": "./universal.js",
|
|
43
43
|
"require": "./universal.cjs"
|
|
44
44
|
},
|
|
45
|
-
"./configs/frontend":
|
|
45
|
+
"./configs/frontend": {
|
|
46
|
+
"types": "./configs/frontend.d.ts",
|
|
47
|
+
"default": "./configs/frontend.json"
|
|
48
|
+
},
|
|
46
49
|
"./schema": "./schema.json",
|
|
47
50
|
"./package.json": "./package.json"
|
|
48
51
|
},
|
|
@@ -73,11 +76,11 @@
|
|
|
73
76
|
"use-at-your-own-risk.js"
|
|
74
77
|
],
|
|
75
78
|
"optionalDependencies": {
|
|
76
|
-
"@utoo/lint-darwin-arm64": "0.2.
|
|
77
|
-
"@utoo/lint-darwin-x64": "0.2.
|
|
78
|
-
"@utoo/lint-linux-arm64": "0.2.
|
|
79
|
-
"@utoo/lint-linux-x64": "0.2.
|
|
80
|
-
"@utoo/lint-win32-x64": "0.2.
|
|
79
|
+
"@utoo/lint-darwin-arm64": "0.2.6",
|
|
80
|
+
"@utoo/lint-darwin-x64": "0.2.6",
|
|
81
|
+
"@utoo/lint-linux-arm64": "0.2.6",
|
|
82
|
+
"@utoo/lint-linux-x64": "0.2.6",
|
|
83
|
+
"@utoo/lint-win32-x64": "0.2.6"
|
|
81
84
|
},
|
|
82
85
|
"dependencies": {
|
|
83
86
|
"jiti": "2.7.0"
|
|
@@ -86,7 +89,11 @@
|
|
|
86
89
|
"access": "public",
|
|
87
90
|
"registry": "https://registry.npmjs.org/"
|
|
88
91
|
},
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"typescript": "6.0.3"
|
|
94
|
+
},
|
|
89
95
|
"scripts": {
|
|
90
|
-
"test": "node --test --test-concurrency=1 test/*.test.mjs"
|
|
96
|
+
"test": "node --test --test-concurrency=1 test/*.test.mjs && pnpm test:types",
|
|
97
|
+
"test:types": "tsc -p test/types/tsconfig.json"
|
|
91
98
|
}
|
|
92
99
|
}
|