Skip to content

Commit 7a820b1

Browse files
huang-julienvalentinpalkovic
authored andcommitted
Merge pull request #34245 from storybookjs/chore/root_oxfmt
Cleanup: Unify oxlint at root and add more file to format (cherry picked from commit b31240c)
1 parent a1ca843 commit 7a820b1

36 files changed

Lines changed: 227 additions & 233 deletions

.github/workflows/nx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
3333
runs-on: ubuntu-latest
3434
env:
35-
ALL_TASKS: compile,check,knip,test,pretty-docs,lint,sandbox,build,e2e-tests,e2e-tests-dev,test-runner,vitest-integration,check-sandbox,e2e-ui,jest,vitest,playwright-ct,cypress
35+
ALL_TASKS: compile,check,knip,test,lint,sandbox,build,e2e-tests,e2e-tests-dev,test-runner,vitest-integration,check-sandbox,e2e-ui,jest,vitest,playwright-ct,cypress
3636
steps:
3737
- uses: actions/checkout@v4
3838
with:

.husky/pre-commit

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
if [ -z "$SKIP_STORYBOOK_GIT_HOOKS" ]; then
2-
cd code
3-
yarn lint-staged
4-
5-
cd ../scripts
62
yarn lint-staged
73
fi

.lintstagedrc.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { detectAgent } from 'std-env';
2+
3+
const fmtCmd = detectAgent().name ? 'oxfmt' : 'oxfmt --check';
4+
5+
export default {
6+
'code/**/*.{js,jsx,mjs,ts,tsx,html,json}': [fmtCmd, 'yarn --cwd code lint:js:cmd'],
7+
'scripts/**/*.{html,js,json,jsx,mjs,ts,tsx}': ['yarn --cwd scripts lint:js:cmd'],
8+
'docs/_snippets/**/*.{js,jsx,mjs,ts,tsx,html,json}': [fmtCmd],
9+
'**/*.ejs': ['yarn --cwd scripts exec ejslint'],
10+
'**/package.json': ['yarn --cwd scripts lint:package'],
11+
};

.nx/workflows/distribution-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ assignment-rules:
1414
- compile
1515
- check
1616
- lint
17-
- pretty-docs
1817
- knip
1918
run-on:
2019
- agent: linux-js

.oxfmtrc.json

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
23
"printWidth": 100,
34
"tabWidth": 2,
45
"bracketSpacing": true,
@@ -7,20 +8,61 @@
78
"arrowParens": "always",
89
"sortPackageJson": false,
910
"ignorePatterns": [
10-
"code",
11-
"test-storybooks",
12-
"node_modules",
11+
"*.bundle.js",
12+
"*.js.map",
1313
".yarn",
14-
".nx",
1514
".vscode",
16-
".github",
17-
"*.md",
18-
"*.mdx",
15+
".nx/cache",
16+
".nx/workspace-data",
17+
"dist",
18+
"build",
19+
"bench",
20+
"coverage",
21+
"node_modules",
22+
"storybook-static",
23+
"built-storybooks",
24+
"ember-output",
25+
"code/core/assets",
26+
"code/core/report",
27+
"code/core/src/core-server/presets/common-manager.ts",
28+
"code/core/src/core-server/utils/__search-files-tests__",
29+
"code/core/src/core-server/utils/__mockdata__/src/Empty.stories.ts",
30+
"code/lib/codemod/src/transforms/__testfixtures__",
31+
"code/frameworks/angular/template/**",
32+
"code/lib/eslint-plugin",
33+
".prettierrc",
34+
"test-storybooks",
1935
"*.yml",
2036
"*.yaml",
21-
"docs/versions",
22-
"CHANGELOG*",
23-
"MIGRATION*",
24-
"CONTRIBUTING*"
37+
"*.md",
38+
"*.mdx",
39+
"!docs/_snippets/**"
40+
],
41+
"overrides": [
42+
{
43+
"files": ["docs/_snippets/**"],
44+
"options": {
45+
"trailingComma": "all"
46+
}
47+
},
48+
{
49+
"files": ["*.md", "*.mdx"],
50+
"options": {
51+
"importOrderSeparation": false,
52+
"importOrderSortSpecifiers": false
53+
}
54+
},
55+
{
56+
"files": ["*.component.html"],
57+
"options": {
58+
"parser": "angular"
59+
}
60+
},
61+
{
62+
"files": ["**/frameworks/angular/src/**/*.ts", "**/frameworks/angular/template/**/*.ts"],
63+
"options": {
64+
"parser": "babel-ts"
65+
}
66+
}
2567
]
2668
}

.vscode/extensions.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"dbaeumer.vscode-eslint",
44
"EditorConfig.EditorConfig",
55
"unifiedjs.vscode-mdx",
6-
"yzhang.markdown-all-in-one"
6+
"yzhang.markdown-all-in-one",
7+
"oxc.oxc-vscode"
78
]
8-
}
9+
}

.vscode/settings.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
{
2-
"[javascript]": {
3-
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
4-
"editor.formatOnSave": true
5-
},
6-
"[javascriptreact]": {
7-
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
8-
"editor.formatOnSave": true
9-
},
10-
"[typescript]": {
2+
"[javascript][javascriptreact][typescript][typescriptreact][json][jsonc]": {
113
"editor.defaultFormatter": "oxc.oxc-vscode",
124
"editor.formatOnSave": true
135
},
14-
"[typescriptreact]": {
15-
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
16-
"editor.formatOnSave": true
17-
},
186
"editor.codeActionsOnSave": {
19-
"source.fixAll.eslint": "explicit"
7+
"source.fixAll.eslint": "explicit",
8+
"source.fixAll.oxc": "explicit"
209
},
2110
"editor.formatOnSave": true,
2211
"editor.tabSize": 2,
23-
"eslint.format.enable": true,
2412
"eslint.options": {
2513
"cache": true,
2614
"cacheLocation": ".cache/eslint",
27-
"extensions": [".js", ".jsx", ".mjs", ".json", ".ts", ".tsx"]
15+
"extensions": [
16+
".js",
17+
".jsx",
18+
".mjs",
19+
".json",
20+
".ts",
21+
".tsx"
22+
]
2823
},
2924
"eslint.useESLintClass": true,
3025
"eslint.validate": [
@@ -35,9 +30,13 @@
3530
"typescript",
3631
"typescriptreact"
3732
],
38-
"eslint.workingDirectories": ["./code", "./scripts"],
33+
"eslint.workingDirectories": [
34+
"./code",
35+
"./scripts"
36+
],
3937
"files.associations": {
40-
"*.js": "javascriptreact"
38+
"*.js": "javascriptreact",
39+
".oxfmtrc.json": "json"
4140
},
4241
"javascript.preferences.importModuleSpecifier": "relative",
4342
"javascript.preferences.quoteStyle": "single",
@@ -51,4 +50,6 @@
5150
"typescript.tsdk": "./typescript/lib",
5251
"vitest.workspaceConfig": "./code/vitest.workspace.ts",
5352
"vitest.rootConfig": "./code/vitest.workspace.ts",
54-
}
53+
"oxc.fmt.configPath": ".oxfmtrc.json",
54+
"oxc.enable.oxlint": false,
55+
}

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ Use Storybook loggers instead of raw `console.*` in normal code paths:
243243
- Server-side: `storybook/internal/node-logger`
244244
- Client-side: `storybook/internal/client-logger`
245245

246+
The pre-commit hook automatically detects AI agents (via `std-env`) and switches from check-only to write mode, so formatting is auto-fixed when agents commit.
247+
246248
Avoid `console.log`, `console.warn`, and `console.error` unless the file is isolated enough that importing the logger is not reasonable.
247249

248250
## Troubleshooting

code/.oxfmtrc.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

code/builders/builder-vite/input/iframe.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@
7070
if (hostname !== 'localhost' && globalThis.CONFIG_TYPE === 'DEVELOPMENT') {
7171
const message = `Failed to load the Storybook preview file 'vite-app.js':
7272
73-
It looks like you're visiting the Storybook development server on another hostname than localhost: '${hostname}', but you haven't configured the necessary security features to support this.
74-
Please re-run your Storybook development server with the '--host ${hostname}' flag, or manually configure your Vite allowedHosts configuration with viteFinal.
73+
It looks like you're visiting the Storybook development server on another hostname than localhost: '${hostname}', but you haven't configured the necessary security features to support this.
74+
Please re-run your Storybook development server with the '--host ${hostname}' flag, or manually configure your Vite allowedHosts configuration with viteFinal.
7575
76-
See:`;
76+
See:`;
7777
const docs = [
7878
'https://storybook.js.org/docs/api/cli-options#dev',
7979
'https://storybook.js.org/docs/api/main-config/main-config-vite-final',
@@ -85,7 +85,7 @@
8585
`<p style="color: red; max-width: 70ch">${message.replaceAll(
8686
'\n',
8787
'<br/>'
88-
)}<ul>${docs.map((doc) => `<li><a href='${doc}' target='_blank'>${doc}</a></li>`).join('')}<ul></p>`;
88+
)}<ul>${docs.map((doc) => `<li><a href='${doc}' target='_blank'>${doc}</a></li>`).join('')}</ul></p>`;
8989
return;
9090
}
9191
}

0 commit comments

Comments
 (0)