c3b-lint 0.0.3 → 0.0.5

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 CHANGED
@@ -20,15 +20,19 @@ 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), CSS
24
- only in `src/style/` + `style/page/` + `style/animation/`, JS only in `src/script/`, fonts only in
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/`.
29
29
 
30
30
  Formatting itself (indent, quotes, spacing) is not linted: the `.editorconfig` and the IDE own it.
31
31
 
32
+ A Node library that keeps its modules in `src/` (c10g) is not a site: its `eslint.config.js` is
33
+ `export default [...base, librarySrc];` (both from `c3b-lint/config/eslint.config.js`), which lints `src/` with the
34
+ Node rules, and the site-layout checks only apply when `src/` holds pages.
35
+
32
36
  ## Setup
33
37
 
34
38
  ```
@@ -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
- if (!existsSync('src')) {
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()) {
@@ -77,6 +77,22 @@ export const node = {
77
77
  },
78
78
  };
79
79
 
80
+ // For a Node library that keeps its modules in src/ (c10g): the Node rules there instead of the
81
+ // browser ones, which are switched off because ESLint merges every matching object's rules.
82
+ // Usage, in the project's eslint.config.js: `export default [...base, librarySrc];`
83
+ export const librarySrc = {
84
+ ...node,
85
+ files: ['src/**/*.js'],
86
+ ignores: [],
87
+ rules: {
88
+ ...node.rules,
89
+ 'no-console': 'off',
90
+ 'no-restricted-syntax': 'off',
91
+ 'no-restricted-properties': 'off',
92
+ 'no-restricted-globals': 'off',
93
+ },
94
+ };
95
+
80
96
  export default [
81
97
  { ignores: ['node_modules/**', 'dist/**', 'c10g/**', 'src/**/vendor/**', '**/*.min.js'] },
82
98
  browser,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c3b-lint",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
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",