c3b-lint 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/c3b-lint.js +14 -1
  2. package/package.json +1 -1
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
- const configFor = (file) => (existsSync(resolve(file)) ? resolve(file) : join(CONFIG_DIR, file));
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c3b-lint",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
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",