@kitschpatrol/stylelint-config 1.0.0 → 2.0.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/cli.js +29 -0
- package/package.json +5 -3
- package/readme.md +10 -4
- package/init.js +0 -22
package/cli.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env zx
|
|
2
|
+
/* eslint-disable unicorn/prefer-module */
|
|
3
|
+
import minimist from 'minimist';
|
|
4
|
+
import { $, path } from 'zx';
|
|
5
|
+
import 'zx/globals';
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
const options = ['init', 'fix', 'check'];
|
|
9
|
+
const args = minimist(process.argv.slice(2), {
|
|
10
|
+
boolean: options,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const argumentCount = options.reduce((count, argument) => count + (args[argument] ? 1 : 0), 0);
|
|
14
|
+
if (argumentCount !== 1) {
|
|
15
|
+
console.error(`[Stylelint] Please provide exactly one of ${options.map((opt) => `--${opt}`).join(' or ')}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
process.env.FORCE_COLOR = '1';
|
|
20
|
+
if (args.init) {
|
|
21
|
+
await $`cp -Ri ${path.join(__dirname, 'init')}/. ${process.cwd()}`.nothrow();
|
|
22
|
+
} else if (args.fix) {
|
|
23
|
+
await $`stylelint --ignore-path .gitignore --allow-empty-input "**/*.{css,scss,sass,svelte,html,astro}" --fix`;
|
|
24
|
+
} else if (args.check) {
|
|
25
|
+
await $`stylelint --ignore-path .gitignore --allow-empty-input "**/*.{css,scss,sass,svelte,html,astro}"`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/stylelint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Stylelint config for @kitschpatrol/shared-config",
|
|
6
6
|
"repository": {
|
|
@@ -23,16 +23,18 @@
|
|
|
23
23
|
"pnpm": ">=8.0.0"
|
|
24
24
|
},
|
|
25
25
|
"bin": {
|
|
26
|
-
"stylelint-config
|
|
26
|
+
"stylelint-config": "./cli.js"
|
|
27
27
|
},
|
|
28
28
|
"main": "main.cjs",
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"stylelint": "^15.11.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"minimist": "^1.2.8",
|
|
33
34
|
"stylelint-config-clean-order": "^5.2.0",
|
|
34
35
|
"stylelint-config-html": "^1.1.0",
|
|
35
|
-
"stylelint-config-standard": "^34.0.0"
|
|
36
|
+
"stylelint-config-standard": "^34.0.0",
|
|
37
|
+
"zx": "^7.2.3"
|
|
36
38
|
},
|
|
37
39
|
"publishConfig": {
|
|
38
40
|
"access": "public"
|
package/readme.md
CHANGED
|
@@ -19,26 +19,32 @@ To use just this Stylelint config in isolation:
|
|
|
19
19
|
2. Add the package:
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
|
-
pnpm add @kitschpatrol/stylelint-config
|
|
22
|
+
pnpm add -D @kitschpatrol/stylelint-config
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
3. Add the starter `.stylelintrc.cjs` file to your project root, and add any customizations you'd like:
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
|
-
pnpm exec stylelint-config
|
|
28
|
+
pnpm exec stylelint-config --init
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
32
32
|
|
|
33
33
|
The Stylelint binary should be picked up automatically by VSCode plugins.
|
|
34
34
|
|
|
35
|
+
You can call it directly, or use the script bundled with the config.
|
|
36
|
+
|
|
35
37
|
Integrate with your `package.json` scripts as you see fit, for example:
|
|
36
38
|
|
|
37
39
|
```json
|
|
38
40
|
...
|
|
39
41
|
"scripts": {
|
|
40
|
-
"lint": "stylelint --
|
|
41
|
-
"format": "stylelint
|
|
42
|
+
"lint": "stylelint-config --check"
|
|
43
|
+
"format": "stylelint-config --fix"
|
|
42
44
|
}
|
|
43
45
|
...
|
|
44
46
|
```
|
|
47
|
+
|
|
48
|
+
## Notes
|
|
49
|
+
|
|
50
|
+
Ignores files in `.gitignore`
|
package/init.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import console from 'node:console';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import process from 'node:process';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
|
|
9
|
-
const sourceDirectory = path.join(__dirname, 'init');
|
|
10
|
-
const destinationDirectory = process.cwd(); // (project root)
|
|
11
|
-
|
|
12
|
-
for (const file of fs.readdirSync(sourceDirectory)) {
|
|
13
|
-
const sourcePath = path.join(sourceDirectory, file);
|
|
14
|
-
const destinationPath = path.join(destinationDirectory, file);
|
|
15
|
-
|
|
16
|
-
if (fs.existsSync(destinationPath)) {
|
|
17
|
-
console.log(`${file} already exists in project root, skipping.`);
|
|
18
|
-
} else {
|
|
19
|
-
fs.copyFileSync(sourcePath, destinationPath);
|
|
20
|
-
console.log(`Copied ${file} to project root.`);
|
|
21
|
-
}
|
|
22
|
-
}
|