@kitschpatrol/eslint-config 2.1.0 → 2.2.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/bin/cli.js CHANGED
@@ -1,13 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import x from"chalk";import{execa as w}from"execa";import O from"meow";import u from"node:path";import{Transform as A}from"node:stream";import{fileURLToPath as S}from"node:url";import{packageUp as k}from"package-up";function $(o,n){return new A({transform(t,e,i){let s=t.toString().split(/\r?\n/).filter(l=>l.trim().length>0).map(l=>`${o?x[n]("["+o+"] "):""}${l}`).join(`
2
+ import F from"chalk";import{execa as x}from"execa";import O from"meow";import d from"node:path";import{Transform as A}from"node:stream";import{fileURLToPath as S}from"node:url";import{packageUp as k}from"package-up";function $(o,t){return new A({transform(n,e,i){let m=n.toString().split(/\r?\n/).filter(l=>l.trim().length>0).map(l=>`${o?F[t]("["+o+"] "):""}${l}`).join(`
3
3
  `)+`
4
- `;this.push(s),i()}})}function j(o,n){let t=`
4
+ `;this.push(m),i()}})}function N(o,t){let n=`
5
5
  Usage
6
6
  $ ${o} [<file|glob> ...]
7
- `;if(Object.keys(n).length>0){t+=`
8
- Options`;for(let e of Object.keys(n))switch(e){case"init":{t+=`
9
- --init, -i Initialize by copying starter config files to your project root.`;break}case"check":{t+=`
10
- --check, -c Check for and report issues. Same as ${o}.`;break}case"fix":{t+=`
11
- --fix, -f Fix all auto-fixable issues, and report the un-fixable.`;break}case"printConfig":{t+=`
12
- --print-config <file> Print the effective configuration for a file`;break}default:console.error(`Unknown command name: ${e}`)}}return t}function N(o){return Object.keys(o).reduce((n,t)=>{let e={};switch(t){case"init":{e={shortFlag:"i",type:"boolean"};break}case"check":{e={aliases:["lint",""],shortFlag:"l",type:"boolean"};break}case"fix":{e={shortFlag:"f",type:"boolean"};break}case"printConfig":{e={type:"boolean"};break}default:console.error(`Unknown command name: ${t}`)}return n[t]=e,n},{})}async function y(o,n,t=[]){if(n.command!==void 0&&typeof n.command=="string"){let e;try{let i=w(n.command,[...n.options??[],...t],{env:{FORCE_COLOR:"true"},stdin:"inherit"});i.stdout?.pipe(o,{end:!1}),await i,e=i.exitCode??1}catch(i){e=typeof i.exitCode=="number"?i.exitCode:1}return e}return console.error(`Invalid optionCommand: ${JSON.stringify(n,void 0,2)}`),1}function h(o,n){o.length===0&&!n.defaultArguments&&(console.error("This command must be used with a file argument"),process.exit(1))}async function C(o,n,t,e){let i=O(j(o,e),{allowUnknownFlags:!1,booleanDefault:void 0,flags:N(e),importMeta:import.meta}),{flags:d,input:s}=i,l=Object.keys(e).reduce((c,r)=>(d[r]&&(c[r]=e[r]),c),{});Object.keys(l).length===0&&(l.check=e.check);let m=$(n,t);m.pipe(process.stdout);let a=0;for(let[c,r]of Object.entries(l))if(typeof r.command=="function"){h(s,r);let f=s.length===0?r.defaultArguments??[]:s,g=r.options??[];a+=await r.command(m,f,g)}else if(typeof r.command=="string")h(s,r),a+=await y(m,r,s.length===0?r.defaultArguments:s);else switch(c){case"init":{let f=await k();if(f===void 0){console.error("The `--init` flag must be used in a directory with a package.json file"),a+=1;break}let g=await k({cwd:S(import.meta.url)});if(g===void 0){console.error("The script being called was not in a package, weird."),a+=1;break}let p=u.join(u.dirname(g),"init/"),b=u.dirname(f);console.log(`Copying initial configuration files from:
13
- "${p}" \u2192 "${b}"`);let F={command:"cp",options:["-Ri",`${p}`,`${b}`]};a+=await y(m,F);break}case"check":{console.error("No default implementation for check"),a+=1;break}case"fix":{console.error("No default implementation for fix"),a+=1;break}case"printConfig":{console.error("No default implementation for print-config"),a+=1;break}default:{console.error(`Unknown command name: ${c}`),a+=1;break}}process.exit(a>0?1:0)}await C("eslint-config","ESLint","magenta",{check:{command:"eslint",defaultArguments:["."]},fix:{command:"eslint",defaultArguments:["."],options:["--fix"]},init:{},printConfig:{command:"eslint",options:["--print-config"]}});
7
+ `;if(Object.keys(t).length>0){n+=`
8
+ Options`;for(let e of Object.keys(t))switch(e){case"init":{n+=`
9
+ --init, -i Initialize by copying starter config files to your project root.`;break}case"check":{n+=`
10
+ --check, -c Check for and report issues. Same as ${o}.`;break}case"fix":{n+=`
11
+ --fix, -f Fix all auto-fixable issues, and report the un-fixable.`;break}case"printConfig":{n+=`
12
+ --print-config <file> Print the effective configuration for a file`;break}default:console.error(`Unknown command name: ${e}`)}}return n}function j(o){return Object.keys(o).reduce((t,n)=>{let e={};switch(n){case"init":{e={shortFlag:"i",type:"boolean"};break}case"check":{e={aliases:["lint",""],shortFlag:"l",type:"boolean"};break}case"fix":{e={shortFlag:"f",type:"boolean"};break}case"printConfig":{e={type:"boolean"};break}default:console.error(`Unknown command name: ${n}`)}return t[n]=e,t},{})}async function y(o,t,n=[]){if(t.command!==void 0&&typeof t.command=="string"){let e;try{let i=x(t.command,[...t.options??[],...n],{env:{FORCE_COLOR:"true"},stdin:"inherit"});i.stdout?.pipe(o,{end:!1}),i.stderr?.pipe(o,{end:!1}),await i,e=i.exitCode??1}catch(i){e=typeof i.exitCode=="number"?i.exitCode:1}return e}return o.write(`Error: Invalid optionCommand: ${JSON.stringify(t,void 0,2)}`),1}function h(o,t,n){o.length===0&&!t.defaultArguments&&(n.write(`Error: This command must be used with a file argument
13
+ `),process.exit(1))}async function C(o,t,n,e){let i=O(N(o,e),{allowUnknownFlags:!1,booleanDefault:void 0,flags:j(e),importMeta:import.meta}),{flags:u,input:m}=i,l=Object.keys(e).reduce((c,r)=>(u[r]&&(c[r]=e[r]),c),{});Object.keys(l).length===0&&(l.check=e.check);let s=$(t,n);s.pipe(process.stdout);let a=0;for(let[c,r]of Object.entries(l))if(typeof r.command=="function"){h(m,r,s);let f=m.length===0?r.defaultArguments??[]:m,g=r.options??[];a+=await r.command(s,f,g)}else if(typeof r.command=="string")h(m,r,s),a+=await y(s,r,m.length===0?r.defaultArguments:m);else switch(c){case"init":{let f=await k();if(f===void 0){s.write("Error: The `--init` flag must be used in a directory with a package.json file\n"),a+=1;break}let g=await k({cwd:S(import.meta.url)});if(g===void 0){s.write(`Error: The script being called was not in a package, weird.
14
+ `),a+=1;break}let p=d.join(d.dirname(g),"init/"),b=d.dirname(f);s.write(`Copying initial configuration files from:
15
+ "${p}" \u2192 "${b}"
16
+ `);let w={command:"cp",options:["-Ri",`${p}`,`${b}`]};a+=await y(s,w);break}case"check":{console.error("No default implementation for check"),a+=1;break}case"fix":{console.error("No default implementation for fix"),a+=1;break}case"printConfig":{console.error("No default implementation for print-config"),a+=1;break}default:{console.error(`Unknown command name: ${c}`),a+=1;break}}process.exit(a>0?1:0)}await C("eslint-config","ESLint","magenta",{check:{command:"eslint",defaultArguments:["."]},fix:{command:"eslint",defaultArguments:["."],options:["--fix"]},init:{},printConfig:{command:"eslint",options:["--print-config"]}});
@@ -1,3 +1,5 @@
1
1
  module.exports = {
2
2
  extends: ['@kitschpatrol/eslint-config'],
3
+ root: true,
4
+ // Overrides
3
5
  };
package/main.cjs CHANGED
@@ -1,15 +1,15 @@
1
- /* @type {import('eslint').Linter.Config} */
2
-
3
1
  const extendsPrefix = [
4
2
  'eslint:recommended',
5
3
  'plugin:n/recommended',
6
4
  'plugin:unicorn/recommended',
5
+ 'plugin:mdx/recommended', // Run over all files because it can lint comments
7
6
  'xo',
8
7
  'plugin:perfectionist/recommended-natural',
9
8
  ];
10
9
 
11
10
  const extendsSuffix = ['prettier'];
12
11
 
12
+ /* @type {import('eslint').Linter.Config} */
13
13
  const rulesConfig = {
14
14
  // Possible perfectionist conflicts
15
15
  '@typescript-eslint/adjacent-overload-signatures': 'off',
@@ -47,6 +47,12 @@ module.exports = {
47
47
  },
48
48
  extends: [...extendsPrefix, ...extendsSuffix],
49
49
  overrides: [
50
+ {
51
+ extends: [...extendsPrefix, ...extendsSuffix],
52
+ files: ['*.md', '*.mdx'],
53
+ parser: 'eslint-mdx',
54
+ rules: rulesConfig,
55
+ },
50
56
  {
51
57
  extends: [...extendsPrefix, 'plugin:@typescript-eslint/recommended', 'xo-typescript', ...extendsSuffix],
52
58
  files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
@@ -99,4 +105,7 @@ module.exports = {
99
105
  },
100
106
  ],
101
107
  rules: rulesConfig,
108
+ settings: {
109
+ 'mdx/code-blocks': true,
110
+ },
102
111
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitschpatrol/eslint-config",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "description": "Eslint config for @kitschpatrol/shared-config",
6
6
  "repository": {
@@ -43,13 +43,15 @@
43
43
  "eslint-config-xo-typescript": "^1.0.1",
44
44
  "eslint-plugin-astro": "^0.30.0",
45
45
  "eslint-plugin-jsx-a11y": "^6.8.0",
46
+ "eslint-plugin-mdx": "^3.0.0",
46
47
  "eslint-plugin-n": "^16.4.0",
47
48
  "eslint-plugin-perfectionist": "^2.5.0",
48
49
  "eslint-plugin-svelte": "^2.35.1",
49
50
  "eslint-plugin-unicorn": "^49.0.0",
50
51
  "execa": "^8.0.1",
51
52
  "meow": "^12.1.1",
52
- "package-up": "^5.0.0"
53
+ "package-up": "^5.0.0",
54
+ "up": "^1.0.2"
53
55
  },
54
56
  "publishConfig": {
55
57
  "access": "public"