Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement stylelint-bezier package for easy use of bezier design token #2412

Merged
merged 20 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ff79b03
feat(stylelint-bezier): scaffolding
sungik-choi Mar 22, 2024
6538b96
feat(stylelint-bezier): copy code working in progress of @ed
yangwooseong Aug 7, 2024
1943b0d
feat(stylelint-bezier): reinstall bezier-tokens, add postcss-styled-s…
yangwooseong Aug 8, 2024
9aa0335
feat(stylelint-bezier): include alpha token flatten
yangwooseong Aug 8, 2024
68abf52
feat(stylelint-bezier): set secondary options of rule
yangwooseong Aug 8, 2024
e44e7f0
chore(stylelint-bezier): rm dirty
yangwooseong Aug 8, 2024
35743ef
feat(stylelint-bezier): test code for typescript
yangwooseong Aug 8, 2024
97d4336
Revert "feat(stylelint-bezier): test code for typescript"
yangwooseong Aug 8, 2024
6c50d0c
chore(stylelint-bezier): update README, packages.jon, LICENSE file
yangwooseong Aug 8, 2024
1c0f418
chore(changeset): add
yangwooseong Aug 8, 2024
4bd5f75
chore(lockfile): dedupe
yangwooseong Aug 8, 2024
6a7f31b
feat(stylelint-bezier): add stylelint-bezier to peerDeps of bezier-react
yangwooseong Aug 8, 2024
966a60d
feat(stylelint-bezier): add tsx to files
yangwooseong Aug 8, 2024
147f561
chore(stylelint-bezier): resolve stylelint warning
yangwooseong Aug 8, 2024
fba8172
feat(stylelint-bezier): resolve error in yarn lint command
yangwooseong Aug 8, 2024
7238ec9
feat(stylelint-bezier): rm stylelint-bezier from peerDeps in bezier-r…
yangwooseong Aug 8, 2024
038c916
chore(stylelint-bezier): add .eslintrc.js file
yangwooseong Aug 21, 2024
71b10d8
chore(stylelint-bezier): add common scripts
yangwooseong Aug 21, 2024
9948d30
chore(stylelint-bezier): add .eslintignore
yangwooseong Aug 21, 2024
57e83c2
refactor(stylelint-bezier): set ignorePatterns in eslint-config-bezie…
yangwooseong Aug 21, 2024
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
5 changes: 5 additions & 0 deletions .changeset/smooth-nails-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@channel.io/stylelint-bezier': minor
---

Release of `stylelint-bezier` package. It includes stylelint configuration for token validation rules to make `bezier-tokens` easy to use.
9 changes: 8 additions & 1 deletion .stylelintrc.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('stylelint').Config} */
export default {
extends: ['@channel.io/stylelint-config'],
extends: ['@channel.io/stylelint-config', './packages/stylelint-bezier'],
rules: {
'selector-class-pattern': [
// NOTE: Allows Pascal case(components) and Kebab case(states, variants, etc.).
Expand All @@ -11,5 +11,12 @@ export default {
],
// NOTE: Set to reduce difficulties caused by selector specificity between components.
'selector-max-specificity': ['0,2,0'],
'bezier/validate-token': [
true,
{
ignorePrefix: ['b-'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

severity: 'warning',
},
],
},
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
| [bezier-figma-plugin](packages/bezier-figma-plugin) | Figma plugin that helps build Bezier design system and increase productivity. |
| [bezier-tokens](packages/bezier-tokens) | Design token library for Bezier design system. |
| [bezier-vscode](packages/bezier-vscode) | VS Code extension for Bezier design system. |
| [stylelint-bezier](packages/stylelint-bezier) | Stylelint configuration for Bezier design system. |

## Commands

Expand Down
1 change: 1 addition & 0 deletions configs/eslint-config-bezier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
extends: ['@channel.io/eslint-config/web'],
plugins: ['@channel.io/eslint-plugin', 'jest'],
parser: '@typescript-eslint/parser',
ignorePatterns: ['dist', 'node_modules'],
env: {
node: true,
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@changesets/get-github-info": "^0.6.0",
"@changesets/types": "^6.0.0",
"@channel.io/prettier-config": "^0.0.1",
"@channel.io/stylelint-bezier": "0.0.0",
"@channel.io/stylelint-config": "^2.0.0",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-conventional": "^19.0.0",
Expand Down
4 changes: 0 additions & 4 deletions packages/bezier-codemod/.eslintignore

This file was deleted.

1 change: 1 addition & 0 deletions packages/bezier-codemod/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ module.exports = {
rules: {
'no-restricted-imports': 'off',
},
ignorePatterns: ['**/fixtures/*'],
}
2 changes: 0 additions & 2 deletions packages/bezier-figma-plugin/.eslintignore

This file was deleted.

2 changes: 0 additions & 2 deletions packages/bezier-icons/.eslintignore

This file was deleted.

5 changes: 0 additions & 5 deletions packages/bezier-react/.eslintignore

This file was deleted.

1 change: 1 addition & 0 deletions packages/bezier-react/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
tsconfigRootDir: __dirname,
project: './tsconfig.eslint.json',
},
ignorePatterns: ['coverage', '__mocks__', '!.storybook'],
rules: {
'import/order': [
'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-primary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-dark);
}
}
Expand All @@ -202,6 +203,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-secondary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-lighter);
}
}
Expand All @@ -214,6 +216,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-tertiary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-lightest);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-primary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-dark);
}
}
Expand All @@ -155,6 +156,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-secondary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-lighter);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-primary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-dark);
}
}
Expand All @@ -128,6 +129,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-secondary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-lighter);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-primary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-dark);
}
}
Expand All @@ -183,6 +184,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-secondary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-lighter);
}
}
Expand All @@ -195,6 +197,7 @@ $chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple';
&:where(.variant-tertiary) {
@each $color in $chromatic-colors {
&:where(.color-#{'' + $color}) {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color}-lightest);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ $active-selector: ':where(.active, :hover):where(:not(:disabled))';
@each $color-variant in $chromatic-color-variants {
&:where(.color-#{$color-variant}) {
color: var(--bgtxt-absolute-white-dark);
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color-variant}-normal);

&#{$active-selector} {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color-variant}-dark);
}
}
Expand Down Expand Up @@ -112,12 +114,14 @@ $active-selector: ':where(.active, :hover):where(:not(:disabled))';
&:where(.style-secondary) {
@each $color-variant in $chromatic-color-variants {
&:where(.color-#{$color-variant}) {
/* stylelint-disable bezier/validate-token */
color: var(--bgtxt-#{$color-variant}-normal);
background-color: var(--bgtxt-#{$color-variant}-lightest);

&#{$active-selector} {
background-color: var(--bgtxt-#{$color-variant}-lighter);
}
/* stylelint-enable bezier/validate-token */
}
}

Expand Down Expand Up @@ -154,9 +158,11 @@ $active-selector: ':where(.active, :hover):where(:not(:disabled))';

@each $color-variant in $chromatic-color-variants {
&:where(.color-#{$color-variant}) {
/* stylelint-disable-next-line bezier/validate-token */
color: var(--bgtxt-#{$color-variant}-normal);

&#{$active-selector} {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color-variant}-lightest);
}
}
Expand Down Expand Up @@ -191,9 +197,11 @@ $active-selector: ':where(.active, :hover):where(:not(:disabled))';
@each $color-variant in $chromatic-color-variants {
&:where(.color-#{$color-variant}) {
color: var(--bgtxt-absolute-white-dark);
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color-variant}-normal);

&#{$active-selector} {
/* stylelint-disable-next-line bezier/validate-token */
background-color: var(--bgtxt-#{$color-variant}-dark);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $elevations: 1, 2, 3, 4, 5, 6;

@each $ev in $elevations {
:where(.elevation-#{$ev}) {
/* stylelint-disable-next-line bezier/validate-token */
box-shadow: var(--ev-#{$ev});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $radiuses:

@each $radius in $radiuses {
:where(.radius-#{$radius}) {
/* stylelint-disable-next-line bezier/validate-token */
border-radius: var(--radius-#{$radius});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $z-indices: hidden, base, floating, overlay, modal, toast, tooltip, important;

@each $z-index in $z-indices {
:where(.z-index-#{$z-index}) {
/* stylelint-disable-next-line bezier/validate-token */
z-index: var(--z-index-#{$z-index});
}
}
2 changes: 0 additions & 2 deletions packages/bezier-tokens/.eslintignore

This file was deleted.

2 changes: 0 additions & 2 deletions packages/bezier-vscode/.eslintignore

This file was deleted.

11 changes: 11 additions & 0 deletions packages/stylelint-bezier/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
root: true,
extends: ['bezier'],
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.eslint.json',
},
}
File renamed without changes.
53 changes: 53 additions & 0 deletions packages/stylelint-bezier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Stylelint Bezier

Stylelint configuration for Bezier design system.

## Installation

### npm

```bash
npm i -D @channel.io/stylelint-bezier
```

### yarn

```bash
yarn add -D @channel.io/stylelint-bezier
```

## Usage

Extend @channel.io/stylelint-bezier in your stylelint config.

```json
{
"extends": ["@channel.io/stylelint-bezier"]
}
```

## Rules

### validate-token

Disallows use of tokens not in bezier-tokens. If you want to use css variable other than bezier design token, you can set a specific prefix and add it to ignorePrefix.

```tsx
{
rule: {
'bezier/validate-token': [
true,
{
ignorePrefix: ['b-'],
severity: 'warning',
},
],
}
}
```

## Version Matchups

| @channel.io/stylelint-bezier | @channel.io/bezier-react |
| ---------------------------- | ------------------------ |
| 0.1.0 | 2.2.4 |
Comment on lines +49 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

33 changes: 33 additions & 0 deletions packages/stylelint-bezier/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@channel.io/stylelint-bezier",
"version": "0.0.0",
"description": "Stylelint configuration for Bezier design system.",
"repository": {
"type": "git",
"url": "https://github.com/channel-io/bezier-react",
"directory": "packages/stylelint-bezier"
},
"main": "dist/index.js",
"scripts": {
"build": "tsc --build --verbose",
"dev": "tsc --watch",
"lint": "TIMING=1 eslint --cache .",
"typecheck": "tsc --noEmit",
"clean": "run-s 'clean:*'",
"clean:build": "rm -rf dist",
"clean:cache": "rm -rf node_modules .turbo .eslintcache stats.html"
},
"author": "Channel Corp.",
"license": "Apache-2.0",
"dependencies": {
"@channel.io/bezier-tokens": "0.2.6"
},
"devDependencies": {
"eslint-config-bezier": "workspace:*",
"postcss-styled-syntax": "^0.6.4",
"tsconfig": "workspace:*"
},
"peerDependencies": {
"stylelint": ">=16.0.0"
}
}
12 changes: 12 additions & 0 deletions packages/stylelint-bezier/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
plugins: ['./plugins/validate-token'],
rules: {
'bezier/validate-token': true,
},
overrides: [
{
files: ['**/*.{ts,tsx}'],
customSyntax: 'postcss-styled-syntax',
},
],
}
Loading
Loading