@ac-kit/format-editorconfig 0.1.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/LICENSE +28 -0
- package/README.md +38 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/parse-editorconfig.d.ts +28 -0
- package/dist/parse-editorconfig.d.ts.map +1 -0
- package/dist/parse-editorconfig.js +120 -0
- package/dist/parse-editorconfig.js.map +1 -0
- package/dist/properties.d.ts +35 -0
- package/dist/properties.d.ts.map +1 -0
- package/dist/properties.js +7 -0
- package/dist/properties.js.map +1 -0
- package/dist/resolve-editorconfig.d.ts +27 -0
- package/dist/resolve-editorconfig.d.ts.map +1 -0
- package/dist/resolve-editorconfig.js +63 -0
- package/dist/resolve-editorconfig.js.map +1 -0
- package/dist/text-style.d.ts +29 -0
- package/dist/text-style.d.ts.map +1 -0
- package/dist/text-style.js +62 -0
- package/dist/text-style.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Anthony Champagne and contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @ac-kit/format-editorconfig
|
|
2
|
+
|
|
3
|
+
Parse `.editorconfig` files, resolve the properties that apply to a path, and
|
|
4
|
+
apply them to text.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import {
|
|
8
|
+
applyEditorConfigStyle,
|
|
9
|
+
parseEditorConfig,
|
|
10
|
+
resolveEditorConfig,
|
|
11
|
+
} from "@ac-kit/format-editorconfig";
|
|
12
|
+
|
|
13
|
+
const properties = resolveEditorConfig(
|
|
14
|
+
[{ directory: "/repo", file: parseEditorConfig(source) }],
|
|
15
|
+
"/repo/src/main.ts",
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const normalized = applyEditorConfigStyle(text, properties);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Resolution is separate from the file walk
|
|
22
|
+
|
|
23
|
+
`resolveEditorConfig` takes files that have already been read, ordered outermost
|
|
24
|
+
first, and returns the merged properties for one path. Ascending the directory
|
|
25
|
+
tree and stopping at `root = true` needs a filesystem, so it lives in
|
|
26
|
+
`@ac-kit/app-config` instead — which is what keeps this package portable.
|
|
27
|
+
|
|
28
|
+
## What `applyEditorConfigStyle` does not do
|
|
29
|
+
|
|
30
|
+
It applies `end_of_line`, `insert_final_newline` and `trim_trailing_whitespace`.
|
|
31
|
+
It deliberately does not re-indent: honouring `indent_style` and `indent_size`
|
|
32
|
+
means knowing the language's own nesting, and any text-level rule that tries
|
|
33
|
+
corrupts string literals and here-documents. Use `detectEditorConfigStyle` to
|
|
34
|
+
report what a file already does, including its indentation.
|
|
35
|
+
|
|
36
|
+
See the
|
|
37
|
+
[generated API docs](https://anthochamp.github.io/node-essentials/api/format-editorconfig/)
|
|
38
|
+
for the full reference.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { EditorConfigProperties } from "./properties.js";
|
|
2
|
+
/**
|
|
3
|
+
* One `.editorconfig` file: its `root` flag and its sections, in source order.
|
|
4
|
+
*
|
|
5
|
+
* Order is load-bearing — a later matching section overrides an earlier one —
|
|
6
|
+
* which is why this is a list rather than a map.
|
|
7
|
+
*/
|
|
8
|
+
export type EditorConfigFile = {
|
|
9
|
+
/** `root = true` in the preamble stops the search at this file. */
|
|
10
|
+
readonly root: boolean;
|
|
11
|
+
readonly sections: readonly EditorConfigSection[];
|
|
12
|
+
};
|
|
13
|
+
/** One `[glob]` section. */
|
|
14
|
+
export type EditorConfigSection = {
|
|
15
|
+
/** The section header verbatim, to be matched with the editorconfig dialect. */
|
|
16
|
+
readonly pattern: string;
|
|
17
|
+
readonly properties: EditorConfigProperties;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Parses one `.editorconfig` file.
|
|
21
|
+
*
|
|
22
|
+
* The INI syntax comes from `@ac-kit/format-ini`'s order-preserving document
|
|
23
|
+
* tree; everything here is the EditorConfig semantics layered on top — property
|
|
24
|
+
* names and values are case-insensitive, `unset` erases, and anything the spec
|
|
25
|
+
* does not define is preserved rather than dropped.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseEditorConfig(source: string): EditorConfigFile;
|
|
28
|
+
//# sourceMappingURL=parse-editorconfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-editorconfig.d.ts","sourceRoot":"","sources":["../src/parse-editorconfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAClD,CAAC;AAEF,4BAA4B;AAC5B,MAAM,MAAM,mBAAmB,GAAG;IACjC,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,sBAAsB,CAAC;CAC5C,CAAC;AAqFF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAmDlE"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { parseIniDocument } from "@ac-kit/format-ini";
|
|
2
|
+
const KNOWN_ = new Set([
|
|
3
|
+
"indent_style",
|
|
4
|
+
"indent_size",
|
|
5
|
+
"tab_width",
|
|
6
|
+
"end_of_line",
|
|
7
|
+
"charset",
|
|
8
|
+
"trim_trailing_whitespace",
|
|
9
|
+
"insert_final_newline",
|
|
10
|
+
"max_line_length",
|
|
11
|
+
]);
|
|
12
|
+
function toBoolean(raw) {
|
|
13
|
+
if (raw === "true") {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (raw === "false") {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
function toNumber(raw) {
|
|
22
|
+
const value = Number(raw);
|
|
23
|
+
return Number.isInteger(value) && value >= 0 ? value : undefined;
|
|
24
|
+
}
|
|
25
|
+
function assignProperty(target, unknown, name, raw) {
|
|
26
|
+
// The spec lower-cases both halves, and `unset` means "say nothing", which is
|
|
27
|
+
// the same as never having been written.
|
|
28
|
+
if (raw === "unset") {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!KNOWN_.has(name)) {
|
|
32
|
+
unknown[name] = raw;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
switch (name) {
|
|
36
|
+
case "indent_style":
|
|
37
|
+
if (raw === "tab" || raw === "space") {
|
|
38
|
+
target.indentStyle = raw;
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case "indent_size":
|
|
42
|
+
target.indentSize = raw === "tab" ? "tab" : toNumber(raw);
|
|
43
|
+
break;
|
|
44
|
+
case "tab_width":
|
|
45
|
+
target.tabWidth = toNumber(raw);
|
|
46
|
+
break;
|
|
47
|
+
case "end_of_line":
|
|
48
|
+
if (raw === "lf" || raw === "crlf" || raw === "cr") {
|
|
49
|
+
target.endOfLine = raw;
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case "charset":
|
|
53
|
+
target.charset = raw;
|
|
54
|
+
break;
|
|
55
|
+
case "trim_trailing_whitespace":
|
|
56
|
+
target.trimTrailingWhitespace = toBoolean(raw);
|
|
57
|
+
break;
|
|
58
|
+
case "insert_final_newline":
|
|
59
|
+
target.insertFinalNewline = toBoolean(raw);
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
target.maxLineLength = raw === "off" ? "off" : toNumber(raw);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
if (target[camelOf(name)] === undefined) {
|
|
66
|
+
delete target[camelOf(name)];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function camelOf(name) {
|
|
70
|
+
return name.replace(/_(\w)/g, (_match, char) => char.toUpperCase());
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Parses one `.editorconfig` file.
|
|
74
|
+
*
|
|
75
|
+
* The INI syntax comes from `@ac-kit/format-ini`'s order-preserving document
|
|
76
|
+
* tree; everything here is the EditorConfig semantics layered on top — property
|
|
77
|
+
* names and values are case-insensitive, `unset` erases, and anything the spec
|
|
78
|
+
* does not define is preserved rather than dropped.
|
|
79
|
+
*/
|
|
80
|
+
export function parseEditorConfig(source) {
|
|
81
|
+
const { nodes } = parseIniDocument(source);
|
|
82
|
+
let root = false;
|
|
83
|
+
const sections = [];
|
|
84
|
+
let current;
|
|
85
|
+
const flush = () => {
|
|
86
|
+
if (!current) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const properties = current.target;
|
|
90
|
+
sections.push({
|
|
91
|
+
pattern: current.pattern,
|
|
92
|
+
properties: Object.keys(current.unknown).length > 0
|
|
93
|
+
? { ...properties, unknown: current.unknown }
|
|
94
|
+
: properties,
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
for (const node of nodes) {
|
|
98
|
+
if (node.kind === "section") {
|
|
99
|
+
flush();
|
|
100
|
+
current = { pattern: node.raw.trim(), target: {}, unknown: {} };
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (node.kind !== "property" || node.value === undefined) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const name = node.key.toLowerCase();
|
|
107
|
+
const raw = node.value.toLowerCase();
|
|
108
|
+
if (!current) {
|
|
109
|
+
// Preamble: only `root` is defined there.
|
|
110
|
+
if (name === "root") {
|
|
111
|
+
root = toBoolean(raw) ?? false;
|
|
112
|
+
}
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
assignProperty(current.target, current.unknown, name, raw);
|
|
116
|
+
}
|
|
117
|
+
flush();
|
|
118
|
+
return { root, sections };
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=parse-editorconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-editorconfig.js","sourceRoot":"","sources":["../src/parse-editorconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAuBtD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;IACtB,cAAc;IACd,aAAa;IACb,WAAW;IACX,aAAa;IACb,SAAS;IACT,0BAA0B;IAC1B,sBAAsB;IACtB,iBAAiB;CACjB,CAAC,CAAC;AAEH,SAAS,SAAS,CAAC,GAAW;IAC7B,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAA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7B,KAAK,EAAE,CAAC;YACR,OAAO,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YAChE,SAAS;QACV,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1D,SAAS;QACV,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAErC,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,0CAA0C;YAC1C,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACrB,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC;YAChC,CAAC;YACD,SAAS;QACV,CAAC;QACD,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC;IACD,KAAK,EAAE,CAAC;IAER,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The properties EditorConfig defines, with their spec spellings resolved to
|
|
3
|
+
* values a program can act on.
|
|
4
|
+
*
|
|
5
|
+
* Every field is optional: an unset property means the file said nothing about
|
|
6
|
+
* it, which is different from setting it off. `"unset"` in the source also
|
|
7
|
+
* lands here as absent, since that is exactly what it means.
|
|
8
|
+
*/
|
|
9
|
+
export type EditorConfigProperties = {
|
|
10
|
+
/** `indent_style`. */
|
|
11
|
+
readonly indentStyle?: "tab" | "space";
|
|
12
|
+
/** `indent_size`; `"tab"` defers to {@link tabWidth}. */
|
|
13
|
+
readonly indentSize?: number | "tab";
|
|
14
|
+
/** `tab_width`. Defaults to `indent_size` when that is a number. */
|
|
15
|
+
readonly tabWidth?: number;
|
|
16
|
+
/** `end_of_line`. */
|
|
17
|
+
readonly endOfLine?: "lf" | "crlf" | "cr";
|
|
18
|
+
/** `charset`. */
|
|
19
|
+
readonly charset?: string;
|
|
20
|
+
/** `trim_trailing_whitespace`. */
|
|
21
|
+
readonly trimTrailingWhitespace?: boolean;
|
|
22
|
+
/** `insert_final_newline`. */
|
|
23
|
+
readonly insertFinalNewline?: boolean;
|
|
24
|
+
/** `max_line_length`; `"off"` where the spec allows disabling it. */
|
|
25
|
+
readonly maxLineLength?: number | "off";
|
|
26
|
+
/** Properties the spec does not define, preserved with their raw values. */
|
|
27
|
+
readonly unknown?: Readonly<Record<string, string>>;
|
|
28
|
+
};
|
|
29
|
+
/** The line terminator an {@link EditorConfigProperties.endOfLine} names. */
|
|
30
|
+
export declare const END_OF_LINE_SEQUENCES: {
|
|
31
|
+
readonly lf: "\n";
|
|
32
|
+
readonly crlf: "\r\n";
|
|
33
|
+
readonly cr: "\r";
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC,sBAAsB;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;IAEvC,yDAAyD;IACzD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAErC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B,qBAAqB;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IAE1C,iBAAiB;IACjB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,kCAAkC;IAClC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAE1C,8BAA8B;IAC9B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAEtC,qEAAqE;IACrE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAExC,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB;iBAC7B,IAAI;mBACF,MAAM;iBACR,IAAI;CACkC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":"AAqCA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI;CACkC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { EditorConfigFile } from "./parse-editorconfig.js";
|
|
2
|
+
import type { EditorConfigProperties } from "./properties.js";
|
|
3
|
+
/**
|
|
4
|
+
* One `.editorconfig` file paired with the directory it was found in.
|
|
5
|
+
*
|
|
6
|
+
* The directory is what a section glob is resolved against, so a caller reading
|
|
7
|
+
* files off disk must report where each came from.
|
|
8
|
+
*/
|
|
9
|
+
export type EditorConfigSource = {
|
|
10
|
+
/** Directory holding the file, with `/` separators and no trailing slash. */
|
|
11
|
+
readonly directory: string;
|
|
12
|
+
readonly file: EditorConfigFile;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the properties that apply to `path`.
|
|
16
|
+
*
|
|
17
|
+
* `sources` must be ordered **outermost first** — the root of the search down
|
|
18
|
+
* to the directory holding the file — because a later section overrides an
|
|
19
|
+
* earlier one, and a nearer `.editorconfig` overrides a further one. Reading
|
|
20
|
+
* the files and stopping at `root = true` is the caller's job; that walk is
|
|
21
|
+
* host-bound, and keeping it out is what lets this package stay portable.
|
|
22
|
+
*
|
|
23
|
+
* `indent_size` and `tab_width` are cross-filled per the spec: each defaults to
|
|
24
|
+
* the other where only one was given.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveEditorConfig(sources: readonly EditorConfigSource[], path: string): EditorConfigProperties;
|
|
27
|
+
//# sourceMappingURL=resolve-editorconfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-editorconfig.d.ts","sourceRoot":"","sources":["../src/resolve-editorconfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAqCF;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,SAAS,kBAAkB,EAAE,EACtC,IAAI,EAAE,MAAM,GACV,sBAAsB,CA0BxB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { compileGlob } from "@ac-kit/format-glob";
|
|
2
|
+
/**
|
|
3
|
+
* Expands a section header into the glob the spec says to match.
|
|
4
|
+
*
|
|
5
|
+
* A pattern containing no `/` matches at any depth; one that does is anchored
|
|
6
|
+
* to the directory holding the file. A leading `/` anchors without implying a
|
|
7
|
+
* separator of its own.
|
|
8
|
+
*/
|
|
9
|
+
function patternFor(directory, pattern) {
|
|
10
|
+
const prefix = directory.endsWith("/") ? directory : `${directory}/`;
|
|
11
|
+
if (!pattern.includes("/")) {
|
|
12
|
+
return `${prefix}**/${pattern}`;
|
|
13
|
+
}
|
|
14
|
+
return `${prefix}${pattern.startsWith("/") ? pattern.slice(1) : pattern}`;
|
|
15
|
+
}
|
|
16
|
+
function merge(into, from) {
|
|
17
|
+
for (const [key, value] of Object.entries(from)) {
|
|
18
|
+
if (value === undefined) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (key === "unknown") {
|
|
22
|
+
into.unknown = {
|
|
23
|
+
...into.unknown,
|
|
24
|
+
...value,
|
|
25
|
+
};
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
into[key] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the properties that apply to `path`.
|
|
33
|
+
*
|
|
34
|
+
* `sources` must be ordered **outermost first** — the root of the search down
|
|
35
|
+
* to the directory holding the file — because a later section overrides an
|
|
36
|
+
* earlier one, and a nearer `.editorconfig` overrides a further one. Reading
|
|
37
|
+
* the files and stopping at `root = true` is the caller's job; that walk is
|
|
38
|
+
* host-bound, and keeping it out is what lets this package stay portable.
|
|
39
|
+
*
|
|
40
|
+
* `indent_size` and `tab_width` are cross-filled per the spec: each defaults to
|
|
41
|
+
* the other where only one was given.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveEditorConfig(sources, path) {
|
|
44
|
+
const resolved = {};
|
|
45
|
+
for (const source of sources) {
|
|
46
|
+
for (const section of source.file.sections) {
|
|
47
|
+
const matches = compileGlob(patternFor(source.directory, section.pattern), "editorconfig");
|
|
48
|
+
if (matches(path)) {
|
|
49
|
+
merge(resolved, section.properties);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const properties = resolved;
|
|
54
|
+
if (properties.indentSize === "tab" && properties.tabWidth !== undefined) {
|
|
55
|
+
resolved.indentSize = properties.tabWidth;
|
|
56
|
+
}
|
|
57
|
+
else if (properties.tabWidth === undefined &&
|
|
58
|
+
typeof properties.indentSize === "number") {
|
|
59
|
+
resolved.tabWidth = properties.indentSize;
|
|
60
|
+
}
|
|
61
|
+
return properties;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=resolve-editorconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-editorconfig.js","sourceRoot":"","sources":["../src/resolve-editorconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAiBlD;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,SAAiB,EAAE,OAAe;IACrD,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC;IAErE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,GAAG,MAAM,MAAM,OAAO,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AAC3E,CAAC;AAED,SAAS,KAAK,CACb,IAA6B,EAC7B,IAA4B;IAE5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,SAAS;QACV,CAAC;QACD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG;gBACd,GAAI,IAAI,CAAC,OAA8C;gBACvD,GAAI,KAAgC;aACpC,CAAC;YACF,SAAS;QACV,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;AACF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAClC,OAAsC,EACtC,IAAY;IAEZ,MAAM,QAAQ,GAA4B,EAAE,CAAC;IAE7C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5C,MAAM,OAAO,GAAG,WAAW,CAC1B,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,EAC7C,cAAc,CACd,CAAC;YACF,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;YACrC,CAAC;QACF,CAAC;IACF,CAAC;IAED,MAAM,UAAU,GAAG,QAAkC,CAAC;IACtD,IAAI,UAAU,CAAC,UAAU,KAAK,KAAK,IAAI,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC1E,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC;IAC3C,CAAC;SAAM,IACN,UAAU,CAAC,QAAQ,KAAK,SAAS;QACjC,OAAO,UAAU,CAAC,UAAU,KAAK,QAAQ,EACxC,CAAC;QACF,QAAQ,CAAC,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type EditorConfigProperties } from "./properties.js";
|
|
2
|
+
/**
|
|
3
|
+
* What a piece of text currently does, in EditorConfig's own vocabulary.
|
|
4
|
+
*
|
|
5
|
+
* Every field is optional for the same reason it is on
|
|
6
|
+
* {@link EditorConfigProperties}: the text may be silent about a property — no
|
|
7
|
+
* indented line reveals nothing about `indent_style` — and "unknown" is not
|
|
8
|
+
* "off".
|
|
9
|
+
*/
|
|
10
|
+
export type DetectedStyle = Pick<EditorConfigProperties, "indentStyle" | "indentSize" | "endOfLine" | "insertFinalNewline" | "trimTrailingWhitespace">;
|
|
11
|
+
/**
|
|
12
|
+
* Reports which EditorConfig properties `content` already satisfies.
|
|
13
|
+
*
|
|
14
|
+
* Mixed line endings leave `endOfLine` unset rather than guessing a winner.
|
|
15
|
+
* `trimTrailingWhitespace` is reported as `true` only when no line has trailing
|
|
16
|
+
* whitespace — the property describes the desired end state, so text that
|
|
17
|
+
* already complies reports the value that would keep it that way.
|
|
18
|
+
*/
|
|
19
|
+
export declare function detectEditorConfigStyle(content: string): DetectedStyle;
|
|
20
|
+
/**
|
|
21
|
+
* Rewrites `content` so it satisfies the properties given.
|
|
22
|
+
*
|
|
23
|
+
* Only the properties present are applied; the rest are left exactly as they
|
|
24
|
+
* are. `indent_style` and `indent_size` are deliberately not applied here —
|
|
25
|
+
* re-indenting requires knowing the language's own nesting, which no text-level
|
|
26
|
+
* rule can supply without corrupting strings and here-docs.
|
|
27
|
+
*/
|
|
28
|
+
export declare function applyEditorConfigStyle(content: string, properties: EditorConfigProperties): string;
|
|
29
|
+
//# sourceMappingURL=text-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-style.d.ts","sourceRoot":"","sources":["../src/text-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,sBAAsB,EAC3B,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAC/B,sBAAsB,EACpB,aAAa,GACb,YAAY,GACZ,WAAW,GACX,oBAAoB,GACpB,wBAAwB,CAC1B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CA0BtE;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,sBAAsB,GAChC,MAAM,CAwBR"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { END_OF_LINE_SEQUENCES, } from "./properties.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reports which EditorConfig properties `content` already satisfies.
|
|
4
|
+
*
|
|
5
|
+
* Mixed line endings leave `endOfLine` unset rather than guessing a winner.
|
|
6
|
+
* `trimTrailingWhitespace` is reported as `true` only when no line has trailing
|
|
7
|
+
* whitespace — the property describes the desired end state, so text that
|
|
8
|
+
* already complies reports the value that would keep it that way.
|
|
9
|
+
*/
|
|
10
|
+
export function detectEditorConfigStyle(content) {
|
|
11
|
+
const hasCrLf = content.includes("\r\n");
|
|
12
|
+
const hasLf = /(?<!\r)\n/.test(content);
|
|
13
|
+
const hasCr = /\r(?!\n)/.test(content);
|
|
14
|
+
const detected = {};
|
|
15
|
+
const kinds = [hasLf, hasCrLf, hasCr].filter(Boolean).length;
|
|
16
|
+
if (kinds === 1) {
|
|
17
|
+
detected.endOfLine = hasCrLf ? "crlf" : hasLf ? "lf" : "cr";
|
|
18
|
+
}
|
|
19
|
+
const indent = /^([\t ]+)\S/m.exec(content)?.[1];
|
|
20
|
+
if (indent !== undefined) {
|
|
21
|
+
detected.indentStyle = indent.startsWith("\t") ? "tab" : "space";
|
|
22
|
+
if (detected.indentStyle === "space") {
|
|
23
|
+
detected.indentSize = indent.length;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (content.length > 0) {
|
|
27
|
+
detected.insertFinalNewline = /\r?\n$/.test(content);
|
|
28
|
+
}
|
|
29
|
+
detected.trimTrailingWhitespace = !/[\t ]+(?:\r?\n|$)/m.test(content);
|
|
30
|
+
return detected;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Rewrites `content` so it satisfies the properties given.
|
|
34
|
+
*
|
|
35
|
+
* Only the properties present are applied; the rest are left exactly as they
|
|
36
|
+
* are. `indent_style` and `indent_size` are deliberately not applied here —
|
|
37
|
+
* re-indenting requires knowing the language's own nesting, which no text-level
|
|
38
|
+
* rule can supply without corrupting strings and here-docs.
|
|
39
|
+
*/
|
|
40
|
+
export function applyEditorConfigStyle(content, properties) {
|
|
41
|
+
let result = content;
|
|
42
|
+
if (properties.trimTrailingWhitespace === true) {
|
|
43
|
+
result = result.replace(/[ \t]+(?=\r?\n|$)/g, "");
|
|
44
|
+
}
|
|
45
|
+
const newline = properties.endOfLine
|
|
46
|
+
? END_OF_LINE_SEQUENCES[properties.endOfLine]
|
|
47
|
+
: undefined;
|
|
48
|
+
if (newline !== undefined) {
|
|
49
|
+
result = result.replace(/\r\n|\n|\r/g, newline);
|
|
50
|
+
}
|
|
51
|
+
if (properties.insertFinalNewline !== undefined) {
|
|
52
|
+
const terminator = /(?:\r\n|\n|\r)$/.exec(result);
|
|
53
|
+
if (properties.insertFinalNewline && terminator === null) {
|
|
54
|
+
result += newline ?? "\n";
|
|
55
|
+
}
|
|
56
|
+
else if (!properties.insertFinalNewline && terminator !== null) {
|
|
57
|
+
result = result.slice(0, -terminator[0].length);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=text-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-style.js","sourceRoot":"","sources":["../src/text-style.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,GAErB,MAAM,iBAAiB,CAAC;AAmBzB;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACtD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEvC,MAAM,QAAQ,GAA4B,EAAE,CAAC;IAE7C,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAC7D,IAAI,KAAK,KAA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E,CAAC;QAC3B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,UAAU,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;QACjD,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,UAAU,CAAC,kBAAkB,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YAC1D,MAAM,IAAI,OAAO,IAAI,IAAI,CAAC;QAC3B,CAAC;aAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YAClE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ac-kit/format-editorconfig",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Parse .editorconfig files, resolve the properties that apply to a path, and apply them to text.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"editorconfig",
|
|
7
|
+
"formatting",
|
|
8
|
+
"parser"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://anthochamp.github.io/node-essentials/api/format-editorconfig/",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/anthochamp/node-essentials/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "BSD-3-Clause",
|
|
15
|
+
"author": "Anthony Champagne <dev@anthonychampagne.fr>",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/anthochamp/node-essentials.git",
|
|
19
|
+
"directory": "packages/format-editorconfig"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"compile": "tsc -p ./tsconfig.build.json -outDir dist",
|
|
39
|
+
"compile:check": "tsc -noEmit -p ./tsconfig.json",
|
|
40
|
+
"clean": "rimraf dist",
|
|
41
|
+
"build": "yarn clean && yarn compile",
|
|
42
|
+
"test": "yarn run -T vitest run",
|
|
43
|
+
"prepack": "yarn build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@ac-kit/core": "^0.1.0",
|
|
47
|
+
"@ac-kit/format-glob": "^0.1.0",
|
|
48
|
+
"@ac-kit/format-ini": "^0.1.0",
|
|
49
|
+
"@types/web": "^0.0.354"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@ac-kit/tsconfig": "0.1.0",
|
|
53
|
+
"@ac-kit/typedoc-config": "0.1.0",
|
|
54
|
+
"@ac-kit/vitest-config": "0.1.0",
|
|
55
|
+
"@typescript/native": "typescript@7.0.2",
|
|
56
|
+
"rimraf": "6.1.3",
|
|
57
|
+
"typedoc": "0.28.20",
|
|
58
|
+
"typescript": "@typescript/typescript6@6.0.2"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=24"
|
|
62
|
+
}
|
|
63
|
+
}
|