@plumeria/init 19.14.0 → 19.14.1
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/dist/detect.d.ts +1 -0
- package/dist/detect.js +1 -0
- package/dist/setup.d.ts +8 -0
- package/dist/setup.js +99 -3
- package/package.json +1 -1
package/dist/detect.d.ts
CHANGED
package/dist/detect.js
CHANGED
|
@@ -181,6 +181,7 @@ const detect = (root, override) => {
|
|
|
181
181
|
bundler,
|
|
182
182
|
bundlerConfig: firstExisting(root, CONFIG_NAMES[bundler]),
|
|
183
183
|
eslintConfig: firstExisting(root, ESLINT_NAMES),
|
|
184
|
+
oxlintConfig: firstExisting(root, ['.oxlintrc.json']),
|
|
184
185
|
declaration,
|
|
185
186
|
typescript,
|
|
186
187
|
esm: manifest.type === 'module',
|
package/dist/setup.d.ts
CHANGED
|
@@ -53,5 +53,13 @@ export declare const packages: (detected: Detected, answers: Answers) => string[
|
|
|
53
53
|
export declare const installCommand: (manager: PackageManager, names: readonly string[]) => string;
|
|
54
54
|
export declare const buildScript: (existing: string, styleProp: string) => string;
|
|
55
55
|
export declare const plan: (detected: Detected, answers: Answers) => Action[];
|
|
56
|
+
export declare const OXLINT_PLUGIN: {
|
|
57
|
+
name: string;
|
|
58
|
+
specifier: string;
|
|
59
|
+
};
|
|
60
|
+
export declare const OXLINT_RECOMMENDED: Record<string, 'error' | 'warn'>;
|
|
61
|
+
type JsonObject = Record<string, unknown>;
|
|
62
|
+
export declare const oxlintEntries: (answers: Answers) => JsonObject;
|
|
56
63
|
export declare const CLEAN_SCRIPT = "rimraf .next";
|
|
57
64
|
export declare const cleanScripts: (scripts: Record<string, string>) => Record<string, string>;
|
|
65
|
+
export {};
|
package/dist/setup.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.cleanScripts = exports.CLEAN_SCRIPT = exports.plan = exports.buildScript = exports.installCommand = exports.packages = exports.eslintEntries = exports.eslintSource = exports.bundlerSource = exports.declarationSource = exports.pluginCall = exports.pluginOptions = exports.spellingRule = exports.compilerOption = exports.rejectedSpelling = exports.DEFAULT_ANSWERS = exports.assertStyleProp = exports.DEFAULT_STYLE_PROP = void 0;
|
|
6
|
+
exports.cleanScripts = exports.CLEAN_SCRIPT = exports.oxlintEntries = exports.OXLINT_RECOMMENDED = exports.OXLINT_PLUGIN = exports.plan = exports.buildScript = exports.installCommand = exports.packages = exports.eslintEntries = exports.eslintSource = exports.bundlerSource = exports.declarationSource = exports.pluginCall = exports.pluginOptions = exports.spellingRule = exports.compilerOption = exports.rejectedSpelling = exports.DEFAULT_ANSWERS = exports.assertStyleProp = exports.DEFAULT_STYLE_PROP = void 0;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const detect_1 = require("./detect");
|
|
@@ -216,7 +216,7 @@ const packages = (detected, answers) => {
|
|
|
216
216
|
];
|
|
217
217
|
if (answers.eslint) {
|
|
218
218
|
wanted.push('@plumeria/eslint-plugin');
|
|
219
|
-
if (!detected.eslintConfig) {
|
|
219
|
+
if (!detected.eslintConfig && !detected.oxlintConfig) {
|
|
220
220
|
wanted.push('eslint', '@eslint/js');
|
|
221
221
|
if (detected.typescript)
|
|
222
222
|
wanted.push('typescript-eslint');
|
|
@@ -397,9 +397,105 @@ const snippetFor = (bundler, call) => {
|
|
|
397
397
|
}
|
|
398
398
|
return `${imported}\n\nplugins: [${call}]`;
|
|
399
399
|
};
|
|
400
|
+
exports.OXLINT_PLUGIN = {
|
|
401
|
+
name: '@plumeria',
|
|
402
|
+
specifier: '@plumeria/eslint-plugin/oxlint-plugin',
|
|
403
|
+
};
|
|
404
|
+
exports.OXLINT_RECOMMENDED = {
|
|
405
|
+
'@plumeria/custom-props-require-import': 'error',
|
|
406
|
+
'@plumeria/expand-border-shorthands': 'warn',
|
|
407
|
+
'@plumeria/no-combinator': 'error',
|
|
408
|
+
'@plumeria/no-destructure': 'error',
|
|
409
|
+
'@plumeria/no-inline-object': 'error',
|
|
410
|
+
'@plumeria/no-inner-call': 'error',
|
|
411
|
+
'@plumeria/no-invalid-selector': 'error',
|
|
412
|
+
'@plumeria/no-mixed-styling-props': 'error',
|
|
413
|
+
'@plumeria/no-mutable-binding': 'warn',
|
|
414
|
+
'@plumeria/no-order-dependent-overlap': 'warn',
|
|
415
|
+
'@plumeria/no-style-prop-relay': 'error',
|
|
416
|
+
'@plumeria/no-unknown-css-properties': 'error',
|
|
417
|
+
'@plumeria/no-unused-keys': 'warn',
|
|
418
|
+
'@plumeria/no-unresolved-composition': 'warn',
|
|
419
|
+
'@plumeria/sort-properties': 'warn',
|
|
420
|
+
'@plumeria/format-properties': 'warn',
|
|
421
|
+
'@plumeria/validate-values': 'warn',
|
|
422
|
+
'@plumeria/validate-pseudos': 'warn',
|
|
423
|
+
'@plumeria/validate-at-rules': 'warn',
|
|
424
|
+
};
|
|
425
|
+
const isJsonObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
426
|
+
const oxlintEntries = (answers) => {
|
|
427
|
+
const rules = { ...exports.OXLINT_RECOMMENDED };
|
|
428
|
+
const rejected = (0, exports.rejectedSpelling)(answers.spelling);
|
|
429
|
+
if (rejected) {
|
|
430
|
+
rules[`@plumeria/no-${rejected}-properties`] = answers.sizes
|
|
431
|
+
? ['error', { sizes: true }]
|
|
432
|
+
: 'error';
|
|
433
|
+
}
|
|
434
|
+
const entries = { jsPlugins: [exports.OXLINT_PLUGIN], rules };
|
|
435
|
+
if (answers.styleProp !== exports.DEFAULT_STYLE_PROP) {
|
|
436
|
+
entries.settings = { plumeria: { styleProp: answers.styleProp } };
|
|
437
|
+
}
|
|
438
|
+
return entries;
|
|
439
|
+
};
|
|
440
|
+
exports.oxlintEntries = oxlintEntries;
|
|
441
|
+
const oxlintAction = (detected, answers, file) => {
|
|
442
|
+
const source = read(detected, file);
|
|
443
|
+
if (source.includes(exports.OXLINT_PLUGIN.specifier)) {
|
|
444
|
+
return {
|
|
445
|
+
kind: 'skip',
|
|
446
|
+
label: 'skip',
|
|
447
|
+
note: 'the plugin is already configured',
|
|
448
|
+
file,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
const entries = (0, exports.oxlintEntries)(answers);
|
|
452
|
+
let config;
|
|
453
|
+
try {
|
|
454
|
+
config = JSON.parse(source);
|
|
455
|
+
}
|
|
456
|
+
catch {
|
|
457
|
+
config = undefined;
|
|
458
|
+
}
|
|
459
|
+
if (!isJsonObject(config)) {
|
|
460
|
+
return {
|
|
461
|
+
kind: 'manual',
|
|
462
|
+
label: 'manual',
|
|
463
|
+
note: 'merge into the oxlint config',
|
|
464
|
+
file,
|
|
465
|
+
snippet: JSON.stringify(entries, null, 2),
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
const merged = {
|
|
469
|
+
...config,
|
|
470
|
+
jsPlugins: [
|
|
471
|
+
...(Array.isArray(config.jsPlugins) ? config.jsPlugins : []),
|
|
472
|
+
exports.OXLINT_PLUGIN,
|
|
473
|
+
],
|
|
474
|
+
rules: {
|
|
475
|
+
...(isJsonObject(config.rules) ? config.rules : {}),
|
|
476
|
+
...entries.rules,
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
if (entries.settings) {
|
|
480
|
+
merged.settings = {
|
|
481
|
+
...(isJsonObject(config.settings) ? config.settings : {}),
|
|
482
|
+
...entries.settings,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
kind: 'patch',
|
|
487
|
+
label: 'patch',
|
|
488
|
+
note: 'jsPlugins @plumeria',
|
|
489
|
+
file,
|
|
490
|
+
contents: `${JSON.stringify(merged, null, indentOfJson(source))}\n`,
|
|
491
|
+
};
|
|
492
|
+
};
|
|
400
493
|
const eslintAction = (detected, answers) => {
|
|
401
|
-
const { eslintConfig, typescript } = detected;
|
|
494
|
+
const { eslintConfig, oxlintConfig, typescript } = detected;
|
|
402
495
|
const entries = (0, exports.eslintEntries)(answers, typescript);
|
|
496
|
+
if (!eslintConfig && oxlintConfig) {
|
|
497
|
+
return oxlintAction(detected, answers, oxlintConfig);
|
|
498
|
+
}
|
|
403
499
|
if (!eslintConfig) {
|
|
404
500
|
return {
|
|
405
501
|
kind: 'write',
|
package/package.json
CHANGED