Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/ci-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,18 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Setup yarn
run: npm install -g yarn
- name: Install deps
id: dependencies
run: yarn install --frozen-lockfile
timeout-minutes: 15
- name: Build
run: yarn build
- name: Bundlewatch
run: yarn bundlewatch
- name: Install Chromium
run: yarn workspace @cloudtower/eagle exec playwright install --with-deps chromium
- name: Test
run: yarn test:ci
- name: Check new fixed colors
if: ${{ !cancelled() && steps.dependencies.outcome == 'success' }}
env:
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: yarn workspace @cloudtower/eagle lint:colors:changed "$PR_BASE_SHA"
- name: Compare computed styles
run: yarn workspace @cloudtower/eagle test:styles
151 changes: 0 additions & 151 deletions packages/eagle/__test__/color-lint/check-changed-colors.test.cjs

This file was deleted.

12 changes: 10 additions & 2 deletions packages/eagle/__test__/color-lint/color-lint.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ async function run() {
const result = await lint(`.fixture { color: ${value}; }`, "scss");
assert.ok(
result.results[0].warnings.length > 0,
`Missing warning: ${value}`,
`Missing color diagnostic: ${value}`,
);
assert.ok(
result.results[0].warnings.every((item) => item.severity === "warning"),
result.results[0].warnings.every((item) => item.severity === "error"),
);
assert.ok(result.errored, `Hardcoded color must fail lint: ${value}`);
}
const valid = await lint(
".fixture { color: $text-light-primary; background: var(--fill); border-color: currentColor; }",
Expand All @@ -43,6 +44,13 @@ async function run() {
assert.ok(
linaria.results[0].warnings.some((item) => item.rule === "color-no-hex"),
);
const exception = await lint(
"const S = css`\n/* stylelint-disable-next-line color-no-hex -- Test suppression for a color with an equivalent token. */\ncolor: #00122e;\nbackground: #00122e;\n`;",
"tsx",
);
assert.equal(exception.results[0].warnings.length, 1);
assert.equal(exception.results[0].warnings[0].line, 4);
assert.ok(exception.errored, "The next declaration must still fail lint");
const broken = await lint('const S = css`color: "unterminated`;', "tsx");
assert.ok(broken.errored, "Syntax errors must remain errors");
console.log(`Color lint checks passed (${version.trim()})`);
Expand Down
4 changes: 1 addition & 3 deletions packages/eagle/docs/theme-color-gaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

透明度也逐项比较:例如 rgba(...,.1) 与八位十六进制 ...1A(约 .101961)并非严格等值,保留原透明度,不将精度差异视为设计确认。

PR 保留全量颜色警告。增量检查只在新增或改动行涉及颜色用法、且该固定颜色已有等值 Eagle token 时令 CI 失败。历史用法和暂时没有等值 token 的固定颜色继续由原有规则提示。样式可直接使用 CSS 变量,也可通过公开的 `Color`/`Effect` 保留运行时引用。

在本地可运行 `yarn workspace @cloudtower/eagle lint:colors:changed <base-ref>` 检查已提交的变更。检查使用生成的默认浅色 token 值。旧 Sass 别名的值取自主题迁移前 `523ffb98` 的公开 Sass 文件。增量检查覆盖可静态识别的 sRGB 色值和 Sass 别名,动态颜色计算和跨文件数据流留给代码审查。
全量颜色 lint 会阻断未放行的硬编码。待设计确认的值在使用处注明原因,并通过对应规则的单行注释放行。审查时确认是否已有等值 token。样式可直接使用 CSS 变量,也可通过公开的 `Color`/`Effect` 保留运行时引用。

## Eagle 保留值

Expand Down
4 changes: 3 additions & 1 deletion packages/eagle/docs/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ hook 不保存偏好,也不在卸载时恢复主题。原有 antd4Configs/an
## 检查

根 `yarn test:ci` 包含组件单测、颜色规则回归与 lint;主题完整性在构建时校验。
颜色硬编码使用 Stylelint/ast-grep 提示 warning,配置或语法错误仍会失败;没有历史 baseline。
Stylelint/ast-grep 将硬编码颜色作为 error 阻断检查。没有完全等值的 token 时,保留原值并在使用处注明原因,
用 `stylelint-disable-next-line <规则名> -- No equivalent theme token.` 放行单行 CSS,
或在 TS/TSX 的目标行前写原因和 `// ast-grep-ignore: <规则名>`。其余声明继续检查。
独立排查可用 `test:colors`、`lint:colors`、`lint:colors:ts`;包内测试前须先构建。
安装 ast-grep 时须执行 postinstall,避免留下未真正扫描的占位程序。

Expand Down
7 changes: 2 additions & 5 deletions packages/eagle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
"prebuild": "yarn generate:theme",
"lint:colors": "stylelint \"src/**/*.{ts,tsx,css,scss}\"",
"lint:colors:ts": "ast-grep scan --color=never",
"lint:colors:changed": "node tools/color-lint/check-changed-colors.cjs",
"check:theme": "yarn generate:theme && git diff --exit-code -- src/styles/token src/styles/common/variables.scss",
"test:colors": "node __test__/color-lint/color-lint.test.cjs && ast-grep test --skip-snapshot-tests && node __test__/color-lint/check-changed-colors.test.cjs",
"check:theme": "yarn generate:theme && git diff --exit-code -- src/styles/token docs/theme-tokens.md",
"test:colors": "node __test__/color-lint/color-lint.test.cjs && ast-grep test --skip-snapshot-tests",
"posttest:ci": "yarn test:colors && yarn lint:colors && yarn lint:colors:ts",
"postbuild": "node -e \"for (const file of ['dist/variables.scss', 'dist/linaria.merged.scss']) require('fs').rmSync(file, { force: true })\"",
"test:styles": "playwright test --config playwright.config.cjs",
Expand Down Expand Up @@ -102,7 +101,6 @@
"@types/react-transition-group": "4.2.4",
"@types/xterm": "^3.0.0",
"@vitejs/plugin-react": "^4.2.1",
"colord": "^2.9.3",
"copy-to-clipboard": "^3.3.3",
"dotenv": "^16.4.7",
"history": "^4.9.0",
Expand All @@ -117,7 +115,6 @@
"postcss-import": "^15",
"postcss-scss": "^4",
"postcss-url": "^10.1.3",
"postcss-value-parser": "^4.2.0",
"rc-select": "^11.5.3",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/eagle/src/core/AccordionCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Card = styled.div`
border-color: var(--stroke-outstanding-base);

> header {
/* stylelint-disable-next-line color-no-hex -- No equivalent theme token. */
background: rgba(#0080ff, 0.1);
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/eagle/src/core/Banner/banner.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ export const BasicBanner = css`

.banner-action {
padding: 2px 8px;
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- No equivalent theme token. */
background: rgba(255, 255, 255, 0.16);
&:hover {
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- No equivalent theme token. */
background: rgba(255, 255, 255, 0.28);
}
&:active {
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- No equivalent theme token. */
background: rgba(255, 255, 255, 0.16);
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- No equivalent theme token. */
box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.5);
}
}
Expand All @@ -83,6 +87,7 @@ export const BasicBanner = css`
opacity: 0.8;
}
&:hover {
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- No equivalent theme token. */
background: rgba(255, 255, 255, 0.28);
.icon-wrapper {
opacity: 1;
Expand Down
1 change: 1 addition & 0 deletions packages/eagle/src/core/BlankState/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const BlankStateWrapper = css`
flex-direction: column;
align-items: center;
justify-content: center;
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- No equivalent theme token. */
color: rgba(0, 21, 64, 0.3);
&.large {
max-width: 648px;
Expand Down
4 changes: 4 additions & 0 deletions packages/eagle/src/core/Breadcrumb/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const Breadcrumb: React.FunctionComponent<IBreadcrumbProps> = (props) => {
>
<path
d="M4.81662 3.33203C5.15455 3.555 5.32351 3.66649 5.38224 3.80736C5.43358 3.93049 5.43358 4.06904 5.38224 4.19218C5.32351 4.33305 5.15455 4.44454 4.81662 4.66751L1.81921 6.64529C1.4159 6.91141 1.21424 7.04446 1.04715 7.03393C0.901576 7.02475 0.767265 6.95246 0.679429 6.836C0.578613 6.70234 0.578613 6.46074 0.578613 5.97755L0.578613 2.02199C0.578613 1.53879 0.578613 1.2972 0.679429 1.16353C0.767265 1.04708 0.901576 0.974785 1.04715 0.965607C1.21424 0.955073 1.4159 1.08813 1.81921 1.35425L4.81662 3.33203Z"
// No equivalent theme token.
// ast-grep-ignore: no-hardcoded-color-tsx
fill="#031E4F"
fillOpacity="0.18"
/>
Expand All @@ -68,6 +70,8 @@ const Breadcrumb: React.FunctionComponent<IBreadcrumbProps> = (props) => {
>
<path
d="M4.81662 3.33203C5.15455 3.555 5.32351 3.66649 5.38224 3.80736C5.43358 3.93049 5.43358 4.06904 5.38224 4.19218C5.32351 4.33305 5.15455 4.44454 4.81662 4.66751L1.81921 6.64529C1.4159 6.91141 1.21424 7.04446 1.04715 7.03393C0.901576 7.02475 0.767265 6.95246 0.679429 6.836C0.578613 6.70234 0.578613 6.46074 0.578613 5.97755L0.578613 2.02199C0.578613 1.53879 0.578613 1.2972 0.679429 1.16353C0.767265 1.04708 0.901576 0.974785 1.04715 0.965607C1.21424 0.955073 1.4159 1.08813 1.81921 1.35425L4.81662 3.33203Z"
// No equivalent theme token.
// ast-grep-ignore: no-hardcoded-color-tsx
fill="#031E4F"
fillOpacity="0.18"
/>
Expand Down
Loading
Loading