Skip to content

Commit

Permalink
feat: add lint-staged config
Browse files Browse the repository at this point in the history
  • Loading branch information
shijistar committed Feb 6, 2025
1 parent 0c835cb commit cddeec3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
module.exports = require('./').configs.recommended;
module.exports = require('./eslint/config/recommended');
14 changes: 2 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,8 @@

## v1.0.0

`2025-02-05`
`2025-02-06`

### Features

- Provide the following `eslint` presets:
- `@tiny-codes/code-style-all-in-one/eslint/config/recommended`
- `@tiny-codes/code-style-all-in-one/eslint/config/react`
- `@tiny-codes/code-style-all-in-one/eslint/config/next`
- `@tiny-codes/code-style-all-in-one/eslint/config/base`
- `@tiny-codes/code-style-all-in-one/eslint/config/base-typescript`
- Provide `prettier` configuration
- `@tiny-codes/eslint-config-all-in-one/prettier/config`
- Provide `stylelint` configuration
- `@tiny-codes/eslint-config-all-in-one/stylelint/config`
- Provide `husky` configuration, please refer to the [README.md](./README.md) document
- Provide a series of code style configurations for `eslint`, `stylelint`, `prettier` and configurations for `husky`, `lint-staged`, and `commitlint`
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ Add `husky` related configuration in `package.json`:
"scripts": {
"prepare": "husky"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,vue}": "eslint --fix",
"*.{css,less,scss}": "stylelint --fix",
"*.{js,jsx,ts,tsx,vue,md,json,css,less,scss}": "prettier --write"
},
```

Add the following two files to the `.husky` directory:
Expand All @@ -126,6 +121,16 @@ _.husky/commit-msg_
. "node_modules/@tiny-codes/code-style-all-in-one/husky/hooks/commit-msg.sh"
```

### Lint-staged configuration

Create a `lint-staged.config` file in the project root directory with the following configuration:

_lint-staged.config_

```js
module.exports = require('@tiny-codes/code-style-all-in-one/lint-staged/config');
```

### Commitlint configuration

Create a `.commitlintrc.js` file in the project root directory with the following configuration:
Expand Down
31 changes: 0 additions & 31 deletions index.js

This file was deleted.

2 changes: 2 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
module.exports = require('./lint-staged/config');
7 changes: 3 additions & 4 deletions lint-staged/config/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** @type {Exclude<import('lint-staged').Config, import('lint-staged').ConfigFn>} */
module.exports = {
'*.{md,json}': ['prettier --cache --write'],
'*.{js,jsx}': ['max lint --fix --eslint-only', 'prettier --cache --write'],
'*.{css,less}': ['max lint --fix --stylelint-only', 'prettier --cache --write'],
'*.ts?(x)': ['max lint --fix --eslint-only', 'prettier --cache --parser=typescript --write'],
'*.{js,jsx,ts,tsx,vue}': 'eslint --fix',
'*.{css,less,scss}': 'stylelint --fix',
'*.{js,jsx,ts,tsx,vue,md,json,css,less,scss}': 'prettier --write',
};
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
"scripts": {
"prepare": "husky"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,vue}": "eslint --fix",
"*.{css,less,scss}": "stylelint --fix",
"*.{js,jsx,ts,tsx,vue,md,json,css,less,scss}": "prettier --write"
},
"dependencies": {
"@babel/eslint-parser": "^7.24.6",
"@commitlint/cli": "^19.3.0",
Expand Down

0 comments on commit cddeec3

Please sign in to comment.