@kitschpatrol/eslint-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 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(`[ESLint] 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 $`eslint --fix .`;
24
+ } else if (args.check) {
25
+ await $`eslint .`;
26
+ }
27
+ }
28
+
29
+ await main();
package/main.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  // eslint-disable-next-line no-undef
2
+ /* @type {import('eslint').Linter.Config} */
2
3
  module.exports = {
3
- // env: {
4
- // browser: true,
5
- // es2017: true,
6
- // node: true,
7
- // },
4
+ env: {
5
+ browser: true,
6
+ node: true,
7
+ },
8
8
  extends: [
9
9
  'eslint:recommended',
10
10
  'plugin:@typescript-eslint/recommended',
@@ -69,6 +69,8 @@ module.exports = {
69
69
  {
70
70
  allowList: {
71
71
  Props: true,
72
+ props: true,
73
+ args: true,
72
74
  },
73
75
  },
74
76
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitschpatrol/eslint-config",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "description": "Eslint config for @kitschpatrol/shared-config",
6
6
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "pnpm": ">=8.0.0"
24
24
  },
25
25
  "bin": {
26
- "eslint-config-init": "./init.js"
26
+ "eslint-config": "./cli.js"
27
27
  },
28
28
  "main": "main.cjs",
29
29
  "peerDependencies": {
@@ -38,7 +38,9 @@
38
38
  "eslint-plugin-jsx-a11y": "^6.8.0",
39
39
  "eslint-plugin-perfectionist": "^2.5.0",
40
40
  "eslint-plugin-svelte": "^2.35.1",
41
- "eslint-plugin-unicorn": "^49.0.0"
41
+ "eslint-plugin-unicorn": "^49.0.0",
42
+ "minimist": "^1.2.8",
43
+ "zx": "^7.2.3"
42
44
  },
43
45
  "publishConfig": {
44
46
  "access": "public"
package/readme.md CHANGED
@@ -19,26 +19,28 @@ To use just this ESLint config in isolation:
19
19
  2. Add the package:
20
20
 
21
21
  ```sh
22
- pnpm add @kitschpatrol/eslint-config
22
+ pnpm add -D @kitschpatrol/eslint-config
23
23
  ```
24
24
 
25
25
  3. Add the starter `.eslintrc.cjs` config and `.eslintignore` files to your project root, and add any overrides you'd like:
26
26
 
27
27
  ```sh
28
- pnpm exec eslint-config-init
28
+ pnpm exec eslint-config --init
29
29
  ```
30
30
 
31
31
  ## Usage
32
32
 
33
33
  The ESLint 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": "eslint ."
41
- "fix": "eslint --fix ."
42
+ "lint": "eslint-config --check"
43
+ "fix": "eslint-config --fix"
42
44
  }
43
45
  ...
44
46
  ```
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
- }