c3b-lint 0.0.10 → 0.0.11

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
@@ -5,7 +5,8 @@ markdown that a tool can check, with one command and one config to install. It r
5
5
 
6
6
  1. **ESLint** on every `.js` file — classic browser scripts under `src/` (IIFE required, no top-level declarations,
7
7
  no `console.log`), ES modules everywhere else — with `eslint:recommended` plus the rules from `frontend.md`:
8
- braces on every `if`, `const`/`let` never `var`, `===`, a blank line before `return`, 500 lines max.
8
+ braces on every `if`, `const`/`let` never `var`, `===`, a blank line before `return`, 500 lines max, and a
9
+ `replace()`/`replaceAll()` whose replacement comes from data must pass a function (a string one expands `$&`).
9
10
  2. **Stylelint** on `src/**/*.css` with `stylelint-config-recommended` plus the rules from `frontend.md`: no
10
11
  `!important`, max 3 compound selectors, kebab-case ids/classes with `is-*` states and `--` variants, `:root` only
11
12
  in `tokens.css` (and `reset.css`), token names `--{category}-{role}`, `rem` font sizes, `em` letter-spacing,
@@ -46,6 +46,16 @@ const shared = {
46
46
  'eol-last': 'error'
47
47
  };
48
48
 
49
+ // node-cli.md: a replacement that comes from data (a name, a URL, a hash) goes in as a function — a
50
+ // string replacement expands `$&`, `$'` and `$1`, so a value with a `$` in it rewrites the output.
51
+ // A literal second argument is fine; anything else (an identifier, a template with expressions, a
52
+ // call) must be wrapped: `text.replace(re, () => value)`.
53
+ const dataReplacement = {
54
+ selector: 'CallExpression[callee.property.name=/^replace(All)?$/][arguments.length=2]'
55
+ + ':not([arguments.1.type=/^(ArrowFunctionExpression|FunctionExpression|Literal)$/])',
56
+ message: 'A replacement from data expands $& and $1: pass a function, text.replace(re, () => value).'
57
+ };
58
+
49
59
  export const browser = {
50
60
  files: ['src/**/*.js'],
51
61
  languageOptions: {
@@ -60,6 +70,7 @@ export const browser = {
60
70
  'no-console': ['error', { allow: ['warn', 'error'] }],
61
71
  'no-restricted-syntax': [
62
72
  'error',
73
+ dataReplacement,
63
74
  {
64
75
  selector: 'Program > VariableDeclaration',
65
76
  message: 'Classic scripts share one global scope: wrap the file in an IIFE and attach its API to window.App.'
@@ -94,7 +105,8 @@ export const node = {
94
105
  },
95
106
  rules: {
96
107
  ...js.configs.recommended.rules,
97
- ...shared
108
+ ...shared,
109
+ 'no-restricted-syntax': ['error', dataReplacement]
98
110
  }
99
111
  };
100
112
 
@@ -108,7 +120,7 @@ export const librarySrc = {
108
120
  rules: {
109
121
  ...node.rules,
110
122
  'no-console': 'off',
111
- 'no-restricted-syntax': 'off',
123
+ 'no-restricted-syntax': ['error', dataReplacement],
112
124
  'no-restricted-properties': 'off',
113
125
  'no-restricted-globals': 'off'
114
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c3b-lint",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
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",
@@ -27,12 +27,12 @@
27
27
  "deploy": "npm run test && npm publish"
28
28
  },
29
29
  "dependencies": {
30
- "@eslint/js": "9",
31
- "eslint": "9",
32
- "globals": "16",
33
- "parse5": "7",
34
- "postcss": "8",
35
- "stylelint": "16",
36
- "stylelint-config-recommended": "17"
30
+ "@eslint/js": "9.39.5",
31
+ "eslint": "9.39.5",
32
+ "globals": "16.5.0",
33
+ "parse5": "7.3.0",
34
+ "postcss": "8.5.29",
35
+ "stylelint": "16.26.1",
36
+ "stylelint-config-recommended": "17.0.0"
37
37
  }
38
38
  }