@adbayb/stack 2.40.0-next-314d883 โ 2.40.0-next-4c238fc
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/configs/oxlint/index.ts +95 -25
- package/dist/index.js +84 -48
- package/package.json +1 -1
package/configs/oxlint/index.ts
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
import { defineConfig } from "oxlint";
|
|
2
2
|
|
|
3
|
+
const JAVASCRIPT_EXTENSIONS = ["js", "jsx", "cjs", "mjs", "mjsx"];
|
|
4
|
+
const TYPESCRIPT_EXTENSIONS = ["ts", "tsx", "cts", "mts", "mtsx"];
|
|
5
|
+
const JAVASCRIPT_LIKE_EXTENSIONS = [...JAVASCRIPT_EXTENSIONS, ...TYPESCRIPT_EXTENSIONS];
|
|
6
|
+
const JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING = JAVASCRIPT_LIKE_EXTENSIONS.join(",");
|
|
7
|
+
|
|
8
|
+
const TEST_LIKE_FILES = [
|
|
9
|
+
`**/{test,test-d}.{${JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING}}`,
|
|
10
|
+
`**/*.{test,test-d}.{${JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING}}`,
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const RELAXED_LIKE_FILES = [
|
|
14
|
+
...TEST_LIKE_FILES,
|
|
15
|
+
"**/.config/**",
|
|
16
|
+
"**/.configs/**",
|
|
17
|
+
"**/config/**",
|
|
18
|
+
"**/configs/**",
|
|
19
|
+
"**/examples/**",
|
|
20
|
+
"**/scripts/**",
|
|
21
|
+
"**/tools/**",
|
|
22
|
+
`**/config.{${JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING}}`,
|
|
23
|
+
`**/configs.{${JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING}}`,
|
|
24
|
+
`**/*.config.{${JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING}}`,
|
|
25
|
+
`**/*.configs.{${JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING}}`,
|
|
26
|
+
`**/stories.{${JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING}}`,
|
|
27
|
+
`**/*.stories.{${JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING}}`,
|
|
28
|
+
];
|
|
29
|
+
|
|
3
30
|
export default defineConfig({
|
|
31
|
+
categories: {
|
|
32
|
+
correctness: "error",
|
|
33
|
+
nursery: "error",
|
|
34
|
+
pedantic: "error",
|
|
35
|
+
perf: "error",
|
|
36
|
+
restriction: "error",
|
|
37
|
+
style: "error",
|
|
38
|
+
suspicious: "error",
|
|
39
|
+
},
|
|
40
|
+
options: {
|
|
41
|
+
denyWarnings: true,
|
|
42
|
+
reportUnusedDisableDirectives: "error",
|
|
43
|
+
respectEslintDisableDirectives: false,
|
|
44
|
+
typeAware: true,
|
|
45
|
+
typeCheck: true,
|
|
46
|
+
},
|
|
47
|
+
overrides: [
|
|
48
|
+
{
|
|
49
|
+
files: TEST_LIKE_FILES,
|
|
50
|
+
plugins: ["vitest"],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
files: [
|
|
54
|
+
...RELAXED_LIKE_FILES,
|
|
55
|
+
`*.config(s)?.{${JAVASCRIPT_LIKE_EXTENSIONS_AS_STRING}}`,
|
|
56
|
+
],
|
|
57
|
+
rules: {
|
|
58
|
+
"import/no-anonymous-default-export": "off",
|
|
59
|
+
"import/no-default-export": "off",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
// TODO: add jsPlugins for perfectionist and padding-line-between-statements + add React rules (such as set-state-in-effect) from React X https://github.com/oxc-project/oxc/issues/1022 + potentially https://github.com/es-tooling/eslint-plugin-depend/blob/main/docs/rules/ban-dependencies.md
|
|
4
64
|
plugins: [
|
|
5
65
|
"eslint",
|
|
6
66
|
"import",
|
|
@@ -13,39 +73,49 @@ export default defineConfig({
|
|
|
13
73
|
"react-perf",
|
|
14
74
|
"typescript",
|
|
15
75
|
"unicorn",
|
|
16
|
-
"vitest",
|
|
17
76
|
],
|
|
18
|
-
// TODO: add jsPlugins for perfectionist and padding-line-between-statements + add React rules (such as set-state-in-effect) from React X https://github.com/oxc-project/oxc/issues/1022
|
|
19
|
-
categories: {
|
|
20
|
-
correctness: "error",
|
|
21
|
-
pedantic: "error",
|
|
22
|
-
perf: "error",
|
|
23
|
-
suspicious: "error",
|
|
24
|
-
nursery: "error",
|
|
25
|
-
},
|
|
26
77
|
rules: {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"max-classes-per-file": "off",
|
|
78
|
+
"array-callback-return": ["error", { allowImplicit: true }],
|
|
79
|
+
"arrow-body-style": ["error", "always"],
|
|
80
|
+
"id-length": "off",
|
|
81
|
+
"import/exports-last": "off",
|
|
82
|
+
"import/group-exports": "off",
|
|
33
83
|
"import/max-dependencies": "off",
|
|
34
|
-
"
|
|
84
|
+
"import/no-dynamic-require": "off",
|
|
85
|
+
"import/no-named-export": "off",
|
|
86
|
+
"import/no-nodejs-modules": "off",
|
|
87
|
+
"import/no-relative-parent-imports": "off",
|
|
88
|
+
"import/prefer-default-export": "off",
|
|
35
89
|
"jsdoc/require-param-type": "off",
|
|
36
90
|
"jsdoc/require-property-type": "off",
|
|
37
91
|
"jsdoc/require-returns-type": "off",
|
|
92
|
+
"max-classes-per-file": "off",
|
|
93
|
+
"max-lines": "off",
|
|
94
|
+
"max-lines-per-function": "off",
|
|
95
|
+
"max-statements": "off",
|
|
96
|
+
"no-async-await": "off",
|
|
97
|
+
"no-continue": "off",
|
|
98
|
+
"no-magic-numbers": "off",
|
|
99
|
+
"no-optional-chaining": "off",
|
|
100
|
+
"no-rest-spread-properties": "off",
|
|
101
|
+
"no-ternary": "off",
|
|
102
|
+
"no-undef": "off",
|
|
103
|
+
"no-undefined": "off",
|
|
104
|
+
"no-use-before-define": "off",
|
|
105
|
+
"no-void": "off",
|
|
38
106
|
"no-warning-comments": "off",
|
|
39
|
-
"
|
|
107
|
+
"node/no-sync": "off",
|
|
108
|
+
"prefer-named-capture-group": "off",
|
|
109
|
+
"prefer-readonly-parameter-types": "off",
|
|
110
|
+
"react/jsx-max-depth": "off",
|
|
111
|
+
"sort-imports": ["error", { ignoreDeclarationSort: true }],
|
|
112
|
+
"strict-boolean-expressions": "off",
|
|
40
113
|
"typescript/consistent-return": "off",
|
|
114
|
+
"typescript/consistent-type-definitions": ["error", "type"],
|
|
115
|
+
"typescript/explicit-function-return-type": "off",
|
|
116
|
+
"typescript/explicit-module-boundary-types": "off",
|
|
41
117
|
"typescript/no-unsafe-type-assertion": "off",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
options: {
|
|
45
|
-
denyWarnings: true,
|
|
46
|
-
reportUnusedDisableDirectives: "error",
|
|
47
|
-
respectEslintDisableDirectives: false,
|
|
48
|
-
typeAware: true,
|
|
49
|
-
typeCheck: true,
|
|
118
|
+
"unicorn/filename-case": "off",
|
|
119
|
+
"unicorn/import-style": "off",
|
|
50
120
|
},
|
|
51
121
|
});
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ import { chmod, cp, mkdir, readFile, readdir, rename, rm, symlink, writeFile } f
|
|
|
6
6
|
|
|
7
7
|
//#region src/helpers.ts
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
|
-
|
|
9
|
+
const assert = (expectedCondition, createError) => {
|
|
10
10
|
if (!expectedCondition) throw createError();
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
12
|
/**
|
|
13
13
|
* Helper to format log messages with a welcoming bot.
|
|
14
14
|
*
|
|
@@ -103,31 +103,35 @@ async function getRequest(url, responseType) {
|
|
|
103
103
|
return response.json();
|
|
104
104
|
}
|
|
105
105
|
const request = { get: getRequest };
|
|
106
|
-
const oxlint = (options) =>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
106
|
+
const oxlint = (options) => {
|
|
107
|
+
return async (files = []) => {
|
|
108
|
+
const args = [
|
|
109
|
+
...files,
|
|
110
|
+
"--disable-nested-config",
|
|
111
|
+
"--no-error-on-unmatched-pattern"
|
|
112
|
+
];
|
|
113
|
+
if (options.isFixMode) args.push("--fix");
|
|
114
|
+
try {
|
|
115
|
+
return await helpers.exec(`oxlint ${args.join(" ")}`);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
throw createError("oxlint", error instanceof Error ? error : new Error(String(error)));
|
|
118
|
+
}
|
|
119
|
+
};
|
|
118
120
|
};
|
|
119
|
-
const oxfmt = (options) =>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
const oxfmt = (options) => {
|
|
122
|
+
return async (files = []) => {
|
|
123
|
+
const args = [
|
|
124
|
+
...files,
|
|
125
|
+
"--disable-nested-config",
|
|
126
|
+
"--no-error-on-unmatched-pattern",
|
|
127
|
+
options.isFixMode ? "--write" : "--check"
|
|
128
|
+
];
|
|
129
|
+
try {
|
|
130
|
+
return await helpers.exec(`oxfmt ${args.join(" ")}`);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
throw createError("oxfmt", error instanceof Error ? error : new Error(String(error)));
|
|
133
|
+
}
|
|
134
|
+
};
|
|
131
135
|
};
|
|
132
136
|
const turbo = async (command, options = {}) => {
|
|
133
137
|
try {
|
|
@@ -199,7 +203,9 @@ const checkDependency = async () => {
|
|
|
199
203
|
const checkDependencyVersionMismatch = createPackagesVersionMismatchChecker();
|
|
200
204
|
const packages = JSON.parse(stdout).map((pkg) => {
|
|
201
205
|
const packagePath = join(pkg.path, "package.json");
|
|
202
|
-
assert(pkg.name, () =>
|
|
206
|
+
assert(pkg.name, () => {
|
|
207
|
+
return createPackageError(`\`${packagePath}\` must have a name field.`);
|
|
208
|
+
});
|
|
203
209
|
const packageContent = require(packagePath);
|
|
204
210
|
const peerDependencies = packageContent.peerDependencies ?? {};
|
|
205
211
|
const devDependencies = packageContent.devDependencies ?? {};
|
|
@@ -276,17 +282,21 @@ const createPackagesVersionMismatchChecker = () => {
|
|
|
276
282
|
const createPackageError = (message, context) => {
|
|
277
283
|
return createError("stack check", context ? `\`${context.name}\` consumed by \`${context.consumedBy}\` doesn't conform to package guidelines.\n${message}` : message);
|
|
278
284
|
};
|
|
279
|
-
|
|
280
|
-
assert(version, () =>
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
+
const assertVersion = (version, { consumedBy, name }) => {
|
|
286
|
+
assert(version, () => {
|
|
287
|
+
return createPackageError(`\`${name}\` must have a valid version specified (current version equals to \`${String(version)}\`).`, {
|
|
288
|
+
consumedBy,
|
|
289
|
+
name
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
};
|
|
285
293
|
const isExcluded = (version) => {
|
|
286
294
|
const isPreReleaseVersion = /\d+\.\d+\.\d+-(alpha|beta|experimental|next|rc).*/u.exec(version);
|
|
287
295
|
return version.startsWith("npm:") || isPreReleaseVersion;
|
|
288
296
|
};
|
|
289
|
-
const hasCaret = (version) =>
|
|
297
|
+
const hasCaret = (version) => {
|
|
298
|
+
return version.startsWith("^");
|
|
299
|
+
};
|
|
290
300
|
|
|
291
301
|
//#endregion
|
|
292
302
|
//#region src/commands/check/checkFormatting.ts
|
|
@@ -355,9 +365,13 @@ const createCheckCommand = (program) => {
|
|
|
355
365
|
}
|
|
356
366
|
});
|
|
357
367
|
};
|
|
358
|
-
const label$4 = (message) =>
|
|
359
|
-
|
|
360
|
-
|
|
368
|
+
const label$4 = (message) => {
|
|
369
|
+
return `${message} ๐ง`;
|
|
370
|
+
};
|
|
371
|
+
const ifFilterDefinedAndNotEqualTo = (filter) => {
|
|
372
|
+
return (context) => {
|
|
373
|
+
return context.filter !== void 0 && context.filter !== filter;
|
|
374
|
+
};
|
|
361
375
|
};
|
|
362
376
|
|
|
363
377
|
//#endregion
|
|
@@ -399,7 +413,9 @@ const createCleanCommand = (program) => {
|
|
|
399
413
|
}
|
|
400
414
|
});
|
|
401
415
|
};
|
|
402
|
-
const label$3 = (message) =>
|
|
416
|
+
const label$3 = (message) => {
|
|
417
|
+
return `${message} ๐งน`;
|
|
418
|
+
};
|
|
403
419
|
const cleanFiles = async (files) => {
|
|
404
420
|
await Promise.all(files.map(async (file) => {
|
|
405
421
|
await rm(file, {
|
|
@@ -412,13 +428,19 @@ const isDirectoryExistAndNotEmpty = (path) => {
|
|
|
412
428
|
return existsSync(path) && readdirSync(path).length > 0;
|
|
413
429
|
};
|
|
414
430
|
const retrieveIgnoredFiles = async () => {
|
|
415
|
-
return (await helpers.exec("git clean -fdXn")).split(/\n|\r\n/u).filter((cleanOutput) =>
|
|
431
|
+
return (await helpers.exec("git clean -fdXn")).split(/\n|\r\n/u).filter((cleanOutput) => {
|
|
432
|
+
return PRESERVE_FILES.every((excludedFile) => {
|
|
433
|
+
return !cleanOutput.includes(excludedFile);
|
|
434
|
+
});
|
|
435
|
+
}).map((cleanOutput) => {
|
|
436
|
+
return cleanOutput.split(" ").at(-1) ?? "";
|
|
437
|
+
}).filter(Boolean);
|
|
416
438
|
};
|
|
417
439
|
const PRESERVE_FILES = ["node_modules"];
|
|
418
440
|
|
|
419
441
|
//#endregion
|
|
420
442
|
//#region package.json
|
|
421
|
-
var version = "2.40.0-next-
|
|
443
|
+
var version = "2.40.0-next-4c238fc";
|
|
422
444
|
|
|
423
445
|
//#endregion
|
|
424
446
|
//#region src/commands/create.ts
|
|
@@ -568,7 +590,9 @@ const createCreateCommand = (program) => {
|
|
|
568
590
|
});
|
|
569
591
|
} });
|
|
570
592
|
};
|
|
571
|
-
const label$2 = (message) =>
|
|
593
|
+
const label$2 = (message) => {
|
|
594
|
+
return `${message} ๐จ`;
|
|
595
|
+
};
|
|
572
596
|
const slugify = (input) => {
|
|
573
597
|
return input.toLowerCase().replaceAll(/[^a-z0-9\s-]/gu, "").trim().replaceAll(/\s+/gu, "-").replaceAll(/-+/gu, "-");
|
|
574
598
|
};
|
|
@@ -589,7 +613,9 @@ const createTemplateEngine = async (workingPath, { projectName, templateModel, t
|
|
|
589
613
|
process.chdir(workingPath);
|
|
590
614
|
return {
|
|
591
615
|
async processContents() {
|
|
592
|
-
await Promise.all(templateEntries.filter(({ type }) =>
|
|
616
|
+
await Promise.all(templateEntries.filter(({ type }) => {
|
|
617
|
+
return type === "content";
|
|
618
|
+
}).map(async (entry) => {
|
|
593
619
|
await writeFile(entry.path, setTemplateVariables(entry, templateModel));
|
|
594
620
|
}));
|
|
595
621
|
},
|
|
@@ -597,7 +623,9 @@ const createTemplateEngine = async (workingPath, { projectName, templateModel, t
|
|
|
597
623
|
const sortedDirectoryEntries = templateEntries.filter(({ content, type }) => {
|
|
598
624
|
if (type === "path.directory" || type === "path.file") return hasTemplateVariable(basename(content));
|
|
599
625
|
return false;
|
|
600
|
-
}).toSorted(({ path: pathA }, { path: pathB }) =>
|
|
626
|
+
}).toSorted(({ path: pathA }, { path: pathB }) => {
|
|
627
|
+
return pathB.length - pathA.length;
|
|
628
|
+
});
|
|
601
629
|
for (const entry of sortedDirectoryEntries) {
|
|
602
630
|
const newPath = setTemplateVariables(entry, templateModel);
|
|
603
631
|
await rename(entry.path, newPath);
|
|
@@ -631,7 +659,9 @@ const getTemplateEntries = async (path) => {
|
|
|
631
659
|
path: entryPath,
|
|
632
660
|
type
|
|
633
661
|
};
|
|
634
|
-
}).filter((input) =>
|
|
662
|
+
}).filter((input) => {
|
|
663
|
+
return Boolean(input);
|
|
664
|
+
});
|
|
635
665
|
}))).flat();
|
|
636
666
|
};
|
|
637
667
|
const setTemplateVariables = (entry, model) => {
|
|
@@ -687,7 +717,9 @@ const createFixCommand = (program) => {
|
|
|
687
717
|
label: label$1("Fix code issues")
|
|
688
718
|
});
|
|
689
719
|
};
|
|
690
|
-
const label$1 = (message) =>
|
|
720
|
+
const label$1 = (message) => {
|
|
721
|
+
return `${message} ๐`;
|
|
722
|
+
};
|
|
691
723
|
|
|
692
724
|
//#endregion
|
|
693
725
|
//#region src/commands/install.ts
|
|
@@ -707,7 +739,9 @@ const createInstallCommand = (program) => {
|
|
|
707
739
|
label: label("Install `git.commit-msg` hook")
|
|
708
740
|
});
|
|
709
741
|
};
|
|
710
|
-
const label = (message) =>
|
|
742
|
+
const label = (message) => {
|
|
743
|
+
return `${message} ๐ฒ`;
|
|
744
|
+
};
|
|
711
745
|
const installGitHook = async (hook, content) => {
|
|
712
746
|
const filename = resolveFromWorkingDirectory(`.git/hooks/${hook}`);
|
|
713
747
|
await writeFile(filename, content);
|
|
@@ -762,8 +796,10 @@ const createReleaseCommand = (program) => {
|
|
|
762
796
|
skip: ifNotEqualTo("publish")
|
|
763
797
|
});
|
|
764
798
|
};
|
|
765
|
-
const ifNotEqualTo = (validOption) =>
|
|
766
|
-
return
|
|
799
|
+
const ifNotEqualTo = (validOption) => {
|
|
800
|
+
return (context) => {
|
|
801
|
+
return !context[validOption];
|
|
802
|
+
};
|
|
767
803
|
};
|
|
768
804
|
|
|
769
805
|
//#endregion
|