eslint-plugin-oxfmt 0.0.12 → 0.0.14
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.d.mts +2 -2
- package/dist/index.mjs +11 -12
- package/package.json +12 -12
- package/workers/oxfmt.mjs +18 -18
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as eslint from "eslint";
|
|
2
2
|
import { Linter, Rule } from "eslint";
|
|
3
3
|
|
|
4
4
|
//#region src/types.d.ts
|
|
@@ -23,7 +23,7 @@ declare const meta: {
|
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/rules/index.d.ts
|
|
25
25
|
declare const rules: {
|
|
26
|
-
oxfmt:
|
|
26
|
+
oxfmt: eslint.Rule.RuleModule;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/parser.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import { createSyncFn } from "synckit";
|
|
|
3
3
|
import { URL, fileURLToPath } from "node:url";
|
|
4
4
|
import { DIFFERENCE, generateDifferences } from "generate-differences";
|
|
5
5
|
|
|
6
|
-
//#region
|
|
6
|
+
//#region \0rolldown/runtime.js
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
|
-
var __exportAll = (all,
|
|
8
|
+
var __exportAll = (all, no_symbols) => {
|
|
9
9
|
let target = {};
|
|
10
10
|
for (var name in all) {
|
|
11
11
|
__defProp(target, name, {
|
|
@@ -13,7 +13,7 @@ var __exportAll = (all, symbols) => {
|
|
|
13
13
|
enumerable: true
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
if (
|
|
16
|
+
if (!no_symbols) {
|
|
17
17
|
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
18
|
}
|
|
19
19
|
return target;
|
|
@@ -58,7 +58,7 @@ const recommended = {
|
|
|
58
58
|
name: "oxfmt/recommended",
|
|
59
59
|
languageOptions: { parser: parserPlain },
|
|
60
60
|
plugins: { get oxfmt() {
|
|
61
|
-
return
|
|
61
|
+
return plugin;
|
|
62
62
|
} },
|
|
63
63
|
rules: { "oxfmt/oxfmt": "error" }
|
|
64
64
|
};
|
|
@@ -67,7 +67,7 @@ const configs = { recommended };
|
|
|
67
67
|
//#endregion
|
|
68
68
|
//#region package.json
|
|
69
69
|
var name = "eslint-plugin-oxfmt";
|
|
70
|
-
var version = "0.0.
|
|
70
|
+
var version = "0.0.14";
|
|
71
71
|
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/meta.ts
|
|
@@ -170,7 +170,7 @@ const oxfmtOptionsSchema = {
|
|
|
170
170
|
type: "boolean"
|
|
171
171
|
},
|
|
172
172
|
embeddedLanguageFormatting: {
|
|
173
|
-
description: `Control whether to format embedded parts in
|
|
173
|
+
description: `Control whether to format embedded parts (For example, CSS-in-JS, or JS-in-Vue, etc.) in the file.\n\nNOTE: XXX-in-JS support is incomplete.\n\n- (Default: "auto")`,
|
|
174
174
|
enum: ["auto", "off"],
|
|
175
175
|
type: "string"
|
|
176
176
|
},
|
|
@@ -196,7 +196,7 @@ const oxfmtOptionsSchema = {
|
|
|
196
196
|
type: "object",
|
|
197
197
|
properties: {
|
|
198
198
|
elementNamePattern: {
|
|
199
|
-
description: `List of
|
|
199
|
+
description: `List of glob patterns to match import sources for this group.`,
|
|
200
200
|
type: "array",
|
|
201
201
|
items: { type: "string" }
|
|
202
202
|
},
|
|
@@ -264,7 +264,7 @@ const oxfmtOptionsSchema = {
|
|
|
264
264
|
type: "object",
|
|
265
265
|
properties: {
|
|
266
266
|
attributes: {
|
|
267
|
-
description: `List of attributes
|
|
267
|
+
description: `List of additional attributes to sort beyond "class" and "className" (exact match).\n\nNOTE: Regex patterns are not yet supported.\n\n- (Default: [])\n- Example: ["myClassProp", ":class"]`,
|
|
268
268
|
type: "array",
|
|
269
269
|
items: { type: "string" }
|
|
270
270
|
},
|
|
@@ -273,7 +273,7 @@ const oxfmtOptionsSchema = {
|
|
|
273
273
|
type: "string"
|
|
274
274
|
},
|
|
275
275
|
functions: {
|
|
276
|
-
description: `List of custom function names
|
|
276
|
+
description: `List of custom function names whose arguments should be sorted (exact match).\n\nNOTE: Regex patterns are not yet supported.\n\n- (Default: [])\n- Example: ["clsx", "cn", "cva", "tw"]`,
|
|
277
277
|
type: "array",
|
|
278
278
|
items: { type: "string" }
|
|
279
279
|
},
|
|
@@ -447,8 +447,8 @@ const oxfmt = {
|
|
|
447
447
|
},
|
|
448
448
|
create(context) {
|
|
449
449
|
if (!formatViaOxfmt) formatViaOxfmt = createSyncFn(join(dirWorkers, "oxfmt.mjs"));
|
|
450
|
+
const sourceText = context.sourceCode.text;
|
|
450
451
|
return { Program() {
|
|
451
|
-
const sourceText = context.sourceCode.text;
|
|
452
452
|
try {
|
|
453
453
|
const formatResult = formatViaOxfmt(context.filename, sourceText, {
|
|
454
454
|
...context.options?.[0],
|
|
@@ -511,7 +511,6 @@ const plugin = {
|
|
|
511
511
|
meta,
|
|
512
512
|
rules
|
|
513
513
|
};
|
|
514
|
-
var src_default = plugin;
|
|
515
514
|
|
|
516
515
|
//#endregion
|
|
517
|
-
export { configs,
|
|
516
|
+
export { configs, plugin as default, plugin, meta, parserPlain, recommended, rules };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-oxfmt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"description": "An ESLint plugin for formatting code with oxfmt.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"eslint",
|
|
@@ -44,41 +44,41 @@
|
|
|
44
44
|
"sideEffects": false,
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"eslint": "^9.5.0",
|
|
47
|
-
"oxfmt": "^0.
|
|
47
|
+
"oxfmt": "^0.31.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"generate-differences": "^0.1.1",
|
|
51
|
-
"load-oxfmt-config": "^0.1.
|
|
51
|
+
"load-oxfmt-config": "^0.1.1",
|
|
52
52
|
"picomatch": "^4.0.3",
|
|
53
53
|
"synckit": "^0.11.12"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@ntnyq/eslint-config": "^6.0.0-beta.
|
|
56
|
+
"@ntnyq/eslint-config": "^6.0.0-beta.8",
|
|
57
57
|
"@types/json-schema": "^7.0.15",
|
|
58
|
-
"@types/node": "^25.2.
|
|
59
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
60
|
-
"bumpp": "^10.4.
|
|
58
|
+
"@types/node": "^25.2.3",
|
|
59
|
+
"@typescript/native-preview": "^7.0.0-dev.20260210.1",
|
|
60
|
+
"bumpp": "^10.4.1",
|
|
61
61
|
"eslint": "^9.39.2",
|
|
62
62
|
"eslint-parser-plain": "^0.1.1",
|
|
63
63
|
"eslint-typegen": "^2.3.0",
|
|
64
|
-
"eslint-vitest-rule-tester": "^3.0
|
|
64
|
+
"eslint-vitest-rule-tester": "^3.1.0",
|
|
65
65
|
"husky": "^9.1.7",
|
|
66
66
|
"nano-staged": "^0.9.0",
|
|
67
67
|
"npm-run-all2": "^8.0.4",
|
|
68
|
-
"oxfmt": "^0.
|
|
68
|
+
"oxfmt": "^0.31.0",
|
|
69
69
|
"show-invisibles": "^0.0.2",
|
|
70
70
|
"tinyglobby": "^0.2.15",
|
|
71
|
-
"tsdown": "^0.20.
|
|
71
|
+
"tsdown": "^0.20.3",
|
|
72
72
|
"tsx": "^4.21.0",
|
|
73
73
|
"typescript": "^5.9.3",
|
|
74
74
|
"vitest": "^4.0.18",
|
|
75
|
-
"eslint-plugin-oxfmt": "0.0.
|
|
75
|
+
"eslint-plugin-oxfmt": "0.0.14"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": "^20.19.0 || >=22.12.0"
|
|
79
79
|
},
|
|
80
80
|
"nano-staged": {
|
|
81
|
-
"*.{js,ts,mjs,
|
|
81
|
+
"*.{js,ts,mjs,tsx,md,vue,yml,yaml,toml,json}": "eslint --fix",
|
|
82
82
|
"*": "oxfmt --no-error-on-unmatched-pattern"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
package/workers/oxfmt.mjs
CHANGED
|
@@ -12,16 +12,11 @@ import { runAsWorker } from 'synckit'
|
|
|
12
12
|
* @property {string} cwd - Current working directory for resolving configuration
|
|
13
13
|
* @property {string} [configPath] - Custom path to oxfmt configuration file
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
15
|
/**
|
|
17
|
-
* @typedef {
|
|
18
|
-
* @property {string[]} files - Glob patterns to match files
|
|
19
|
-
* @property {string[]} [excludeFiles] - Glob patterns to exclude files
|
|
20
|
-
* @property {import('oxfmt').FormatOptions} [options] - Format options to apply
|
|
16
|
+
* @typedef {import('load-oxfmt-config').FormatOptionOverride} Override
|
|
21
17
|
*/
|
|
22
|
-
|
|
23
18
|
/**
|
|
24
|
-
* @typedef {import('oxfmt').
|
|
19
|
+
* @typedef {import('load-oxfmt-config').OxfmtOptions & PluginOptions} Options
|
|
25
20
|
*/
|
|
26
21
|
|
|
27
22
|
/**
|
|
@@ -49,29 +44,29 @@ function applyOverrides(
|
|
|
49
44
|
// Get relative path from cwd and normalize to forward slashes for cross-platform compatibility
|
|
50
45
|
const relativePath = relative(cwd, filename).replace(/\\/g, '/')
|
|
51
46
|
|
|
52
|
-
let mergedOptions =
|
|
47
|
+
let mergedOptions = baseOptions
|
|
48
|
+
let hasOverrides = false
|
|
53
49
|
|
|
54
50
|
// Apply overrides in order (later overrides take precedence)
|
|
55
51
|
for (const override of overrides) {
|
|
56
52
|
const { excludeFiles, files, options: overrideOptions } = override
|
|
57
53
|
|
|
58
54
|
// Check if file matches the files patterns
|
|
59
|
-
const
|
|
60
|
-
const matches = isMatchFiles(relativePath)
|
|
55
|
+
const matches = picomatch.isMatch(relativePath, files)
|
|
61
56
|
|
|
62
57
|
// Check if file is excluded
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
58
|
+
const excluded =
|
|
59
|
+
excludeFiles && excludeFiles.length > 0
|
|
60
|
+
? picomatch.isMatch(relativePath, excludeFiles)
|
|
61
|
+
: false
|
|
68
62
|
|
|
69
63
|
if (matches && !excluded && overrideOptions) {
|
|
70
64
|
mergedOptions = { ...mergedOptions, ...overrideOptions }
|
|
65
|
+
hasOverrides = true
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
|
|
74
|
-
return mergedOptions
|
|
69
|
+
return hasOverrides ? mergedOptions : baseOptions
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
runAsWorker(
|
|
@@ -84,7 +79,7 @@ runAsWorker(
|
|
|
84
79
|
* @type {string} source text
|
|
85
80
|
*/
|
|
86
81
|
sourceText,
|
|
87
|
-
/**
|
|
82
|
+
/**
|
|
88
83
|
* @type {Options} format options
|
|
89
84
|
*/
|
|
90
85
|
options,
|
|
@@ -109,7 +104,12 @@ runAsWorker(
|
|
|
109
104
|
}
|
|
110
105
|
|
|
111
106
|
// Apply overrides based on filename
|
|
112
|
-
const mergedOptions = applyOverrides(
|
|
107
|
+
const mergedOptions = applyOverrides(
|
|
108
|
+
filename,
|
|
109
|
+
cwd,
|
|
110
|
+
baseOptions,
|
|
111
|
+
useConfig ? baseOptions.overrides : overrides,
|
|
112
|
+
)
|
|
113
113
|
|
|
114
114
|
const formatResult = await format(filename, sourceText, mergedOptions)
|
|
115
115
|
return formatResult
|