Skip to content

Commit 4ceb96a

Browse files
authored
feat: added prettier and eslint support (#25)
1 parent dad4da8 commit 4ceb96a

38 files changed

+1106
-143
lines changed

.commitlintrc.cjs .commitlintrc.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
module.exports = {
1+
// @ts-check
2+
3+
/**
4+
* @type {import('@commitlint/types').UserConfig}
5+
*/
6+
const config = {
27
extends: ['@commitlint/config-conventional'],
38
rules: {
49
'type-enum': [
@@ -7,4 +12,6 @@ module.exports = {
712
['feat', 'feature', 'fix', 'refactor', 'docs', 'build', 'test', 'ci', 'chore', 'fonts']
813
]
914
}
10-
};
15+
};
16+
17+
module.exports = config;

.eslintrc.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @ts-check
2+
3+
/**
4+
* @type {import('eslint').Linter.Config}
5+
*/
6+
const config = {
7+
root: true,
8+
env: {
9+
es2022: true
10+
},
11+
ignorePatterns: ['dist', 'node_modules'],
12+
extends: ['plugin:prettier/recommended']
13+
};
14+
15+
module.exports = config;

.github/workflows/actions/build-packages/action.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ description: Common setup steps used by our workflows
33
runs:
44
using: composite
55
steps:
6-
76
- name: Build packages
87
shell: bash
98
run: .github/workflows/actions/build-packages/entrypoint.sh

.github/workflows/actions/setup-yarn/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ runs:
55
steps:
66
- uses: actions/setup-node@v4
77
with:
8-
node-version-file: .node-version
8+
node-version-file: .nvmrc
99

1010
- uses: actions/setup-node@v4
1111
with:

.github/workflows/ci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ jobs:
1717

1818
- name: Build packages
1919
uses: ./.github/workflows/actions/build-packages
20+
21+
- name: Linters
22+
run: |
23+
yarn run prettier:lint
24+
yarn run eslint

.gitignore

-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
*.launch
88
.settings/
99
*.sublime-workspace
10-
/.vscode
11-
!.vscode/settings.json
12-
!.vscode/tasks.json
13-
!.vscode/launch.json
14-
!.vscode/extensions.json
1510
/.awcache
1611
/.angular
1712

.husky/commit-msg

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
yarn commitlint --config .commitlintrc.cjs --edit ${1}
4+
yarn commitlint --edit ${1}

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn lint-staged

.lintstagedrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
'*.{md,yml,json,js}': 'prettier --write',
3+
'*.js': 'eslint'
4+
};

.node-version .nvmrc

File renamed without changes.

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
/dist
3+
CHANGELOG.md

.prettierrc.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @ts-check
2+
3+
/**
4+
* @type {import('prettier').Options}
5+
*/
6+
const config = {
7+
printWidth: 120,
8+
tabWidth: 4,
9+
useTabs: false,
10+
singleQuote: true,
11+
trailingComma: 'none',
12+
overrides: [
13+
{
14+
files: ['*.yml'],
15+
options: {
16+
tabWidth: 2
17+
}
18+
}
19+
]
20+
};
21+
22+
module.exports = config;

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
3+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode"
3+
}

CONTRIBUTING.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ helpful.
1414

1515
Before you submit your pull request (PR) consider the following guidelines:
1616

17-
- Fork Design-tokens into your namespace by using the fork button on github.
18-
- Make your changes in a new git branch: `git checkout -b my-fix-branch master`
19-
- Create your bugfix/feature including appropriate tests.
20-
- Test your changes with our supported browsers.
21-
- Run unit tests and ensure that all tests pass.
22-
- Push your branch to GitHub.
23-
- Create a new pull request from your branch against the angular-components:master
24-
branch.
17+
- Fork Design-tokens into your namespace by using the fork button on github.
18+
- Make your changes in a new git branch: `git checkout -b my-fix-branch master`
19+
- Create your bugfix/feature including appropriate tests.
20+
- Test your changes with our supported browsers.
21+
- Run unit tests and ensure that all tests pass.
22+
- Push your branch to GitHub.
23+
- Create a new pull request from your branch against the angular-components:master
24+
branch.
2525

2626
## Commit message guidelines
2727

@@ -34,10 +34,11 @@ Before you submit your pull request (PR) consider the following guidelines:
3434
│ elements|forms|http|language-service|localize|platform-browser|
3535
│ platform-browser-dynamic|platform-server|router|service-worker|
3636
│ upgrade|zone.js|packaging|changelog|dev-infra|docs-infra|migrations|
37-
37+
3838
3939
└─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test
4040
```
41+
4142
Each commit message consists of a `type`, `scope` and `subject` (message).
4243
The `type` and `subject` are mandatory, the `scope` is optional in some specific
4344
cases. Format: `<type>(<scope>): <subject>`
@@ -46,17 +47,17 @@ cases. Format: `<type>(<scope>): <subject>`
4647

4748
Must be one of the following:
4849

49-
- **feat**: A new feature
50-
- **fix**: A bug fix
51-
- **docs**: Documentation only changes
52-
- **style**: Changes that do not affect the meaning of the code (white-space,
53-
formatting, missing semi-colons, etc)
54-
- **refactor**: A code change that neither fixes a bug nor adds a feature
55-
- **test**: Adding missing tests or correcting existing tests
56-
- **ci**: Changes that affect the CI
57-
- **build**: Changes that affect the build system like npm scripts or
58-
angular-cli related changes
59-
- **chore**: Other changes that don't modify src or test files
50+
- **feat**: A new feature
51+
- **fix**: A bug fix
52+
- **docs**: Documentation only changes
53+
- **style**: Changes that do not affect the meaning of the code (white-space,
54+
formatting, missing semi-colons, etc)
55+
- **refactor**: A code change that neither fixes a bug nor adds a feature
56+
- **test**: Adding missing tests or correcting existing tests
57+
- **ci**: Changes that affect the CI
58+
- **build**: Changes that affect the build system like npm scripts or
59+
angular-cli related changes
60+
- **chore**: Other changes that don't modify src or test files
6061

6162
### Scope
6263

@@ -100,7 +101,7 @@ BREAKING CHANGE: The method has been removed.
100101
Describe reasons.
101102
```
102103

103-
## Code reviews and PRs
104+
## Code reviews and PRs
104105

105106
### Open PR
106107

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## How to build a distribution with tokens
88

9-
- **Clone** this repository;
10-
- **Install** the packages using: `yarn install`
11-
- You can **build it** with this command: `yarn run build`
12-
- Then **find your distribution** in the following folder: `/dist`
9+
- **Clone** this repository;
10+
- **Install** the packages using: `yarn install`
11+
- You can **build it** with this command: `yarn run build`
12+
- Then **find your distribution** in the following folder: `/dist`

package.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
"author": "",
66
"license": "MIT",
77
"packageManager": "[email protected]",
8-
"engines": {
9-
"yarn": "^4.0.0",
10-
"node": ">=18.0.0"
11-
},
128
"keywords": [
139
"design-system",
1410
"design-tokens",
@@ -17,13 +13,17 @@
1713
"koobiq"
1814
],
1915
"scripts": {
20-
"prepare": "husky",
2116
"prebuild": "rimraf dist/",
2217
"build:index-common": "yarn run rollup dist/design-tokens/web/js/index.mjs --file dist/design-tokens/web/js/index.cjs --format cjs",
2318
"build": "node tools/build.js && yarn run build:index-common",
2419
"stage:commit": "koobiq-cli stage-commit -c \"Design Tokens\"",
2520
"release:publish:ci-github": "koobiq-cli publish-ci-github",
26-
"release:publish:ci-gitlab": "koobiq-cli publish-ci-gitlab"
21+
"release:publish:ci-gitlab": "koobiq-cli publish-ci-gitlab",
22+
"prettier": "prettier '**/*.{md,yml,json,js}'",
23+
"prettier:lint": "yarn run prettier --check",
24+
"prettier:fix": "yarn run prettier --list-different --write",
25+
"eslint": "eslint .",
26+
"eslint:fix": "yarn run eslint --fix"
2727
},
2828
"publishConfig": {
2929
"access": "public"
@@ -40,8 +40,13 @@
4040
"@koobiq/cli": "17.0.0-rc.5",
4141
"@types/fs-extra": "^11.0.4",
4242
"@types/node": "^18.19.31",
43+
"eslint": "^8.57.0",
44+
"eslint-config-prettier": "^9.1.0",
45+
"eslint-plugin-prettier": "^5.2.1",
4346
"fs-extra": "^11.2.0",
4447
"husky": "^9.0.11",
48+
"lint-staged": "^15.2.7",
49+
"prettier": "^3.3.3",
4550
"rimraf": "^5.0.5",
4651
"rollup": "^4.17.2",
4752
"style-dictionary": "^3.9.2"

packages/design-tokens/README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ visual system for UI development and brand consistency.
77
Koobiq design tokens store the visual design attributes that define the
88
visual language, including color, typography, and spacing we use.
99

10-
1110
Design tokens are key-value pairs. For example:
11+
1212
```
1313
Key: value;
1414
$card-dark-success-background: #276211;
1515
```
16-
- The key name defines the usage or how to apply the value to a specific context, such as using text on a light background
17-
- The key stores visual design attributes
18-
- The key replaces hard-coded values, such as hex values for color or pixel values for spacing
19-
2016

17+
- The key name defines the usage or how to apply the value to a specific context, such as using text on a light background
18+
- The key stores visual design attributes
19+
- The key replaces hard-coded values, such as hex values for color or pixel values for spacing

packages/tokens-builder/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Tokens Builder
22

33
## Overview
4+
45
Tokens builder is a configuration script that utilizes Style Dictionary,
5-
a design-token platform for creating and maintaining consistent design tokens across various platforms.
6+
a design-token platform for creating and maintaining consistent design tokens across various platforms.
67

78
Overall, this script orchestrates the generation of design tokens by applying custom transformations,
89
filters, and formats to the specified theme configuration for multiple platforms,
910
facilitating a streamlined design token workflow compatible with
1011
various output formats like SCSS, CSS, and TypeScript.
11-

packages/tokens-builder/build.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ require('./formats/variables')(StyleDictionary);
3030
console.log('Build started...');
3131
console.log('==============================================');
3232

33-
3433
module.exports = (themeConfig) => {
3534
StyleDictionary.registerFileHeader({
3635
name: 'customHeader',
@@ -40,14 +39,14 @@ module.exports = (themeConfig) => {
4039

4140
if (!themeConfig || themeConfig.length === 0) {
4241
console.error('Build Failed. Please set ThemeConfig, for example: ', {
43-
name: 'default-theme',
44-
buildPath: [
45-
`design-tokens/tokens/properties/**/*.json5`,
46-
`design-tokens/tokens/components/**/*.json5`
47-
],
48-
outputPath: 'design-tokens/'
49-
}
50-
)
42+
name: 'default-theme',
43+
// prettier-ignore
44+
buildPath: [
45+
`design-tokens/tokens/properties/**/*.json5`,
46+
`design-tokens/tokens/components/**/*.json5`
47+
],
48+
outputPath: 'design-tokens/'
49+
});
5150
process.exit(0);
5251
}
5352

@@ -63,4 +62,4 @@ module.exports = (themeConfig) => {
6362

6463
console.log('\n==============================================');
6564
console.log('\nBuild completed!');
66-
}
65+
};

packages/tokens-builder/configs/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ const filterObj = {
1313
function filterOptions(platforms) {
1414
const platformObj = {};
1515

16-
platforms.map(p => Object.assign(platformObj, p));
16+
platforms.map((p) => Object.assign(platformObj, p));
1717

1818
Object.keys(platformObj).forEach((p) => {
19-
platformObj[p].files = platformObj[p].files.map(f => ({
19+
platformObj[p].files = platformObj[p].files.map((f) => ({
2020
...f,
2121
...filterObj,
2222
options: {
23-
...f.options ?? {},
23+
...(f.options ?? {}),
2424
...filterObj.options
2525
}
2626
}));
@@ -30,7 +30,7 @@ function filterOptions(platforms) {
3030
}
3131

3232
function getSources(theme) {
33-
return theme.buildPath.map(pathName => {
33+
return theme.buildPath.map((pathName) => {
3434
if (pathName.startsWith('@')) {
3535
return join('node_modules', pathName);
3636
}
@@ -48,7 +48,6 @@ function getConfigs(theme) {
4848
}
4949

5050
module.exports = (theme) => {
51-
5251
return {
5352
source: [...getSources(theme)],
5453
platforms: getConfigs(theme)

packages/tokens-builder/configs/js.js

-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ module.exports = {
1313
]
1414
}
1515
};
16-
+3-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
module.exports = (StyleDictionary) => {
2-
32
StyleDictionary.registerFilter({
43
name: 'color',
5-
matcher: (prop) => !prop.attributes.palette &&
6-
!prop.attributes.typography &&
7-
!prop.attributes['md-typography']
8-
})
9-
}
4+
matcher: (prop) => !prop.attributes.palette && !prop.attributes.typography && !prop.attributes['md-typography']
5+
});
6+
};

0 commit comments

Comments
 (0)