Standard: EditorConfig
EditorConfig: the project has an .editorconfig with root = true, and files follow it: line endings, a final newline, trailing whitespace, encoding; indentation and line length are observed.
About the package
What the standard is. EditorConfig is an .editorconfig file where a project sets how editors save files: line endings, indentation, encoding. The specification: https://spec.editorconfig.org/ (version 0.17.2), the site https://editorconfig.org/. The file has sections with globs ([*.rs]), and properties in them. The .editorconfig nearest to a file outweighs a farther one; the search up through folders ends at a file with root = true.
When to install. People and agents write in the project in different editors and on different systems. Without shared rules, CRLF appears next to LF, along with trailing whitespace and "whole-file" edits that hide the point of a change.
How to configure. The rules themselves are in the project's .editorconfig: the package does not invent them but checks them. The page /norms/standards/editorconfig.md: what not to check (exclude, globs from the root; by default vendor/, third_party/, fixtures), the file size limit (maxBytes) and changedSince, to check only files touched since that day. changedSince is for a project with old debt: new edits are clean, old ones are fixed gradually.
Files are taken from git (tracked and new ones, without ignored ones); without git, by walking folders without node_modules, target, dist and similar. Binary files are skipped.
What is checked
- EC-R01 (MUST, enforce):
.editorconfigexists in the root or above, the search ends atroot = true, and the file has at least one section. Thepresentcheck. - EC-R02 (MUST, enforce): a file matches the exact properties:
end_of_line(lf, crlf, cr),insert_final_newline = true,trim_trailing_whitespace = true,charset(utf-8 is valid UTF-8 without a BOM; utf-8-bom is with a BOM). There is no guessing here: the bytes are either so or not. Thefilescheck. - EC-R03 (SHOULD, observe): indentation by
indent_style(no tabs withspace; no two or more spaces in an indent withtab) and lines not longer thanmax_line_length. It observes: multi-line strings, here-documents and continuation alignment give false findings. Theindentcheck.
Globs are read by the specification: *, **, ?, [set], [!set], {a,b}, {1..9}; a glob without / applies to the file name in any folder. The value unset removes a property.
What is not checked
insert_final_newline = false(the standard says "make sure there is no newline", but editors almost never do this),indent_sizeandtab_width(the indent width breaks alignment),charsetlatin1 and utf-16.- Whether the
.editorconfigrules themselves are good: for example, Markdown usually keeps trailing spaces (they are a line break), and.diffand.patchkeep context spaces. The owner decides this in.editorconfigitself.
The package only reads files. It fixes nothing.
Norms 3
| ID | Norm | Level | Mode | Enforcer |
|---|---|---|---|---|
| EC-R01 | MUST | blocks | check |
|
| EC-R02 | MUST | blocks | check |
|
| EC-R03 | SHOULD | observes | sensor |
"Blocks": the enforcer stops a violation. "Observes": it only notes it. Level MUST means required; SHOULD means yes by default.
Actions 3
| Name | What it does | File | When |
|---|---|---|---|
| present | .editorconfig exists, the search ends at root = true norm EC-R01 | checks/ec01_present.ts | check |
| files | Line endings, final newline, trailing whitespace, encoding match .editorconfig norm EC-R02 | checks/ec02_files.ts | check |
| indent | Indentation and line length match .editorconfig (observes) norm EC-R03 | checks/ec03_indent.ts | check |
shtuk check runs the checks; shtuk run std-editorconfig <name> runs any action. "After install" actions run by themselves only if the package comes from a trusted source.
Pages 4
They go into the project at these paths.
- /norms/rules/std-editorconfig/
- The project has an .editorconfig with root = true EC-R01
- Files match .editorconfig: line endings, final newline, trailing whitespace, encoding EC-R02
- Indentation and line length match .editorconfig EC-R03
- /norms/standards/
- Settings: EditorConfig page
Package files 6
They go into .shtukbase/packages/std-editorconfig/; actions run from there.