c3b-lint 0.0.16 → 0.0.17

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
@@ -74,7 +74,8 @@ A project's own settings go in its `package.json`, under `"c3b-lint"`:
74
74
  "c3b-lint": {
75
75
  "ignore": ["src/experiment/**"],
76
76
  "globals": ["THREE", "gsap", "ScrollTrigger"],
77
- "singularDirectories": ["mannequin-films"]
77
+ "singularDirectories": ["mannequin-films"],
78
+ "ignoreLength": ["src/index.html"]
78
79
  }
79
80
  ```
80
81
 
@@ -83,6 +84,8 @@ A project's own settings go in its `package.json`, under `"c3b-lint"`:
83
84
  - `globals` — the names a page's CDN `<script>` tags define (`THREE`, `gsap`, `Lenis`, …). ESLint lints each file on
84
85
  its own and never reads the HTML, so without them every use is "not defined". Read-only, `src/` scripts only.
85
86
  - `singularDirectories` — plural-looking directory names that are proper names (a client's brand).
87
+ - `ignoreLength` — globs exempt from the 500-line limit and nothing else: the HTML, token, structure, ESLint and
88
+ Stylelint checks still run on them. For a file that can't be split, like a desktop app's one renderer page.
86
89
 
87
90
  The ESLint and Stylelint configs read these too, so WebStorm reports what the CLI does.
88
91
 
package/c3b-lint.js CHANGED
@@ -9,7 +9,7 @@ import { checkCssTokens } from './check/css-tokens.js';
9
9
  import { checkHtml } from './check/html.js';
10
10
  import { checkStructure } from './check/structure.js';
11
11
  import { installHook } from './check/hook.js';
12
- import { ignoredPaths } from './config/project-settings.js';
12
+ import { ignoredPaths, readSettings } from './config/project-settings.js';
13
13
 
14
14
  // Printed first so it's obvious which installed version is running.
15
15
  const HERE = dirname(fileURLToPath(import.meta.url));
@@ -128,7 +128,8 @@ function checkEditorconfig(report) {
128
128
  // general.md: no hand-written file past 500 lines. ESLint reports JS; this covers CSS and HTML.
129
129
  function checkFileLengths(report) {
130
130
  const ignored = ignoredPaths();
131
- const files = globSync('src/**/*.{css,html}').map(toPosix).filter((file) => !file.includes('/vendor/') && !ignored.has(file));
131
+ const exempt = ignoredPaths(readSettings().ignoreLength);
132
+ const files = globSync('src/**/*.{css,html}').map(toPosix).filter((file) => !file.includes('/vendor/') && !ignored.has(file) && !exempt.has(file));
132
133
  for (const file of files.sort()) {
133
134
  // inline <svg> is vector art, not hand-written markup: its lines are not counted
134
135
  const content = readFileSync(file, 'utf8').replace(/<svg[\s\S]*?<\/svg>/g, '<svg/>');
@@ -130,8 +130,12 @@ export const librarySrc = {
130
130
  }
131
131
  };
132
132
 
133
+ // the "ignoreLength" files: everything but max-lines still applies (ESLint refuses an empty files list)
134
+ const lengthExempt = settings.ignoreLength.length ? [{ files: settings.ignoreLength, rules: { 'max-lines': 'off' } }] : [];
135
+
133
136
  export default [
134
137
  { ignores: ['node_modules/**', 'dist/**', 'c10g/**', 'src/**/vendor/**', '**/*.min.js', ...settings.ignore] },
135
138
  browser,
136
- node
139
+ node,
140
+ ...lengthExempt
137
141
  ];
@@ -7,7 +7,8 @@ import { resolve, sep } from 'path';
7
7
  // "c3b-lint": {
8
8
  // "ignore": ["src/experiment/**"], globs no check looks at: ESLint, Stylelint and c3b-lint's own
9
9
  // "globals": ["THREE", "gsap"], names the pages' CDN <script> tags define, read-only in src/ scripts
10
- // "singularDirectories": ["mannequin-films"] plural-looking directory names that are proper names
10
+ // "singularDirectories": ["mannequin-films"], plural-looking directory names that are proper names
11
+ // "ignoreLength": ["src/index.html"] globs exempt from the 500-line limit only; every other check still runs
11
12
  // }
12
13
  //
13
14
  // The ESLint and Stylelint configs read it too, so the editor reports what the CLI does.
@@ -22,17 +23,17 @@ export function readSettings() {
22
23
  return {
23
24
  ignore: settings.ignore ?? [],
24
25
  globals: settings.globals ?? [],
25
- singularDirectories: settings.singularDirectories ?? []
26
+ singularDirectories: settings.singularDirectories ?? [],
27
+ ignoreLength: settings.ignoreLength ?? []
26
28
  };
27
29
  }
28
30
 
29
- // Every file and directory the "ignore" globs match, as posix paths from the project root, for the checks
30
- // c3b-lint runs itself (ESLint and Stylelint are handed the globs directly)
31
- export function ignoredPaths() {
32
- const { ignore } = readSettings();
33
- if (ignore.length === 0) {
31
+ // Every file and directory the "ignore" globs (or the globs given) match, as posix paths from the project
32
+ // root, for the checks c3b-lint runs itself (ESLint and Stylelint are handed the globs directly)
33
+ export function ignoredPaths(globs = readSettings().ignore) {
34
+ if (globs.length === 0) {
34
35
  return new Set();
35
36
  }
36
37
 
37
- return new Set(globSync(ignore).map((path) => path.split(sep).join('/')));
38
+ return new Set(globSync(globs).map((path) => path.split(sep).join('/')));
38
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c3b-lint",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
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",