c3b-lint 0.0.2 → 0.0.4
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 +3 -3
- package/c3b-lint.js +14 -1
- package/check/structure.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,9 +20,9 @@ markdown that a tool can check, with one command and one config to install. It r
|
|
|
20
20
|
otherwise, `<main id="main">`), one `<h1>`, `alt` on every image, no inline handlers, no `<style>` or `style=""`
|
|
21
21
|
(except a JS-driven custom property), relative paths only, kebab-case ids and classes, no duplicate ids,
|
|
22
22
|
`integrity` on CDN scripts.
|
|
23
|
-
5. **Project structure**: singular directory names, lowercase kebab-case asset names (and no camera exports),
|
|
24
|
-
only in `src/style/` + `style/page/` + `style/animation/`, JS only in `src/script/`,
|
|
25
|
-
`src/asset/font/` as woff2, file names starting with a letter.
|
|
23
|
+
5. **Project structure**: singular directory names, lowercase kebab-case asset names (and no camera exports), and,
|
|
24
|
+
when `src/` holds pages, CSS only in `src/style/` + `style/page/` + `style/animation/`, JS only in `src/script/`,
|
|
25
|
+
fonts only in `src/asset/font/` as woff2, file names starting with a letter.
|
|
26
26
|
6. The **500-line limit** on `src/**/*.{css,html}` (ESLint reports the JS).
|
|
27
27
|
7. That the project's **`.editorconfig`** is the shared one — it carries the JetBrains `ij_*` code-style keys, so
|
|
28
28
|
WebStorm and IntelliJ format the same way without committing `.idea/`.
|
package/c3b-lint.js
CHANGED
|
@@ -27,7 +27,16 @@ const EDITORCONFIG = resolve('.editorconfig');
|
|
|
27
27
|
|
|
28
28
|
// The project's own config file when it has one (the one-liner --init writes, or an extended copy for
|
|
29
29
|
// a project that needs an exception), so the CLI and WebStorm always agree; this package's otherwise.
|
|
30
|
-
|
|
30
|
+
// A .mjs variant is accepted for a package that is not "type": "module" (colab-client).
|
|
31
|
+
function configFor(file) {
|
|
32
|
+
for (const candidate of [file, file.replace(/\.js$/, '.mjs')]) {
|
|
33
|
+
if (existsSync(resolve(candidate))) {
|
|
34
|
+
return resolve(candidate);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return join(CONFIG_DIR, file);
|
|
39
|
+
}
|
|
31
40
|
const MAX_LINES = 500;
|
|
32
41
|
|
|
33
42
|
// Files --init writes at the project root. The .editorconfig is a copy (it has to be a real
|
|
@@ -87,6 +96,10 @@ function writeBaseline() {
|
|
|
87
96
|
if (existsSync(path) && readFileSync(path, 'utf8') === content) {
|
|
88
97
|
continue;
|
|
89
98
|
}
|
|
99
|
+
// a project keeping a .mjs config (not "type": "module") has made its choice
|
|
100
|
+
if (file.endsWith('.js') && existsSync(path.replace(/\.js$/, '.mjs'))) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
90
103
|
console.log(` write ${ file }`);
|
|
91
104
|
writeFileSync(path, content);
|
|
92
105
|
}
|
package/check/structure.js
CHANGED
|
@@ -61,7 +61,9 @@ function checkAssetNames(report) {
|
|
|
61
61
|
// CSS lives in src/style/ (reset, tokens, main, components) with pages in style/page/ and animations
|
|
62
62
|
// in style/animation/; JS in src/script/ (WebGL helpers in src/gl/); fonts in src/asset/font/.
|
|
63
63
|
function checkFileHomes(report) {
|
|
64
|
-
|
|
64
|
+
// src/ is a web root when it holds pages; a library that keeps its modules in src/ (c10g) is not
|
|
65
|
+
// bound to the site layout
|
|
66
|
+
if (!existsSync('src') || globSync('src/**/*.html').length === 0) {
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
69
|
for (const file of globSync('src/**/*.{css,js,woff,woff2,ttf,otf}').map(toPosix).sort()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c3b-lint",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Lints a co:lab project against the rules a tool can check: ESLint, Stylelint, the 500-line limit and the shared .editorconfig; --init writes the config files.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"type": "module",
|