Skip to content

Commit 0b77744

Browse files
authored
chore(fmt): use default print width (#369)
1 parent 4ee1c71 commit 0b77744

109 files changed

Lines changed: 2087 additions & 681 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/migrate-to-rstack-cli/references/rslint.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ Read this reference when the project uses `@rslint/core`, `rslint.config.*`, `rs
1414
```ts
1515
import { define } from 'rstack';
1616

17-
define.lint(({ js, ts }) => [js.configs.recommended, ts.configs.recommendedTypeChecked]);
17+
define.lint(({ js, ts }) => [
18+
js.configs.recommended,
19+
ts.configs.recommendedTypeChecked,
20+
]);
1821
```
1922

2023
Preserve existing presets and rules during migration.

examples/test-inline-projects/tests/dom.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ import App from '../src/App';
55
test('renders the app in a DOM environment', () => {
66
render(<App />);
77

8-
expect(screen.getByRole('heading', { name: 'Rstack React SSR' })).toBeTruthy();
8+
expect(
9+
screen.getByRole('heading', { name: 'Rstack React SSR' }),
10+
).toBeTruthy();
911
});

packages/create-rstack/src/index.ts

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import {
55
create,
66
select,
77
} from '@rstackjs/create-toolkit';
8-
import { access, appendFile, mkdir, readFile, writeFile } from 'node:fs/promises';
8+
import {
9+
access,
10+
appendFile,
11+
mkdir,
12+
readFile,
13+
writeFile,
14+
} from 'node:fs/promises';
915
import path from 'node:path';
1016

1117
const packageRoot = path.join(import.meta.dirname, '..');
@@ -87,12 +93,15 @@ const getTemplateName = async ({ template }: Argv): Promise<string> => {
8793
}),
8894
);
8995

90-
return resolveTemplateName(documentationType === 'basic' ? 'doc' : 'doc-i18n');
96+
return resolveTemplateName(
97+
documentationType === 'basic' ? 'doc' : 'doc-i18n',
98+
);
9199
}
92100

93101
const templateType = checkCancel<string>(
94102
await select({
95-
message: projectType === 'app' ? 'Select framework' : 'Select library type',
103+
message:
104+
projectType === 'app' ? 'Select framework' : 'Select library type',
96105
options:
97106
projectType === 'app'
98107
? [
@@ -129,12 +138,32 @@ const getTemplateName = async ({ template }: Argv): Promise<string> => {
129138
};
130139

131140
const getStagedConfig = (templateName: string): string => {
132-
const scriptExtensions = ['js', 'jsx', 'ts', 'tsx', 'mjs', 'cjs', 'mts', 'cts'];
133-
const formatExtensions = ['json', 'jsonc', 'md', 'mdx', 'css', 'html', 'yml', 'yaml'];
141+
const scriptExtensions = [
142+
'js',
143+
'jsx',
144+
'ts',
145+
'tsx',
146+
'mjs',
147+
'cjs',
148+
'mts',
149+
'cts',
150+
];
151+
const formatExtensions = [
152+
'json',
153+
'jsonc',
154+
'md',
155+
'mdx',
156+
'css',
157+
'html',
158+
'yml',
159+
'yaml',
160+
];
134161
const componentExtensions = ['svelte', 'vue'];
135162
const templateFormatExtensions = [
136163
...formatExtensions,
137-
...componentExtensions.filter((extension) => templateName.includes(extension)),
164+
...componentExtensions.filter((extension) =>
165+
templateName.includes(extension),
166+
),
138167
];
139168

140169
return [
@@ -157,7 +186,9 @@ const injectStagedSetup = async ({
157186
return;
158187
}
159188

160-
const configExtension = await access(path.join(distFolder, 'rstack.config.ts')).then(
189+
const configExtension = await access(
190+
path.join(distFolder, 'rstack.config.ts'),
191+
).then(
161192
() => 'ts',
162193
() => 'js',
163194
);
@@ -167,8 +198,8 @@ const injectStagedSetup = async ({
167198
};
168199

169200
packageJson.scripts = Object.fromEntries(
170-
Object.entries({ ...packageJson.scripts, prepare: 'rs setup' }).sort(([left], [right]) =>
171-
left.localeCompare(right),
201+
Object.entries({ ...packageJson.scripts, prepare: 'rs setup' }).sort(
202+
([left], [right]) => left.localeCompare(right),
172203
),
173204
);
174205

packages/create-rstack/tests/create.test.ts

Lines changed: 100 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,65 @@ type SourceTemplate = {
3131

3232
const sourceTemplates: SourceTemplate[] = [
3333
{ template: 'app-vanilla', sourceExtension: 'js', testFile: 'dom.test.js' },
34-
{ template: 'app-vanilla-ts', sourceExtension: 'ts', testFile: 'dom.test.ts' },
34+
{
35+
template: 'app-vanilla-ts',
36+
sourceExtension: 'ts',
37+
testFile: 'dom.test.ts',
38+
},
3539
{ template: 'app-react', sourceExtension: 'jsx', testFile: 'index.test.jsx' },
36-
{ template: 'app-react-ts', sourceExtension: 'tsx', testFile: 'index.test.tsx' },
37-
{ template: 'app-preact', sourceExtension: 'jsx', testFile: 'index.test.jsx' },
38-
{ template: 'app-preact-ts', sourceExtension: 'tsx', testFile: 'index.test.tsx' },
40+
{
41+
template: 'app-react-ts',
42+
sourceExtension: 'tsx',
43+
testFile: 'index.test.tsx',
44+
},
45+
{
46+
template: 'app-preact',
47+
sourceExtension: 'jsx',
48+
testFile: 'index.test.jsx',
49+
},
50+
{
51+
template: 'app-preact-ts',
52+
sourceExtension: 'tsx',
53+
testFile: 'index.test.tsx',
54+
},
3955
{ template: 'app-vue', sourceExtension: 'js', testFile: 'index.test.js' },
4056
{ template: 'app-vue-ts', sourceExtension: 'ts', testFile: 'index.test.ts' },
4157
{ template: 'app-lit', sourceExtension: 'js', testFile: 'index.test.js' },
4258
{ template: 'app-lit-ts', sourceExtension: 'ts', testFile: 'index.test.ts' },
4359
{ template: 'app-svelte', sourceExtension: 'js', testFile: 'index.test.js' },
44-
{ template: 'app-svelte-ts', sourceExtension: 'ts', testFile: 'index.test.ts' },
60+
{
61+
template: 'app-svelte-ts',
62+
sourceExtension: 'ts',
63+
testFile: 'index.test.ts',
64+
},
4565
{ template: 'app-solid', sourceExtension: 'jsx', testFile: 'index.test.jsx' },
46-
{ template: 'app-solid-ts', sourceExtension: 'tsx', testFile: 'index.test.tsx' },
66+
{
67+
template: 'app-solid-ts',
68+
sourceExtension: 'tsx',
69+
testFile: 'index.test.tsx',
70+
},
4771
{ template: 'lib-node', sourceExtension: 'js', testFile: 'index.test.js' },
4872
{ template: 'lib-node-ts', sourceExtension: 'ts', testFile: 'index.test.ts' },
4973
{ template: 'lib-react', sourceExtension: 'jsx', testFile: 'index.test.jsx' },
50-
{ template: 'lib-react-ts', sourceExtension: 'tsx', testFile: 'index.test.tsx' },
74+
{
75+
template: 'lib-react-ts',
76+
sourceExtension: 'tsx',
77+
testFile: 'index.test.tsx',
78+
},
5179
{ template: 'lib-vue', sourceExtension: 'js', testFile: 'index.test.js' },
5280
{ template: 'lib-vue-ts', sourceExtension: 'ts', testFile: 'index.test.ts' },
5381
{ template: 'lib-svelte', sourceExtension: 'js', testFile: 'index.test.js' },
54-
{ template: 'lib-svelte-ts', sourceExtension: 'ts', testFile: 'index.test.ts' },
82+
{
83+
template: 'lib-svelte-ts',
84+
sourceExtension: 'ts',
85+
testFile: 'index.test.ts',
86+
},
5587
{ template: 'lib-solid', sourceExtension: 'jsx', testFile: 'index.test.jsx' },
56-
{ template: 'lib-solid-ts', sourceExtension: 'tsx', testFile: 'index.test.tsx' },
88+
{
89+
template: 'lib-solid-ts',
90+
sourceExtension: 'tsx',
91+
testFile: 'index.test.tsx',
92+
},
5793
];
5894

5995
const docTemplates = [
@@ -74,14 +110,25 @@ const docTemplates = [
74110
];
75111

76112
const getCheckScript = (template: string, hasTypeScript: boolean): string =>
77-
hasTypeScript && !templatesWithoutTypeCheck.has(template) ? typeCheckScript : checkScript;
113+
hasTypeScript && !templatesWithoutTypeCheck.has(template)
114+
? typeCheckScript
115+
: checkScript;
78116

79-
const readProjectPackage = async (projectDirectory: string): Promise<ProjectPackage> =>
80-
JSON.parse(await readFile(path.join(projectDirectory, 'package.json'), 'utf8')) as ProjectPackage;
117+
const readProjectPackage = async (
118+
projectDirectory: string,
119+
): Promise<ProjectPackage> =>
120+
JSON.parse(
121+
await readFile(path.join(projectDirectory, 'package.json'), 'utf8'),
122+
) as ProjectPackage;
81123

82-
const expectFiles = async (projectDirectory: string, files: string[]): Promise<void> => {
124+
const expectFiles = async (
125+
projectDirectory: string,
126+
files: string[],
127+
): Promise<void> => {
83128
for (const file of files) {
84-
await expect(access(path.join(projectDirectory, file))).resolves.toBeUndefined();
129+
await expect(
130+
access(path.join(projectDirectory, file)),
131+
).resolves.toBeUndefined();
85132
}
86133
};
87134

@@ -92,10 +139,16 @@ const expectStagedSetup = async (
92139
): Promise<void> => {
93140
expect(scripts.prepare).toBe('rs setup');
94141
expect(
95-
await readFile(path.join(projectDirectory, '.rstack', 'hooks', 'pre-commit'), 'utf8'),
142+
await readFile(
143+
path.join(projectDirectory, '.rstack', 'hooks', 'pre-commit'),
144+
'utf8',
145+
),
96146
).toBe('rs staged\n');
97147
expect(
98-
await readFile(path.join(projectDirectory, `rstack.config.${configExtension}`), 'utf8'),
148+
await readFile(
149+
path.join(projectDirectory, `rstack.config.${configExtension}`),
150+
'utf8',
151+
),
99152
).toContain('define.staged({');
100153
};
101154

@@ -109,7 +162,10 @@ const expectNoStagedSetup = async (
109162
access(path.join(projectDirectory, '.rstack', 'hooks', 'pre-commit')),
110163
).rejects.toThrow();
111164
expect(
112-
await readFile(path.join(projectDirectory, `rstack.config.${configExtension}`), 'utf8'),
165+
await readFile(
166+
path.join(projectDirectory, `rstack.config.${configExtension}`),
167+
'utf8',
168+
),
113169
).not.toContain('define.staged({');
114170
};
115171

@@ -122,8 +178,14 @@ const expectProjectSetup = async (
122178
const packageJson = await readProjectPackage(projectDirectory);
123179

124180
expect(packageJson.name).toBe('my-app');
125-
expect(packageJson.scripts.check).toBe(getCheckScript(template, hasTypeScript));
126-
await expectStagedSetup(projectDirectory, configExtension, packageJson.scripts);
181+
expect(packageJson.scripts.check).toBe(
182+
getCheckScript(template, hasTypeScript),
183+
);
184+
await expectStagedSetup(
185+
projectDirectory,
186+
configExtension,
187+
packageJson.scripts,
188+
);
127189

128190
const tsconfig = access(path.join(projectDirectory, 'tsconfig.json'));
129191
if (hasTypeScript) {
@@ -135,7 +197,9 @@ const expectProjectSetup = async (
135197

136198
afterEach(async () => {
137199
await Promise.all(
138-
tempDirectories.splice(0).map((directory) => rm(directory, { recursive: true, force: true })),
200+
tempDirectories
201+
.splice(0)
202+
.map((directory) => rm(directory, { recursive: true, force: true })),
139203
);
140204
});
141205

@@ -154,7 +218,8 @@ const createProject = async (
154218
tempDirectories.push(tempDirectory);
155219

156220
if (initializeGitIn) {
157-
const gitDirectory = initializeGitIn === 'project' ? projectDirectory : tempDirectory;
221+
const gitDirectory =
222+
initializeGitIn === 'project' ? projectDirectory : tempDirectory;
158223
await mkdir(gitDirectory, { recursive: true });
159224
await execFileAsync('git', ['init', '--quiet'], { cwd: gitDirectory });
160225
}
@@ -209,14 +274,22 @@ test.each(sourceTemplates)(
209274
files.push('src/env.d.ts');
210275
}
211276

212-
await expectProjectSetup(projectDirectory, template, configExtension, hasTypeScript);
277+
await expectProjectSetup(
278+
projectDirectory,
279+
template,
280+
configExtension,
281+
hasTypeScript,
282+
);
213283
await expectFiles(projectDirectory, files);
214284
},
215285
);
216286

217-
test.each(docTemplates)('creates the $template template', async ({ template, files }) => {
218-
const projectDirectory = await createProject(template);
287+
test.each(docTemplates)(
288+
'creates the $template template',
289+
async ({ template, files }) => {
290+
const projectDirectory = await createProject(template);
219291

220-
await expectProjectSetup(projectDirectory, template, 'ts', true);
221-
await expectFiles(projectDirectory, files);
222-
});
292+
await expectProjectSetup(projectDirectory, template, 'ts', true);
293+
await expectFiles(projectDirectory, files);
294+
},
295+
);

packages/rstack/rslib.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { defineConfig } from '@rslib/core';
22
import prettierPkgJson from 'prettier/package.json' with { type: 'json' };
33
import pkgJson from './package.json' with { type: 'json' };
44

5-
const fullyMinifiedChunks = /(?:fmt(?:Lsp|Plugins)?|sortPackageJsonPlugin|staged)\.js$/;
5+
const fullyMinifiedChunks =
6+
/(?:fmt(?:Lsp|Plugins)?|sortPackageJsonPlugin|staged)\.js$/;
67

78
export default defineConfig({
89
dts: true,

0 commit comments

Comments
 (0)