Skip to content

Commit

Permalink
refactor(commitlint): add defineConfig (#136)
Browse files Browse the repository at this point in the history
Co-authored-by: Almanov Nikita <131481562+nikkeyl@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and nikkeyl authored Mar 20, 2024
1 parent 1497aa9 commit 102b9cf
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 363 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ name: Commit Lint

on:
pull_request:
branches-ignore:
- dependabot/*
push:
branches-ignore:
- dependabot/*

jobs:
commit-lint:
Expand All @@ -11,11 +15,23 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10

if: ${{ github.actor != 'dependabot[bot]' }}

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set Up PNPM
uses: pnpm/action-setup@v3
with:
version: 8

- name: Set Up NodeJS
uses: actions/setup-node@v4
with:
cache: pnpm
node-version: lts/*

- name: Install Dependencies
run: pnpm i

- name: Lint
uses: wagoid/commitlint-github-action@v5
43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
- Extends the [`stylelint-config-standard-scss` shared config](https://github.com/stylelint-scss/stylelint-config-standard-scss)
and configures it's rules for **SCSS**.

- [`stylelint-prettier/recommended`](https://github.com/prettier/stylelint-prettier):
Runs **Prettier** to format **SCSS** code.

### Plugins

- [`stylelint-declaration-block-no-ignored-properties`](https://github.com/kristerkari/stylelint-declaration-block-no-ignored-properties):
Expand Down Expand Up @@ -72,10 +75,6 @@
- [`stylelint-plugin-logical-css`](https://github.com/yuschick/stylelint-plugin-logical-css):
Replace properties with logical alternatives.

- [`stylelint-prettier`](https://github.com/prettier/stylelint-prettier):
Runs **Prettier** as a **Stylelint** rule and reports
differences as individual **Stylelint** issues.

## Installation

```shell
Expand All @@ -95,24 +94,46 @@ yarn add -D @archoleat/stylelint-config-extended-scss

## Usage

> \[!TIP]
> We recommend setting `stylelint-define-config` for property suggestions.
>
> ```shell
> # pnpm
> pnpm i -D stylelint-define-config
> ```
>
> ```shell
> # npm
> npm i -D stylelint-define-config
> ```
>
> ```shell
> # yarn
> yarn add -D stylelint-define-config
> ```
```js
// stylelint.config.js
export default {
import { defineConfig } from 'stylelint-define-config';
export default defineConfig({
extends: '@archoleat/stylelint-config-extended-scss',
};
});
```
### Extending the Config
```js
// stylelint.config.js
export default {
import { defineConfig } from 'stylelint-define-config';
export default defineConfig({
extends: '@archoleat/stylelint-config-extended-scss',
rules: {
'selector-max-compound-selectors': 4,
'value-no-vendor-prefix': false,
},
};
});
```
## Add the Space Between Logical Groups
Expand All @@ -122,12 +143,14 @@ add this rule to your **Stylelint** config:
```js
// stylelint.config.js
export default {
import { defineConfig } from 'stylelint-define-config';
export default defineConfig({
extends: '@archoleat/stylelint-config-extended-scss',
rules: {
'declaration-empty-line-before': null,
},
};
});
```
### Before
Expand Down
27 changes: 22 additions & 5 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import type { UserConfig } from '@commitlint/types';
import { defineConfig } from '@archoleat/commitlint-define-config';

const commitLintConfig: UserConfig = {
export default defineConfig({
extends: ['@commitlint/config-conventional'],
};

export default commitLintConfig;
rules: {
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'spec',
'style',
],
],
},
});
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
"type": "module",
"types": "index.d.ts",
"exports": {
".": "./index.js",
"./*": "./commitlint.config.ts"
".": "./index.js"
},
"files": [
"index.d.ts",
Expand Down Expand Up @@ -87,10 +86,10 @@
"stylelint-prettier": "^5.0.0"
},
"devDependencies": {
"@archoleat/commitlint-define-config": "^1.0.0",
"@archoleat/semantic-release-define-config": "^1.1.0",
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.3",
"@commitlint/types": "^18.6.1",
"@commitlint/config-conventional": "^19.1.0",
"@rollup/plugin-typescript": "^11.1.6",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
Expand Down
Loading

0 comments on commit 102b9cf

Please sign in to comment.