@plumeria/init 21.2.6 → 21.2.7
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 +7 -0
- package/dist/cli.js +4 -0
- package/dist/prompt.js +3 -0
- package/dist/setup.d.ts +2 -0
- package/dist/setup.js +11 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,12 @@ two cannot disagree. It has to be an identifier TypeScript can declare, and a
|
|
|
48
48
|
name React leaves free; `className`, `style`, `key`, `ref` and `children` are
|
|
49
49
|
refused, from the prompt and from `--style-prop` alike.
|
|
50
50
|
|
|
51
|
+
**Apply styles in .jsx/.tsx only through `classStyle`?** — yes by default, which
|
|
52
|
+
adds `@plumeria/no-use-in-jsx` to the lint config, so `css.use()` is reported in
|
|
53
|
+
`.jsx` and `.tsx` files and the styling prop is the one way to apply styles
|
|
54
|
+
there. Answer no, or pass `--allow-use`, when the project styles a third-party
|
|
55
|
+
component that takes a class name only through `css.use()`.
|
|
56
|
+
|
|
51
57
|
**Set up `@plumeria/eslint-plugin` for ESLint?** — adds the plugin and writes or
|
|
52
58
|
extends the flat config, so a style error is reported while you type. The build
|
|
53
59
|
lints either way: the bundler plugin runs the same rules alongside the build and
|
|
@@ -90,6 +96,7 @@ npx @plumeria/init --dry-run # show the plan, write nothing
|
|
|
90
96
|
npx @plumeria/init --yes # take every default, ask nothing
|
|
91
97
|
npx @plumeria/init --physical --sizes # answer the spelling question up front
|
|
92
98
|
npx @plumeria/init --style-prop sx
|
|
99
|
+
npx @plumeria/init --allow-use # keep css.use() in .jsx/.tsx files
|
|
93
100
|
npx @plumeria/init --bundler rollup
|
|
94
101
|
npx @plumeria/init --no-eslint # leave ESLint out
|
|
95
102
|
npx @plumeria/init --no-install # write the configs, print the command
|
package/dist/cli.js
CHANGED
|
@@ -29,6 +29,7 @@ Options
|
|
|
29
29
|
--logical this project writes logical properties
|
|
30
30
|
--physical this project writes physical properties
|
|
31
31
|
--sizes extend the spelling policy to the size axis
|
|
32
|
+
--allow-use keep css.use() in .jsx/.tsx files
|
|
32
33
|
--no-eslint leave ESLint out
|
|
33
34
|
--no-install write the configs, print the install command
|
|
34
35
|
--cwd <dir> run against another directory
|
|
@@ -75,6 +76,9 @@ function parseArgs(argv) {
|
|
|
75
76
|
case '--sizes':
|
|
76
77
|
options.preset.sizes = true;
|
|
77
78
|
break;
|
|
79
|
+
case '--allow-use':
|
|
80
|
+
options.preset.stylePropOnly = false;
|
|
81
|
+
break;
|
|
78
82
|
case '--no-eslint':
|
|
79
83
|
options.preset.eslint = false;
|
|
80
84
|
break;
|
package/dist/prompt.js
CHANGED
|
@@ -73,6 +73,9 @@ const ask = async (asker, preset) => {
|
|
|
73
73
|
answers.styleProp = (0, setup_1.assertStyleProp)(answer);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
if (preset.stylePropOnly === undefined) {
|
|
77
|
+
answers.stylePropOnly = await confirm(asker, `Apply styles in .jsx/.tsx only through ${answers.styleProp}?`, true);
|
|
78
|
+
}
|
|
76
79
|
if (preset.eslint === undefined) {
|
|
77
80
|
answers.eslint = await confirm(asker, 'Set up @plumeria/eslint-plugin for ESLint?', true);
|
|
78
81
|
}
|
package/dist/setup.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface Answers {
|
|
|
4
4
|
spelling: Spelling;
|
|
5
5
|
sizes: boolean;
|
|
6
6
|
styleProp: string;
|
|
7
|
+
stylePropOnly: boolean;
|
|
7
8
|
eslint: boolean;
|
|
8
9
|
install: boolean;
|
|
9
10
|
}
|
|
@@ -43,6 +44,7 @@ export declare const DEFAULT_ANSWERS: Answers;
|
|
|
43
44
|
export declare const rejectedSpelling: (spelling: Spelling) => "logical" | "physical" | undefined;
|
|
44
45
|
export declare const compilerOption: (answers: Answers) => string | undefined;
|
|
45
46
|
export declare const spellingRule: (answers: Answers) => string | undefined;
|
|
47
|
+
export declare const lintRules: (answers: Answers) => string[];
|
|
46
48
|
export declare const pluginOptions: (answers: Answers) => string;
|
|
47
49
|
export declare const pluginCall: (bundler: Bundler, answers: Answers, local?: string) => string;
|
|
48
50
|
export declare const declarationSource: (answers: Answers) => string;
|
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.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;
|
|
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.lintRules = 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");
|
|
@@ -23,6 +23,7 @@ exports.DEFAULT_ANSWERS = {
|
|
|
23
23
|
spelling: 'none',
|
|
24
24
|
sizes: false,
|
|
25
25
|
styleProp: exports.DEFAULT_STYLE_PROP,
|
|
26
|
+
stylePropOnly: true,
|
|
26
27
|
eslint: true,
|
|
27
28
|
install: true,
|
|
28
29
|
};
|
|
@@ -70,6 +71,11 @@ const spellingRule = (answers) => {
|
|
|
70
71
|
: `${name}: 'error'`;
|
|
71
72
|
};
|
|
72
73
|
exports.spellingRule = spellingRule;
|
|
74
|
+
const lintRules = (answers) => [
|
|
75
|
+
(0, exports.spellingRule)(answers),
|
|
76
|
+
answers.stylePropOnly ? `'@plumeria/no-use-in-jsx': 'error'` : undefined,
|
|
77
|
+
].filter((rule) => rule !== undefined);
|
|
78
|
+
exports.lintRules = lintRules;
|
|
73
79
|
const pluginOptions = (answers) => {
|
|
74
80
|
const entries = [];
|
|
75
81
|
if (answers.styleProp !== exports.DEFAULT_STYLE_PROP) {
|
|
@@ -152,7 +158,7 @@ const settingsLines = (answers) => answers.styleProp === exports.DEFAULT_STYLE_P
|
|
|
152
158
|
`},`,
|
|
153
159
|
];
|
|
154
160
|
const eslintSource = (answers, typescript) => {
|
|
155
|
-
const rules =
|
|
161
|
+
const rules = (0, exports.lintRules)(answers);
|
|
156
162
|
const block = [
|
|
157
163
|
` {`,
|
|
158
164
|
` files: ['**/*.{${typescript ? 'ts,tsx' : 'js,jsx'}}'],`,
|
|
@@ -186,7 +192,7 @@ ${block.join('\n')}
|
|
|
186
192
|
};
|
|
187
193
|
exports.eslintSource = eslintSource;
|
|
188
194
|
const eslintEntries = (answers, typescript) => {
|
|
189
|
-
const rules =
|
|
195
|
+
const rules = (0, exports.lintRules)(answers);
|
|
190
196
|
const settings = settingsLines(answers);
|
|
191
197
|
const entries = ['plumeria.configs.recommended'];
|
|
192
198
|
if (rules.length > 0 || settings.length > 0) {
|
|
@@ -436,6 +442,8 @@ const oxlintEntries = (answers) => {
|
|
|
436
442
|
? ['error', { sizes: true }]
|
|
437
443
|
: 'error';
|
|
438
444
|
}
|
|
445
|
+
if (answers.stylePropOnly)
|
|
446
|
+
rules['@plumeria/no-use-in-jsx'] = 'error';
|
|
439
447
|
const entries = { jsPlugins: [exports.OXLINT_PLUGIN], rules };
|
|
440
448
|
if (answers.styleProp !== exports.DEFAULT_STYLE_PROP) {
|
|
441
449
|
entries.settings = { plumeria: { styleProp: answers.styleProp } };
|
package/package.json
CHANGED