@theholocron/lint-staged-config 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +40 -0
- package/lint-staged.config.js +15 -0
- package/package.json +29 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Lint Staged Config
|
|
2
|
+
|
|
3
|
+
A [Lint Staged configuration](https://github.com/okonet/lint-staged#configuration) for linting code that has been staged in Git within the Galaxy.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev @theholocron/lint-staged-config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
In your project `.husky/pre-commit` add the following:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# .husky/pre-commit
|
|
17
|
+
npx lint-staged --config @theholocron/lint-staged-config
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## How We Manage Git Hooks
|
|
21
|
+
|
|
22
|
+
This library uses [husky](https://github.com/typicode/husky) for managing Git hooks and extends that with `lint-staged`. This means we can run automated tasks on any file that is placed on the Git stage. Currently that means we run the following commands on various types of code:
|
|
23
|
+
|
|
24
|
+
### [TJ]S(X)
|
|
25
|
+
|
|
26
|
+
First we run all suffixed files through `prettier` with the `--write` flag in order to format and fix all style issues.
|
|
27
|
+
|
|
28
|
+
Then we use `eslint` to check for any glaring code issues.
|
|
29
|
+
|
|
30
|
+
Lastly, we run it through `tsc` in order to check for any type errors.
|
|
31
|
+
|
|
32
|
+
If all things pass, then you'll proceed to commit.
|
|
33
|
+
|
|
34
|
+
### (S)CSS
|
|
35
|
+
|
|
36
|
+
We use `stylelint` with the `--fix` flag on any staged files.
|
|
37
|
+
|
|
38
|
+
### Images
|
|
39
|
+
|
|
40
|
+
We run `imagin-lint-staged` in order to compress any images that may show up on the staging area in order to reduce the size.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://github.com/lint-staged/lint-staged?tab=readme-ov-file#configuration
|
|
3
|
+
* @type {import("lint-staged").Config}
|
|
4
|
+
*/
|
|
5
|
+
export default {
|
|
6
|
+
"*.{ts,tsx,js,jsx}": [
|
|
7
|
+
"prettier --write",
|
|
8
|
+
"eslint --ignore-path .gitignore",
|
|
9
|
+
"tsc --noEmit",
|
|
10
|
+
],
|
|
11
|
+
"*.css": "stylelint --fix",
|
|
12
|
+
"*.scss": "stylelint --syntax=scss --fix",
|
|
13
|
+
"*.{png,jpeg,jpg,gif,svg}": "imagemin-lint-staged",
|
|
14
|
+
"package.json": "sort-package-json",
|
|
15
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theholocron/lint-staged-config",
|
|
3
|
+
"homepage": "https://github.com/the-holocron/configs/tree/master/packages/lint-staged-config#readme",
|
|
4
|
+
"description": "A Lint Staged configuration for linting code that has been staged in Git within the Galaxy.",
|
|
5
|
+
"author": "Newton Koumantzelis",
|
|
6
|
+
"version": "1.16.0",
|
|
7
|
+
"main": "lint-staged.config.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/theholocron/configs.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": "https://github.com/theholocron/configs/issues",
|
|
14
|
+
"releases": "https://github.com/theholocron/configs/releases",
|
|
15
|
+
"wiki": "https://github.com/theholocron/configs/wiki",
|
|
16
|
+
"license": "GPL-3.0",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"prepare": "husky"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"husky": "^9.1.6",
|
|
25
|
+
"imagemin-lint-staged": "^0.5.1",
|
|
26
|
+
"lint-staged": "^15.2.10",
|
|
27
|
+
"sort-package-json": "^2.10.1"
|
|
28
|
+
}
|
|
29
|
+
}
|