@plumeria/init 21.2.6 → 22.0.0

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
@@ -14,7 +14,7 @@ writes. Nothing is installed or patched before you say so.
14
14
  ✔ detected next pnpm typescript
15
15
 
16
16
  ➡︎ install @plumeria/core @plumeria/next-plugin @plumeria/eslint-plugin rimraf
17
- + write plumeria.d.ts classStyle
17
+ + write plumeria.d.ts sx
18
18
  ~ patch next.config.ts withPlumeria(...)
19
19
  ~ patch eslint.config.ts plumeria.configs.recommended
20
20
  ~ patch package.json predev: rimraf .next, prebuild: rimraf .next
@@ -42,12 +42,18 @@ so the counterpart cannot compile, and ESLint gets
42
42
  is reported while you type. Answering "none" sets neither. `--sizes` extends
43
43
  the answer to the size axis, where `width` and `inlineSize` are the pair.
44
44
 
45
- **Which JSX prop carries styles?** — `classStyle` by default. A renamed prop is
45
+ **Which JSX prop carries styles?** — `sx` by default. A renamed prop is
46
46
  written into the plugin as `styleProp` and declared in `plumeria.d.ts`, so the
47
47
  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 `sx`?** — 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
@@ -89,7 +95,8 @@ nothing is touched and the snippet is printed instead.
89
95
  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
- npx @plumeria/init --style-prop sx
98
+ npx @plumeria/init --style-prop classStyle
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
@@ -25,10 +25,11 @@ Options
25
25
  -y, --yes accept every default, ask nothing
26
26
  -d, --dry-run show the plan without writing
27
27
  --bundler <name> ${detect_1.BUNDLERS.join(', ')}
28
- --style-prop <p> the JSX prop that carries styles (default classStyle)
28
+ --style-prop <p> the JSX prop that carries styles (default sx)
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
  }
@@ -37,12 +38,13 @@ export type Action = {
37
38
  note: string;
38
39
  file: string;
39
40
  };
40
- export declare const DEFAULT_STYLE_PROP = "classStyle";
41
+ export declare const DEFAULT_STYLE_PROP = "sx";
41
42
  export declare const assertStyleProp: (value: string) => string;
42
43
  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,12 +3,12 @@ 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");
10
10
  const source_1 = require("./source");
11
- exports.DEFAULT_STYLE_PROP = 'classStyle';
11
+ exports.DEFAULT_STYLE_PROP = 'sx';
12
12
  const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
13
13
  const RESERVED = new Set(['className', 'key', 'ref', 'children', 'style']);
14
14
  const assertStyleProp = (value) => {
@@ -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) {
@@ -85,7 +91,7 @@ const pluginCall = (bundler, answers, local = 'plumeria') => `${local}.${UNPLUGI
85
91
  exports.pluginCall = pluginCall;
86
92
  const declarationSource = (answers) => {
87
93
  if (answers.styleProp === exports.DEFAULT_STYLE_PROP) {
88
- return `/// <reference types="@plumeria/core/class-style" />\n`;
94
+ return `/// <reference types="@plumeria/core/sx" />\n`;
89
95
  }
90
96
  return `import type { Style } from '@plumeria/core';
91
97
 
@@ -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 = [(0, exports.spellingRule)(answers)].filter((rule) => rule !== undefined);
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 = [(0, exports.spellingRule)(answers)].filter((rule) => rule !== undefined);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/init",
3
- "version": "21.2.6",
3
+ "version": "22.0.0",
4
4
  "description": "One command that sets up Plumeria: detects the bundler, installs the packages, writes the configs",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",