@anolilab/lint-staged-config 2.0.15 → 2.1.1
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 +19 -0
- package/README.md +68 -0
- package/dist/chunk-AVDVT4B7.mjs +7 -0
- package/dist/chunk-AVDVT4B7.mjs.map +1 -0
- package/dist/chunk-DVFT7GIT.js +12 -0
- package/dist/chunk-DVFT7GIT.js.map +1 -0
- package/dist/chunk-GTUWYYHD.mjs +18 -0
- package/dist/chunk-GTUWYYHD.mjs.map +1 -0
- package/dist/chunk-H67RQHXB.mjs +10 -0
- package/dist/chunk-H67RQHXB.mjs.map +1 -0
- package/dist/chunk-OHF7NDU3.js +20 -0
- package/dist/chunk-OHF7NDU3.js.map +1 -0
- package/dist/chunk-OYUEMN5Q.js +9 -0
- package/dist/chunk-OYUEMN5Q.js.map +1 -0
- package/dist/groups/eslint/index.js +3 -2
- package/dist/groups/eslint/index.mjs +2 -1
- package/dist/groups/typescript.js +3 -2
- package/dist/groups/typescript.mjs +2 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-2ADQIOER.mjs +0 -9
- package/dist/chunk-2ADQIOER.mjs.map +0 -1
- package/dist/chunk-LROKPUXN.js +0 -11
- package/dist/chunk-LROKPUXN.js.map +0 -1
- package/dist/chunk-SAPGJRYB.js +0 -20
- package/dist/chunk-SAPGJRYB.js.map +0 -1
- package/dist/chunk-UFMJP5NU.mjs +0 -17
- package/dist/chunk-UFMJP5NU.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## @anolilab/lint-staged-config [2.1.1](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@2.1.0...@anolilab/lint-staged-config@2.1.1) (2023-10-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fixed exclude checking ([461c524](https://github.com/anolilab/javascript-style-guide/commit/461c524c548295e141cc3216dc4a055494532b84))
|
|
7
|
+
|
|
8
|
+
## @anolilab/lint-staged-config [2.1.0](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@2.0.15...@anolilab/lint-staged-config@2.1.0) (2023-10-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* added new config to disable tsc checking, added new docs for eslint and tsc ([40581ab](https://github.com/anolilab/javascript-style-guide/commit/40581ab6c5f3a2c6e120c1d3be6883eb10c3c550))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Miscellaneous Chores
|
|
17
|
+
|
|
18
|
+
* **deps:** update dependency type-fest to ^4.4.0 ([#771](https://github.com/anolilab/javascript-style-guide/issues/771)) ([8046ba7](https://github.com/anolilab/javascript-style-guide/commit/8046ba7c65f96342fbf46e3ee08bcdfa20c08af1))
|
|
19
|
+
|
|
1
20
|
## @anolilab/lint-staged-config [2.0.15](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@2.0.14...@anolilab/lint-staged-config@2.0.15) (2023-10-05)
|
|
2
21
|
|
|
3
22
|
|
package/README.md
CHANGED
|
@@ -79,6 +79,74 @@ module.exports = {
|
|
|
79
79
|
...config,
|
|
80
80
|
};
|
|
81
81
|
```
|
|
82
|
+
### Config
|
|
83
|
+
|
|
84
|
+
You can configure `@anolilab/lint-staged-config` options with your `package.json` file.
|
|
85
|
+
|
|
86
|
+
Add this property to your package.json:
|
|
87
|
+
|
|
88
|
+
```json5
|
|
89
|
+
{
|
|
90
|
+
anolilab: {
|
|
91
|
+
"lint-staged-config": {
|
|
92
|
+
// ...options
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### typescript
|
|
99
|
+
|
|
100
|
+
Type: `object`
|
|
101
|
+
|
|
102
|
+
Options:
|
|
103
|
+
- `exclude` - Exclude files from tsc linting. Provide the path to the tsconfig.json file.
|
|
104
|
+
- Type: `string[]`
|
|
105
|
+
- Default: `[]`
|
|
106
|
+
|
|
107
|
+
Example using package.json:
|
|
108
|
+
|
|
109
|
+
```json5
|
|
110
|
+
{
|
|
111
|
+
"anolilab": {
|
|
112
|
+
"lint-staged-config": {
|
|
113
|
+
"typescript": {
|
|
114
|
+
// ...options
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### eslint
|
|
122
|
+
|
|
123
|
+
Type: `object`
|
|
124
|
+
|
|
125
|
+
Options:
|
|
126
|
+
- `cache` - Enable or disable caching.
|
|
127
|
+
- Type: `boolean`
|
|
128
|
+
- config - Change path to eslint config.
|
|
129
|
+
- Type: `string`
|
|
130
|
+
- "fix-type"
|
|
131
|
+
- Type: `string[]`
|
|
132
|
+
- "max-warnings"
|
|
133
|
+
- Type: `number | string | false`
|
|
134
|
+
- rules - Override rules from eslint config.
|
|
135
|
+
- Type: `string[]`
|
|
136
|
+
|
|
137
|
+
Example using package.json:
|
|
138
|
+
|
|
139
|
+
```json5
|
|
140
|
+
{
|
|
141
|
+
"anolilab": {
|
|
142
|
+
"lint-staged-config": {
|
|
143
|
+
"eslint": {
|
|
144
|
+
// ...options
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
82
150
|
|
|
83
151
|
## Configuration
|
|
84
152
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { pkg } from '@anolilab/package-json-utils';
|
|
2
|
+
|
|
3
|
+
!global.anolilabLintStagedPackageJsonConfig&&pkg&&(global.anolilabLintStagedPackageJsonConfig=pkg.anolilab?.["lint-staged-config"]);var o=global.anolilabLintStagedPackageJsonConfig??{},g=o;
|
|
4
|
+
|
|
5
|
+
export { g as a };
|
|
6
|
+
//# sourceMappingURL=out.js.map
|
|
7
|
+
//# sourceMappingURL=chunk-AVDVT4B7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/lint-staged-config.ts"],"names":["pkg","config","lint_staged_config_default"],"mappings":"AAAA,OAAS,OAAAA,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,EAAI,WAAc,oBAAoB,GAGvF,IAAMC,EAA8C,OAAO,qCAAuC,CAAC,EAE5FC,EAAQD","sourcesContent":["import { pkg } from \"@anolilab/package-json-utils\";\n\nif (!global.anolilabLintStagedPackageJsonConfig && pkg) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n global.anolilabLintStagedPackageJsonConfig = pkg[\"anolilab\"]?.[\"lint-staged-config\"];\n}\n\nconst config: Record<string, boolean | undefined> = global.anolilabLintStagedPackageJsonConfig ?? {};\n\nexport default config;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkOYUEMN5Q_js = require('./chunk-OYUEMN5Q.js');
|
|
4
|
+
var chunkVU6SMFTD_js = require('./chunk-VU6SMFTD.js');
|
|
5
|
+
var chunkP4FK54EG_js = require('./chunk-P4FK54EG.js');
|
|
6
|
+
var process = require('process');
|
|
7
|
+
|
|
8
|
+
var i=chunkOYUEMN5Q_js.a?.typescript??{},f={[`**/*.{${["ts","mts","cts"].join(",")}}`]:g=>{let r=new Set;return g.forEach(e=>{if(i?.exclude&&Array.isArray(i.exclude)){let t=!1;if(i.exclude.forEach(a=>{!t&&e.includes(a)&&(t=!0);}),t){process.env.DEBUG&&console.info(`Skipping ${e} as it's excluded in the settings.`);return}}try{let t=chunkVU6SMFTD_js.a("tsconfig.json",e);r.add(`${chunkP4FK54EG_js.a()} exec tsc --noEmit --project ${t}`);}catch(t){process.env.DEBUG&&console.error(t);}}),[...r]}},u=f;
|
|
9
|
+
|
|
10
|
+
exports.a = u;
|
|
11
|
+
//# sourceMappingURL=out.js.map
|
|
12
|
+
//# sourceMappingURL=chunk-DVFT7GIT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","typescriptSettings","lint_staged_config_default","group","filenames","commands","filePath","exclude","value","tsconfigPath","get_nearest_config_path_default","get_package_manager_default","error","typescript_default"],"mappings":"wHAAA,OAAS,OAAAA,MAAW,UAiBpB,IAAMC,EAAwCC,GAA2C,YAAe,CAAC,EAEnGC,EAAgB,CAClB,CAAC,SAAS,CAAC,KAAM,MAAO,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,EAAIC,GAAwB,CACnE,IAAMC,EAAW,IAAI,IAErB,OAAAD,EAAU,QAASE,GAAa,CAE5B,GAAIL,GAAoB,SAAW,MAAM,QAAQA,EAAmB,OAAO,EAAG,CAC1E,IAAIM,EAAU,GASd,GAPAN,EAAmB,QAAQ,QAASO,GAAU,CACtC,CAACD,GAAWD,EAAS,SAASE,CAAK,IACnCD,EAAU,GAElB,CAAC,EAGGA,EAAS,CACLP,EAAI,OACJ,QAAQ,KAAK,YAAYM,CAAQ,oCAAoC,EAGzE,MACJ,CACJ,CAEA,GAAI,CAEA,IAAMG,EAAeC,EAAqB,gBAAiBJ,CAAwB,EAEnFD,EAAS,IAAI,GAAGM,EAAkB,CAAC,gCAAgCF,CAAY,EAAE,CACrF,OAASG,EAAO,CACRZ,EAAI,OACJ,QAAQ,MAAMY,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGP,CAAQ,CACvB,CACJ,EAEOQ,EAAQV","sourcesContent":["import { env } from \"node:process\";\n\nimport type { Config } from \"lint-staged\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\nimport getPackageManager from \"../utils/get-package-manager\";\nimport anolilabLintStagedConfig from \"../utils/lint-staged-config\";\n\ninterface TypescriptConfig {\n exclude?: string[];\n}\n\ninterface StagedConfig {\n typescript?: TypescriptConfig;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nconst typescriptSettings: TypescriptConfig = (anolilabLintStagedConfig as StagedConfig)?.typescript ?? ({} as TypescriptConfig);\n\nconst group: Config = {\n [`**/*.{${[\"ts\", \"mts\", \"cts\"].join(\",\")}}`]: (filenames: string[]) => {\n const commands = new Set<string>();\n\n filenames.forEach((filePath) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typescriptSettings?.exclude && Array.isArray(typescriptSettings.exclude)) {\n let exclude = false;\n\n typescriptSettings.exclude.forEach((value) => {\n if (!exclude && filePath.includes(value)) {\n exclude = true;\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (exclude) {\n if (env[\"DEBUG\"]) {\n console.info(`Skipping ${filePath} as it's excluded in the settings.`);\n }\n\n return;\n }\n }\n\n try {\n // eslint-disable-next-line no-template-curly-in-string\n const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\") as string;\n\n commands.add(`${getPackageManager()} exec tsc --noEmit --project ${tsconfigPath}`);\n } catch (error) {\n if (env[\"DEBUG\"]) {\n console.error(error);\n }\n }\n });\n\n return [...commands];\n },\n};\n\nexport default group;\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { a as a$1 } from './chunk-AVDVT4B7.mjs';
|
|
2
|
+
import { a as a$3 } from './chunk-HGDREIGE.mjs';
|
|
3
|
+
import { b as b$1, a as a$4 } from './chunk-PP4XAK3E.mjs';
|
|
4
|
+
import { a as a$2 } from './chunk-COM4XKFJ.mjs';
|
|
5
|
+
import { hasDependency, hasDevDependency, isPackageAvailable } from '@anolilab/package-json-utils';
|
|
6
|
+
import { dirname } from 'path';
|
|
7
|
+
import { ESLint } from 'eslint';
|
|
8
|
+
import { quote } from 'shell-quote';
|
|
9
|
+
|
|
10
|
+
var E=n=>{let t={};return n.forEach(o=>{let i=dirname(o);t[i]||(t[i]=[]),t[i].push(o);}),t},h=E;var A=async n=>{let t=new ESLint,i=(await Promise.allSettled(n.map(async e=>await t.isPathIgnored(e)))).map(e=>{if(e.status==="fulfilled")return e.value;throw console.error(`
|
|
11
|
+
Unable to determine if file is ignored.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
${e.reason}`),new Error("Stopping lint-staged because of an error.")});return n.filter((e,r)=>!i[r]).map(e=>`"${a$4?e:quote([e])}"`)},w=A;var s={};a$1?.eslint?s=a$1.eslint:a$1?.settings?.eslint&&(s=a$1.settings.eslint);var f=[];(hasDependency("eslint-plugin-react-hooks")||hasDevDependency("eslint-plugin-react-hooks"))&&f.push("react-hooks/exhaustive-deps:off");(hasDependency("eslint-plugin-eslint-comments")||hasDevDependency("eslint-plugin-eslint-comments")||isPackageAvailable("eslint-plugin-eslint-comments"))&&f.push("eslint-comments/no-unused-disable:off");var a=".eslintrc",D=()=>{let n=[];s["max-warnings"]!==void 0&&Number.isNaN(s["max-warnings"])?n.push(`--max-warnings=${s["max-warnings"]}`):s["max-warnings"]!==!1&&n.push("--max-warnings=0");let t=[...s.rules??[],...f].filter(i=>i.trim().length>0);t.length>0&&n.push(t.map(i=>`--rule "${i}"`).join(" "));let o=[...s["fix-type"]??["layout"]].filter(i=>i.trim().length>0);return o.length>0&&n.push(`--fix-type ${o.join(",")}`,"--fix"),s.cache&&n.push("--cache"),n},L=async n=>{let t=await w(n),o=D();if(s.config)return o.push(`--config ${s.config}`),[`${a$2()} exec eslint ${o.join(" ")} ${t.join(" ")}`];let i=h(t),c=[];return Object.values(i).forEach(e=>{let r;[a,`${a}.js`,`${a}.cjs`,`${a}.json`,`${a}.yaml`,`${a}.yml`].forEach(j=>{if(!r)try{r=a$3(j,e[0]);}catch{}}),r&&c.push(`${a$2()} exec eslint ${o.join(" ")} --config ${r} ${e.join(" ")}`);}),c},m=L;var b=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml"];global.hasAnolilabLintStagedMarkdownCli||(global.hasAnolilabLintStagedMarkdownCli=hasDependency("markdownlint-cli")||hasDevDependency("markdownlint-cli"));global.hasAnolilabLintStagedMarkdownCli2||(global.hasAnolilabLintStagedMarkdownCli2=hasDependency("markdownlint-cli2")||hasDevDependency("markdownlint-cli2"));!global.hasAnolilabLintStagedMarkdownCli&&!global.hasAnolilabLintStagedMarkdownCli2&&b.push("md");var M={[`**/*.{${["json","json5","jsonc"].join(",")}}`]:async n=>[...await m(n)],[`**/*.{${[b].join(",")}}`]:async n=>[`${a$2()} exec prettier --write ${b$1(n)}`,...await m(n)]},V=M;
|
|
15
|
+
|
|
16
|
+
export { V as a };
|
|
17
|
+
//# sourceMappingURL=out.js.map
|
|
18
|
+
//# sourceMappingURL=chunk-GTUWYYHD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/groups/eslint/index.ts","../src/groups/eslint/create-eslint-commands.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts"],"names":["hasDependency","hasDevDependency","isPackageAvailable","dirname","groupFilePathsByDirectoryName","filePaths","groups","filePath","directoryName","group_file_paths_by_directory_name_default","ESLint","quote","removeIgnoredFiles","filenames","eslint","ignoredFiles","filename","promise","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","lint_staged_config_default","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","fixType","type","createEslintCommands","filteredFiles","get_package_manager_default","groupedFilesNames","eslintCommands","config","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"2KAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,iBAAAD,EAAe,oBAAAC,EAAkB,sBAAAC,MAA0B,+BCApE,OAAS,WAAAC,MAAe,OAExB,IAAMC,EAAiCC,GAAkD,CACrF,IAAMC,EAAmC,CAAC,EAE1C,OAAAD,EAAU,QAASE,GAAa,CAC5B,IAAMC,EAAgBL,EAAQI,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BAAgBP,EAAgB,KAAK,GAAG,CAAC,aAAaU,CAAM,IAAIhC,EAAU,KAAK,GAAG,CAAC,EAAE,CAEvI,CAAC,EAEM+B,CACX,EAEOI,EAAQR,EDrIf,IAAMS,EAAa,CAAC,MAAO,KAAM,MAAO,MAAO,KAAM,MAAO,MAAO,OAAQ,MAAO,MAAO,MAAO,MAAM,EAEjG,OAAO,mCACR,OAAO,iCAAmCzC,EAAc,kBAAkB,GAAKC,EAAiB,kBAAkB,GAGjH,OAAO,oCACR,OAAO,kCAAoCD,EAAc,mBAAmB,GAAKC,EAAiB,mBAAmB,GAGrH,CAAC,OAAO,kCAAoC,CAAC,OAAO,mCACpDwC,EAAW,KAAK,IAAI,EAGxB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,OAAQ,QAAS,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO7B,GAAwB,CAAC,GAAI,MAAM2B,EAAqB3B,CAAS,CAAE,EAC9H,CAAC,SAAS,CAAC4B,CAAU,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO5B,GAAwB,CACjE,GAAGqB,EAAkB,CAAC,0BAA0BS,EAAY9B,CAAS,CAAC,GACtE,GAAI,MAAM2B,EAAqB3B,CAAS,CAC5C,CACJ,EAEO+B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\nimport getPackageManager from \"../../utils/get-package-manager\";\nimport createEslintCommands from \"./create-eslint-commands\";\n\nconst extensions = [\"cjs\", \"js\", \"mjs\", \"cts\", \"ts\", \"mts\", \"yml\", \"yaml\", \"jsx\", \"tsx\", \"mdx\", \"toml\"];\n\nif (!global.hasAnolilabLintStagedMarkdownCli) {\n global.hasAnolilabLintStagedMarkdownCli = hasDependency(\"markdownlint-cli\") || hasDevDependency(\"markdownlint-cli\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli2) {\n global.hasAnolilabLintStagedMarkdownCli2 = hasDependency(\"markdownlint-cli2\") || hasDevDependency(\"markdownlint-cli2\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMarkdownCli2) {\n extensions.push(\"md\");\n}\n\nconst group: Config = {\n [`**/*.{${[\"json\", \"json5\", \"jsonc\"].join(\",\")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],\n [`**/*.{${[extensions].join(\",\")}}`]: async (filenames: string[]) => [\n `${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\n","import { hasDependency, hasDevDependency, isPackageAvailable } from \"@anolilab/package-json-utils\";\n\nimport getNearestConfigPath from \"../../utils/get-nearest-config-path\";\nimport getPackageManager from \"../../utils/get-package-manager\";\nimport anolilabLintStagedConfig from \"../../utils/lint-staged-config\";\nimport groupFilePathsByDirectoryName from \"./group-file-paths-by-directory-name\";\nimport removeIgnoredFiles from \"./remove-ignored-files\";\n\ninterface EslintConfig {\n cache?: boolean;\n config?: string;\n \"fix-type\"?: string[];\n \"max-warnings\"?: number | string | false;\n rules?: string[];\n}\n\ninterface StagedConfig {\n eslint?: EslintConfig;\n settings?: {\n eslint?: EslintConfig;\n };\n}\n\nlet eslintSettings: EslintConfig = {} as EslintConfig;\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nif ((anolilabLintStagedConfig as StagedConfig)?.eslint) {\n eslintSettings = (anolilabLintStagedConfig as StagedConfig).eslint as EslintConfig;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n} else if ((anolilabLintStagedConfig as StagedConfig)?.settings?.eslint) {\n eslintSettings = (\n (anolilabLintStagedConfig as StagedConfig).settings as {\n eslint?: EslintConfig;\n }\n ).eslint as EslintConfig;\n}\n\nconst eslintGlobalRulesForFix: string[] = [];\n\nif (hasDependency(\"eslint-plugin-react-hooks\") || hasDevDependency(\"eslint-plugin-react-hooks\")) {\n // react-hooks/eslint and react in general is very strict about exhaustively\n // declaring the dependencies when using the useEffect, useCallback... hooks.\n //\n // In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable\n // by the developer, leading to some exceptions in the code. That said it should be avoided.\n //\n // While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to\n // automatically fix it from lint-staged as it can potentially break a legit intent.\n //\n // Reminder that a good practice is to always declare the dependencies when using the hooks,\n // and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:\n //\n // // eslint-disable-next-line react-hooks/exhaustive-deps\n //\n // Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass\n // shallow rendering limitations.\n //\n // @see https://reactjs.org/docs/hooks-rules.html\n // @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments\n eslintGlobalRulesForFix.push(\"react-hooks/exhaustive-deps:off\");\n}\n\nif (\n hasDependency(\"eslint-plugin-eslint-comments\") ||\n hasDevDependency(\"eslint-plugin-eslint-comments\") ||\n isPackageAvailable(\"eslint-plugin-eslint-comments\")\n) {\n eslintGlobalRulesForFix.push(\"eslint-comments/no-unused-disable:off\");\n}\n\nconst configFile = \".eslintrc\";\n\nconst createEslintArguments = (): string[] => {\n const eslintArguments: string[] = [];\n\n if (eslintSettings[\"max-warnings\"] !== undefined && Number.isNaN(eslintSettings[\"max-warnings\"])) {\n eslintArguments.push(`--max-warnings=${eslintSettings[\"max-warnings\"]}`);\n } else if (eslintSettings[\"max-warnings\"] !== false) {\n eslintArguments.push(\"--max-warnings=0\");\n }\n\n const rules = [...(eslintSettings.rules ?? []), ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0);\n\n if (rules.length > 0) {\n eslintArguments.push(rules.map((rule) => `--rule \"${rule}\"`).join(\" \"));\n }\n\n // For lint-staged it's safer to not apply the fix command if it changes the AST\n // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type\n const fixType = [...(eslintSettings[\"fix-type\"] ?? [\"layout\"])].filter((type) => type.trim().length > 0);\n\n if (fixType.length > 0) {\n eslintArguments.push(`--fix-type ${fixType.join(\",\")}`, \"--fix\");\n }\n\n if (eslintSettings.cache) {\n eslintArguments.push(\"--cache\");\n }\n\n return eslintArguments;\n};\n\nconst createEslintCommands = async (filenames: string[]): Promise<string[]> => {\n const filteredFiles = await removeIgnoredFiles(filenames);\n\n const eslintArguments = createEslintArguments();\n\n if (eslintSettings.config) {\n eslintArguments.push(`--config ${eslintSettings.config}`);\n\n return [`${getPackageManager()} exec eslint ${eslintArguments.join(\" \")} ${filteredFiles.join(\" \")}`];\n }\n\n const groupedFilesNames = groupFilePathsByDirectoryName(filteredFiles);\n const eslintCommands: string[] = [];\n\n Object.values(groupedFilesNames).forEach((filePaths) => {\n let config: string | undefined;\n\n [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`].forEach((configName) => {\n if (config) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-template-curly-in-string\n config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\") as string;\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`${getPackageManager()} exec eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n","import { dirname } from \"node:path\";\n\nconst groupFilePathsByDirectoryName = (filePaths: string[]): Record<string, string[]> => {\n const groups: Record<string, string[]> = {};\n\n filePaths.forEach((filePath) => {\n const directoryName = dirname(filePath);\n\n // eslint-disable-next-line security/detect-object-injection\n if (!groups[directoryName]) {\n // eslint-disable-next-line security/detect-object-injection\n groups[directoryName] = [];\n }\n // eslint-disable-next-line security/detect-object-injection\n (groups[directoryName] as string[]).push(filePath);\n });\n\n return groups;\n};\n\nexport default groupFilePathsByDirectoryName;\n","import { ESLint } from \"eslint\";\nimport { quote } from \"shell-quote\";\n\nimport isWindows from \"../../utils/is-windows\";\n\nconst removeIgnoredFiles = async (filenames: string[]): Promise<string[]> => {\n const eslint = new ESLint();\n // eslint-disable-next-line compat/compat\n const promises = await Promise.allSettled(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\n const ignoredFiles = promises.map((promise) => {\n if (promise.status === \"fulfilled\") {\n return promise.value;\n }\n\n console.error(`\\nUnable to determine if file is ignored.\\n\\n\\n${promise.reason}`);\n\n throw new Error(\"Stopping lint-staged because of an error.\");\n });\n\n // eslint-disable-next-line security/detect-object-injection\n const filteredFiles = filenames.filter((_, index) => !ignoredFiles[index]);\n\n return filteredFiles.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`);\n};\n\nexport default removeIgnoredFiles;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { a } from './chunk-AVDVT4B7.mjs';
|
|
2
|
+
import { a as a$1 } from './chunk-HGDREIGE.mjs';
|
|
3
|
+
import { a as a$2 } from './chunk-COM4XKFJ.mjs';
|
|
4
|
+
import { env } from 'process';
|
|
5
|
+
|
|
6
|
+
var i=a?.typescript??{},f={[`**/*.{${["ts","mts","cts"].join(",")}}`]:g=>{let r=new Set;return g.forEach(e=>{if(i?.exclude&&Array.isArray(i.exclude)){let t=!1;if(i.exclude.forEach(a=>{!t&&e.includes(a)&&(t=!0);}),t){env.DEBUG&&console.info(`Skipping ${e} as it's excluded in the settings.`);return}}try{let t=a$1("tsconfig.json",e);r.add(`${a$2()} exec tsc --noEmit --project ${t}`);}catch(t){env.DEBUG&&console.error(t);}}),[...r]}},u=f;
|
|
7
|
+
|
|
8
|
+
export { u as a };
|
|
9
|
+
//# sourceMappingURL=out.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-H67RQHXB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","typescriptSettings","lint_staged_config_default","group","filenames","commands","filePath","exclude","value","tsconfigPath","get_nearest_config_path_default","get_package_manager_default","error","typescript_default"],"mappings":"2HAAA,OAAS,OAAAA,MAAW,UAiBpB,IAAMC,EAAwCC,GAA2C,YAAe,CAAC,EAEnGC,EAAgB,CAClB,CAAC,SAAS,CAAC,KAAM,MAAO,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,EAAIC,GAAwB,CACnE,IAAMC,EAAW,IAAI,IAErB,OAAAD,EAAU,QAASE,GAAa,CAE5B,GAAIL,GAAoB,SAAW,MAAM,QAAQA,EAAmB,OAAO,EAAG,CAC1E,IAAIM,EAAU,GASd,GAPAN,EAAmB,QAAQ,QAASO,GAAU,CACtC,CAACD,GAAWD,EAAS,SAASE,CAAK,IACnCD,EAAU,GAElB,CAAC,EAGGA,EAAS,CACLP,EAAI,OACJ,QAAQ,KAAK,YAAYM,CAAQ,oCAAoC,EAGzE,MACJ,CACJ,CAEA,GAAI,CAEA,IAAMG,EAAeC,EAAqB,gBAAiBJ,CAAwB,EAEnFD,EAAS,IAAI,GAAGM,EAAkB,CAAC,gCAAgCF,CAAY,EAAE,CACrF,OAASG,EAAO,CACRZ,EAAI,OACJ,QAAQ,MAAMY,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGP,CAAQ,CACvB,CACJ,EAEOQ,EAAQV","sourcesContent":["import { env } from \"node:process\";\n\nimport type { Config } from \"lint-staged\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\nimport getPackageManager from \"../utils/get-package-manager\";\nimport anolilabLintStagedConfig from \"../utils/lint-staged-config\";\n\ninterface TypescriptConfig {\n exclude?: string[];\n}\n\ninterface StagedConfig {\n typescript?: TypescriptConfig;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nconst typescriptSettings: TypescriptConfig = (anolilabLintStagedConfig as StagedConfig)?.typescript ?? ({} as TypescriptConfig);\n\nconst group: Config = {\n [`**/*.{${[\"ts\", \"mts\", \"cts\"].join(\",\")}}`]: (filenames: string[]) => {\n const commands = new Set<string>();\n\n filenames.forEach((filePath) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typescriptSettings?.exclude && Array.isArray(typescriptSettings.exclude)) {\n let exclude = false;\n\n typescriptSettings.exclude.forEach((value) => {\n if (!exclude && filePath.includes(value)) {\n exclude = true;\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (exclude) {\n if (env[\"DEBUG\"]) {\n console.info(`Skipping ${filePath} as it's excluded in the settings.`);\n }\n\n return;\n }\n }\n\n try {\n // eslint-disable-next-line no-template-curly-in-string\n const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\") as string;\n\n commands.add(`${getPackageManager()} exec tsc --noEmit --project ${tsconfigPath}`);\n } catch (error) {\n if (env[\"DEBUG\"]) {\n console.error(error);\n }\n }\n });\n\n return [...commands];\n },\n};\n\nexport default group;\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkOYUEMN5Q_js = require('./chunk-OYUEMN5Q.js');
|
|
4
|
+
var chunkVU6SMFTD_js = require('./chunk-VU6SMFTD.js');
|
|
5
|
+
var chunkKP7AH4EU_js = require('./chunk-KP7AH4EU.js');
|
|
6
|
+
var chunkP4FK54EG_js = require('./chunk-P4FK54EG.js');
|
|
7
|
+
var packageJsonUtils = require('@anolilab/package-json-utils');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
var eslint = require('eslint');
|
|
10
|
+
var shellQuote = require('shell-quote');
|
|
11
|
+
|
|
12
|
+
var E=n=>{let t={};return n.forEach(o=>{let i=path.dirname(o);t[i]||(t[i]=[]),t[i].push(o);}),t},h=E;var A=async n=>{let t=new eslint.ESLint,i=(await Promise.allSettled(n.map(async e=>await t.isPathIgnored(e)))).map(e=>{if(e.status==="fulfilled")return e.value;throw console.error(`
|
|
13
|
+
Unable to determine if file is ignored.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
${e.reason}`),new Error("Stopping lint-staged because of an error.")});return n.filter((e,r)=>!i[r]).map(e=>`"${chunkKP7AH4EU_js.a?e:shellQuote.quote([e])}"`)},w=A;var s={};chunkOYUEMN5Q_js.a?.eslint?s=chunkOYUEMN5Q_js.a.eslint:chunkOYUEMN5Q_js.a?.settings?.eslint&&(s=chunkOYUEMN5Q_js.a.settings.eslint);var f=[];(packageJsonUtils.hasDependency("eslint-plugin-react-hooks")||packageJsonUtils.hasDevDependency("eslint-plugin-react-hooks"))&&f.push("react-hooks/exhaustive-deps:off");(packageJsonUtils.hasDependency("eslint-plugin-eslint-comments")||packageJsonUtils.hasDevDependency("eslint-plugin-eslint-comments")||packageJsonUtils.isPackageAvailable("eslint-plugin-eslint-comments"))&&f.push("eslint-comments/no-unused-disable:off");var a=".eslintrc",D=()=>{let n=[];s["max-warnings"]!==void 0&&Number.isNaN(s["max-warnings"])?n.push(`--max-warnings=${s["max-warnings"]}`):s["max-warnings"]!==!1&&n.push("--max-warnings=0");let t=[...s.rules??[],...f].filter(i=>i.trim().length>0);t.length>0&&n.push(t.map(i=>`--rule "${i}"`).join(" "));let o=[...s["fix-type"]??["layout"]].filter(i=>i.trim().length>0);return o.length>0&&n.push(`--fix-type ${o.join(",")}`,"--fix"),s.cache&&n.push("--cache"),n},L=async n=>{let t=await w(n),o=D();if(s.config)return o.push(`--config ${s.config}`),[`${chunkP4FK54EG_js.a()} exec eslint ${o.join(" ")} ${t.join(" ")}`];let i=h(t),c=[];return Object.values(i).forEach(e=>{let r;[a,`${a}.js`,`${a}.cjs`,`${a}.json`,`${a}.yaml`,`${a}.yml`].forEach(j=>{if(!r)try{r=chunkVU6SMFTD_js.a(j,e[0]);}catch{}}),r&&c.push(`${chunkP4FK54EG_js.a()} exec eslint ${o.join(" ")} --config ${r} ${e.join(" ")}`);}),c},m=L;var b=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml"];global.hasAnolilabLintStagedMarkdownCli||(global.hasAnolilabLintStagedMarkdownCli=packageJsonUtils.hasDependency("markdownlint-cli")||packageJsonUtils.hasDevDependency("markdownlint-cli"));global.hasAnolilabLintStagedMarkdownCli2||(global.hasAnolilabLintStagedMarkdownCli2=packageJsonUtils.hasDependency("markdownlint-cli2")||packageJsonUtils.hasDevDependency("markdownlint-cli2"));!global.hasAnolilabLintStagedMarkdownCli&&!global.hasAnolilabLintStagedMarkdownCli2&&b.push("md");var M={[`**/*.{${["json","json5","jsonc"].join(",")}}`]:async n=>[...await m(n)],[`**/*.{${[b].join(",")}}`]:async n=>[`${chunkP4FK54EG_js.a()} exec prettier --write ${chunkKP7AH4EU_js.b(n)}`,...await m(n)]},V=M;
|
|
17
|
+
|
|
18
|
+
exports.a = V;
|
|
19
|
+
//# sourceMappingURL=out.js.map
|
|
20
|
+
//# sourceMappingURL=chunk-OHF7NDU3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/groups/eslint/index.ts","../src/groups/eslint/create-eslint-commands.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts"],"names":["hasDependency","hasDevDependency","isPackageAvailable","dirname","groupFilePathsByDirectoryName","filePaths","groups","filePath","directoryName","group_file_paths_by_directory_name_default","ESLint","quote","removeIgnoredFiles","filenames","eslint","ignoredFiles","filename","promise","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","lint_staged_config_default","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","fixType","type","createEslintCommands","filteredFiles","get_package_manager_default","groupedFilesNames","eslintCommands","config","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"uKAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,iBAAAD,EAAe,oBAAAC,EAAkB,sBAAAC,MAA0B,+BCApE,OAAS,WAAAC,MAAe,OAExB,IAAMC,EAAiCC,GAAkD,CACrF,IAAMC,EAAmC,CAAC,EAE1C,OAAAD,EAAU,QAASE,GAAa,CAC5B,IAAMC,EAAgBL,EAAQI,CAAQ,EAG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AgB,KAAK,GAAG,CAAC,aAAaU,CAAM,IAAIhC,EAAU,KAAK,GAAG,CAAC,EAAE,CAEvI,CAAC,EAEM+B,CACX,EAEOI,EAAQR,EDrIf,IAAMS,EAAa,CAAC,MAAO,KAAM,MAAO,MAAO,KAAM,MAAO,MAAO,OAAQ,MAAO,MAAO,MAAO,MAAM,EAEjG,OAAO,mCACR,OAAO,iCAAmCzC,EAAc,kBAAkB,GAAKC,EAAiB,kBAAkB,GAGjH,OAAO,oCACR,OAAO,kCAAoCD,EAAc,mBAAmB,GAAKC,EAAiB,mBAAmB,GAGrH,CAAC,OAAO,kCAAoC,CAAC,OAAO,mCACpDwC,EAAW,KAAK,IAAI,EAGxB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,OAAQ,QAAS,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO7B,GAAwB,CAAC,GAAI,MAAM2B,EAAqB3B,CAAS,CAAE,EAC9H,CAAC,SAAS,CAAC4B,CAAU,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO5B,GAAwB,CACjE,GAAGqB,EAAkB,CAAC,0BAA0BS,EAAY9B,CAAS,CAAC,GACtE,GAAI,MAAM2B,EAAqB3B,CAAS,CAC5C,CACJ,EAEO+B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\nimport getPackageManager from \"../../utils/get-package-manager\";\nimport createEslintCommands from \"./create-eslint-commands\";\n\nconst extensions = [\"cjs\", \"js\", \"mjs\", \"cts\", \"ts\", \"mts\", \"yml\", \"yaml\", \"jsx\", \"tsx\", \"mdx\", \"toml\"];\n\nif (!global.hasAnolilabLintStagedMarkdownCli) {\n global.hasAnolilabLintStagedMarkdownCli = hasDependency(\"markdownlint-cli\") || hasDevDependency(\"markdownlint-cli\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli2) {\n global.hasAnolilabLintStagedMarkdownCli2 = hasDependency(\"markdownlint-cli2\") || hasDevDependency(\"markdownlint-cli2\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMarkdownCli2) {\n extensions.push(\"md\");\n}\n\nconst group: Config = {\n [`**/*.{${[\"json\", \"json5\", \"jsonc\"].join(\",\")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],\n [`**/*.{${[extensions].join(\",\")}}`]: async (filenames: string[]) => [\n `${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\n","import { hasDependency, hasDevDependency, isPackageAvailable } from \"@anolilab/package-json-utils\";\n\nimport getNearestConfigPath from \"../../utils/get-nearest-config-path\";\nimport getPackageManager from \"../../utils/get-package-manager\";\nimport anolilabLintStagedConfig from \"../../utils/lint-staged-config\";\nimport groupFilePathsByDirectoryName from \"./group-file-paths-by-directory-name\";\nimport removeIgnoredFiles from \"./remove-ignored-files\";\n\ninterface EslintConfig {\n cache?: boolean;\n config?: string;\n \"fix-type\"?: string[];\n \"max-warnings\"?: number | string | false;\n rules?: string[];\n}\n\ninterface StagedConfig {\n eslint?: EslintConfig;\n settings?: {\n eslint?: EslintConfig;\n };\n}\n\nlet eslintSettings: EslintConfig = {} as EslintConfig;\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nif ((anolilabLintStagedConfig as StagedConfig)?.eslint) {\n eslintSettings = (anolilabLintStagedConfig as StagedConfig).eslint as EslintConfig;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n} else if ((anolilabLintStagedConfig as StagedConfig)?.settings?.eslint) {\n eslintSettings = (\n (anolilabLintStagedConfig as StagedConfig).settings as {\n eslint?: EslintConfig;\n }\n ).eslint as EslintConfig;\n}\n\nconst eslintGlobalRulesForFix: string[] = [];\n\nif (hasDependency(\"eslint-plugin-react-hooks\") || hasDevDependency(\"eslint-plugin-react-hooks\")) {\n // react-hooks/eslint and react in general is very strict about exhaustively\n // declaring the dependencies when using the useEffect, useCallback... hooks.\n //\n // In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable\n // by the developer, leading to some exceptions in the code. That said it should be avoided.\n //\n // While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to\n // automatically fix it from lint-staged as it can potentially break a legit intent.\n //\n // Reminder that a good practice is to always declare the dependencies when using the hooks,\n // and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:\n //\n // // eslint-disable-next-line react-hooks/exhaustive-deps\n //\n // Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass\n // shallow rendering limitations.\n //\n // @see https://reactjs.org/docs/hooks-rules.html\n // @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments\n eslintGlobalRulesForFix.push(\"react-hooks/exhaustive-deps:off\");\n}\n\nif (\n hasDependency(\"eslint-plugin-eslint-comments\") ||\n hasDevDependency(\"eslint-plugin-eslint-comments\") ||\n isPackageAvailable(\"eslint-plugin-eslint-comments\")\n) {\n eslintGlobalRulesForFix.push(\"eslint-comments/no-unused-disable:off\");\n}\n\nconst configFile = \".eslintrc\";\n\nconst createEslintArguments = (): string[] => {\n const eslintArguments: string[] = [];\n\n if (eslintSettings[\"max-warnings\"] !== undefined && Number.isNaN(eslintSettings[\"max-warnings\"])) {\n eslintArguments.push(`--max-warnings=${eslintSettings[\"max-warnings\"]}`);\n } else if (eslintSettings[\"max-warnings\"] !== false) {\n eslintArguments.push(\"--max-warnings=0\");\n }\n\n const rules = [...(eslintSettings.rules ?? []), ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0);\n\n if (rules.length > 0) {\n eslintArguments.push(rules.map((rule) => `--rule \"${rule}\"`).join(\" \"));\n }\n\n // For lint-staged it's safer to not apply the fix command if it changes the AST\n // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type\n const fixType = [...(eslintSettings[\"fix-type\"] ?? [\"layout\"])].filter((type) => type.trim().length > 0);\n\n if (fixType.length > 0) {\n eslintArguments.push(`--fix-type ${fixType.join(\",\")}`, \"--fix\");\n }\n\n if (eslintSettings.cache) {\n eslintArguments.push(\"--cache\");\n }\n\n return eslintArguments;\n};\n\nconst createEslintCommands = async (filenames: string[]): Promise<string[]> => {\n const filteredFiles = await removeIgnoredFiles(filenames);\n\n const eslintArguments = createEslintArguments();\n\n if (eslintSettings.config) {\n eslintArguments.push(`--config ${eslintSettings.config}`);\n\n return [`${getPackageManager()} exec eslint ${eslintArguments.join(\" \")} ${filteredFiles.join(\" \")}`];\n }\n\n const groupedFilesNames = groupFilePathsByDirectoryName(filteredFiles);\n const eslintCommands: string[] = [];\n\n Object.values(groupedFilesNames).forEach((filePaths) => {\n let config: string | undefined;\n\n [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`].forEach((configName) => {\n if (config) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-template-curly-in-string\n config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\") as string;\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`${getPackageManager()} exec eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n","import { dirname } from \"node:path\";\n\nconst groupFilePathsByDirectoryName = (filePaths: string[]): Record<string, string[]> => {\n const groups: Record<string, string[]> = {};\n\n filePaths.forEach((filePath) => {\n const directoryName = dirname(filePath);\n\n // eslint-disable-next-line security/detect-object-injection\n if (!groups[directoryName]) {\n // eslint-disable-next-line security/detect-object-injection\n groups[directoryName] = [];\n }\n // eslint-disable-next-line security/detect-object-injection\n (groups[directoryName] as string[]).push(filePath);\n });\n\n return groups;\n};\n\nexport default groupFilePathsByDirectoryName;\n","import { ESLint } from \"eslint\";\nimport { quote } from \"shell-quote\";\n\nimport isWindows from \"../../utils/is-windows\";\n\nconst removeIgnoredFiles = async (filenames: string[]): Promise<string[]> => {\n const eslint = new ESLint();\n // eslint-disable-next-line compat/compat\n const promises = await Promise.allSettled(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\n const ignoredFiles = promises.map((promise) => {\n if (promise.status === \"fulfilled\") {\n return promise.value;\n }\n\n console.error(`\\nUnable to determine if file is ignored.\\n\\n\\n${promise.reason}`);\n\n throw new Error(\"Stopping lint-staged because of an error.\");\n });\n\n // eslint-disable-next-line security/detect-object-injection\n const filteredFiles = filenames.filter((_, index) => !ignoredFiles[index]);\n\n return filteredFiles.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`);\n};\n\nexport default removeIgnoredFiles;\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var packageJsonUtils = require('@anolilab/package-json-utils');
|
|
4
|
+
|
|
5
|
+
!global.anolilabLintStagedPackageJsonConfig&&packageJsonUtils.pkg&&(global.anolilabLintStagedPackageJsonConfig=packageJsonUtils.pkg.anolilab?.["lint-staged-config"]);var o=global.anolilabLintStagedPackageJsonConfig??{},g=o;
|
|
6
|
+
|
|
7
|
+
exports.a = g;
|
|
8
|
+
//# sourceMappingURL=out.js.map
|
|
9
|
+
//# sourceMappingURL=chunk-OYUEMN5Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/lint-staged-config.ts"],"names":["pkg","config","lint_staged_config_default"],"mappings":"AAAA,OAAS,OAAAA,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,EAAI,WAAc,oBAAoB,GAGvF,IAAMC,EAA8C,OAAO,qCAAuC,CAAC,EAE5FC,EAAQD","sourcesContent":["import { pkg } from \"@anolilab/package-json-utils\";\n\nif (!global.anolilabLintStagedPackageJsonConfig && pkg) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n global.anolilabLintStagedPackageJsonConfig = pkg[\"anolilab\"]?.[\"lint-staged-config\"];\n}\n\nconst config: Record<string, boolean | undefined> = global.anolilabLintStagedPackageJsonConfig ?? {};\n\nexport default config;\n"]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOHF7NDU3_js = require('../../chunk-OHF7NDU3.js');
|
|
4
|
+
require('../../chunk-OYUEMN5Q.js');
|
|
4
5
|
require('../../chunk-VU6SMFTD.js');
|
|
5
6
|
require('../../chunk-KP7AH4EU.js');
|
|
6
7
|
require('../../chunk-P4FK54EG.js');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
module.exports =
|
|
11
|
+
module.exports = chunkOHF7NDU3_js.a;
|
|
11
12
|
//# sourceMappingURL=out.js.map
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDVFT7GIT_js = require('../chunk-DVFT7GIT.js');
|
|
4
|
+
require('../chunk-OYUEMN5Q.js');
|
|
4
5
|
require('../chunk-VU6SMFTD.js');
|
|
5
6
|
require('../chunk-P4FK54EG.js');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
module.exports =
|
|
10
|
+
module.exports = chunkDVFT7GIT_js.a;
|
|
10
11
|
//# sourceMappingURL=out.js.map
|
|
11
12
|
//# sourceMappingURL=typescript.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkDVFT7GIT_js = require('./chunk-DVFT7GIT.js');
|
|
4
|
+
var chunkOHF7NDU3_js = require('./chunk-OHF7NDU3.js');
|
|
5
|
+
var chunkOYUEMN5Q_js = require('./chunk-OYUEMN5Q.js');
|
|
5
6
|
require('./chunk-VU6SMFTD.js');
|
|
6
7
|
var chunkTNK6LFGX_js = require('./chunk-TNK6LFGX.js');
|
|
7
8
|
var chunk4PAU4XRY_js = require('./chunk-4PAU4XRY.js');
|
|
@@ -13,7 +14,7 @@ require('./chunk-P4FK54EG.js');
|
|
|
13
14
|
var process = require('process');
|
|
14
15
|
var packageJsonUtils = require('@anolilab/package-json-utils');
|
|
15
16
|
|
|
16
|
-
var y=[{config:
|
|
17
|
+
var y=[{config:chunkOHF7NDU3_js.a,configName:"eslint",dependencies:["prettier","eslint"]},{config:chunkTNK6LFGX_js.a,configName:"json",dependencies:["prettier","sort-package-json"]},{config:chunk4PAU4XRY_js.a,configName:"markdown",dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{config:chunk6IRNLWX6_js.a,configName:"secretlint",dependencies:["secretlint"]},{config:chunk5J6LVG23_js.a,configName:"stylesheets",dependencies:["stylelint"]},{config:chunkAUGHUNNL_js.a,configName:"tests",dependencies:["vite","jest","ava"]},{config:chunkDVFT7GIT_js.a,configName:"typescript",dependencies:["typescript"]}],g={},r=[],a={};y.forEach(t=>{let{config:n,configName:i,dependencies:l}=t;if(chunkOYUEMN5Q_js.a.plugin?.[i]!==!1){let s=[];l.forEach(e=>{(packageJsonUtils.hasDependency(e)||packageJsonUtils.hasDevDependency(e))&&s.push(e);}),s.length>0?(g={...g,...n},r.push(i)):(a[i]={},l.forEach(e=>{a[i][e]=packageJsonUtils.hasDependency(e)||packageJsonUtils.hasDevDependency(e);}));}});var w={...g};var j=()=>{},k=t=>process.env.NO_LOGS?j:n=>console.log(`${t}${n}`),O=k(""),o=O;if(!global.hasAnolilabStagedLintConfigLoaded){process.env.DEBUG&&(o(`
|
|
17
18
|
@anolilab/lint-stage-config loaded the following plugins:
|
|
18
19
|
`),r.forEach(n=>{o(` ${n}`);}));let t=!1;Object.entries(a).forEach(([n,i])=>{Object.values(i).some(Boolean)&&(t=!0,o(`
|
|
19
20
|
Your package.json container dependencies for the "${n}" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`),Object.entries(i).forEach(([s,e])=>{e||o(` ${s}`);}));}),t&&(o(`
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"oZAAA,OAAS,OAAAA,MAAW,UCApB,OAAS,iBAAAC,EAAe,oBAAAC,MAAwB,+BAkBhD,IAAMC,EAAiB,CACnB,CACI,OAAQC,EACR,WAAY,SACZ,aAAc,CAAC,WAAY,QAAQ,CACvC,EACA,CACI,OAAQC,EACR,WAAY,OACZ,aAAc,CAAC,WAAY,mBAAmB,CAClD,EACA,CACI,OAAQC,EACR,WAAY,WACZ,aAAc,CAAC,WAAY,mBAAoB,mBAAmB,CACtE,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,EACA,CACI,OAAQC,EACR,WAAY,cACZ,aAAc,CAAC,WAAW,CAC9B,EACA,CACI,OAAQC,EACR,WAAY,QACZ,aAAc,CAAC,OAAQ,OAAQ,KAAK,CACxC,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,CACJ,EAEIC,EAAwB,CAAC,EACvBC,EA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M,CACzDA,GACDH,EAAW,OAAOP,CAAU,EAAE,CAEtC,CAAC,EAET,CAAC,EAGGS,IACAF,EAAW;AAAA,iEAAoE,EAC/EA,EAAW;AAAA,CAAiF,GAGhGA,EAAW,2GAA2G,EAEtH,OAAO,kCAAoC,EAC/C","sourcesContent":["import { env } from \"node:process\";\n\nimport { loadedPluginsNames, possiblePlugins } from \"./config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your lint-staged command call \"NO_LOGS=true lint-staged ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n config: Config;\n configName: string;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n config: eslintConfig,\n configName: \"eslint\",\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n config: jsonConfig,\n configName: \"json\",\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n config: markdownConfig,\n configName: \"markdown\",\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n config: secretlintConfig,\n configName: \"secretlint\",\n dependencies: [\"secretlint\"],\n },\n {\n config: stylesheetsConfig,\n configName: \"stylesheets\",\n dependencies: [\"stylelint\"],\n },\n {\n config: testsConfig,\n configName: \"tests\",\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n config: typescriptConfig,\n configName: \"typescript\",\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: Record<string, Record<string, boolean>> = {};\n\ngroups.forEach((plugin) => {\n const { config, configName, dependencies } = plugin;\n\n // eslint-disable-next-line security/detect-object-injection\n if ((anolilabLintStagedConfig as unknown as Record<string, Record<string, false | undefined>>)[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n // eslint-disable-next-line security/detect-object-injection\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n // eslint-disable-next-line security/detect-object-injection\n (possiblePlugins[configName] as Record<string, boolean>)[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) => (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { a as a$
|
|
2
|
-
import { a as a$
|
|
1
|
+
import { a as a$8 } from './chunk-H67RQHXB.mjs';
|
|
2
|
+
import { a as a$2 } from './chunk-GTUWYYHD.mjs';
|
|
3
|
+
import { a as a$1 } from './chunk-AVDVT4B7.mjs';
|
|
3
4
|
import './chunk-HGDREIGE.mjs';
|
|
4
|
-
import { a as a$
|
|
5
|
-
import { a as a$
|
|
6
|
-
import { a as a$
|
|
7
|
-
import { a as a$
|
|
8
|
-
import { a as a$
|
|
5
|
+
import { a as a$3 } from './chunk-SPRVGS3T.mjs';
|
|
6
|
+
import { a as a$4 } from './chunk-Q3OATPM3.mjs';
|
|
7
|
+
import { a as a$5 } from './chunk-ESC4EHDT.mjs';
|
|
8
|
+
import { a as a$6 } from './chunk-S6JLN2LC.mjs';
|
|
9
|
+
import { a as a$7 } from './chunk-7NPAYSRP.mjs';
|
|
9
10
|
import './chunk-PP4XAK3E.mjs';
|
|
10
11
|
import './chunk-COM4XKFJ.mjs';
|
|
11
12
|
import { env } from 'process';
|
|
12
13
|
import { hasDependency, hasDevDependency } from '@anolilab/package-json-utils';
|
|
13
14
|
|
|
14
|
-
var y=[{config:
|
|
15
|
+
var y=[{config:a$2,configName:"eslint",dependencies:["prettier","eslint"]},{config:a$3,configName:"json",dependencies:["prettier","sort-package-json"]},{config:a$4,configName:"markdown",dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{config:a$5,configName:"secretlint",dependencies:["secretlint"]},{config:a$6,configName:"stylesheets",dependencies:["stylelint"]},{config:a$7,configName:"tests",dependencies:["vite","jest","ava"]},{config:a$8,configName:"typescript",dependencies:["typescript"]}],g={},r=[],a={};y.forEach(t=>{let{config:n,configName:i,dependencies:l}=t;if(a$1.plugin?.[i]!==!1){let s=[];l.forEach(e=>{(hasDependency(e)||hasDevDependency(e))&&s.push(e);}),s.length>0?(g={...g,...n},r.push(i)):(a[i]={},l.forEach(e=>{a[i][e]=hasDependency(e)||hasDevDependency(e);}));}});var w={...g};var j=()=>{},k=t=>env.NO_LOGS?j:n=>console.log(`${t}${n}`),O=k(""),o=O;if(!global.hasAnolilabStagedLintConfigLoaded){env.DEBUG&&(o(`
|
|
15
16
|
@anolilab/lint-stage-config loaded the following plugins:
|
|
16
17
|
`),r.forEach(n=>{o(` ${n}`);}));let t=!1;Object.entries(a).forEach(([n,i])=>{Object.values(i).some(Boolean)&&(t=!0,o(`
|
|
17
18
|
Your package.json container dependencies for the "${n}" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`),Object.entries(i).forEach(([s,e])=>{e||o(` ${s}`);}));}),t&&(o(`
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"+ZAAA,OAAS,OAAAA,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AAO,IAAG,GAEVC,EAAiBC,GAAoBxB,EAAI,QAAasB,EAAQG,GAAoB,QAAQ,IAAI,GAAGD,CAAM,GAAGC,CAAO,EAAE,EAEnHC,EAAaH,EAAc,EAAE,EAE5BI,EAAQD,EFFf,GAAI,CAAC,OAAO,kCAAmC,CACvC1B,EAAI,QACJ2B,EAAW;AAAA;AAAA,CAA+D,EAE1Ef,EAAmB,QAASgB,GAAe,CACvCD,EAAW,OAAOC,CAAU,EAAE,CAClC,CAAC,GAGL,IAAIC,EAAY,GAEhB,OAAO,QAAQhB,CAAe,EAAE,QAAQ,CAAC,CAACC,EAAQG,CAAY,IAAM,CACvC,OAAO,OAAOA,CAAY,EAAE,KAAK,OAAO,IAG7DY,EAAY,GACZF,EACI;AAAA,oDAAuDb,CAAM,yGACjE,EAEA,OAAO,QAAQG,CAAY,EAAE,QAAQ,CAAC,CAACG,EAAYU,CAAS,IAAM,CACzDA,GACDH,EAAW,OAAOP,CAAU,EAAE,CAEtC,CAAC,EAET,CAAC,EAGGS,IACAF,EAAW;AAAA,iEAAoE,EAC/EA,EAAW;AAAA,CAAiF,GAGhGA,EAAW,2GAA2G,EAEtH,OAAO,kCAAoC,EAC/C","sourcesContent":["import { env } from \"node:process\";\n\nimport { loadedPluginsNames, possiblePlugins } from \"./config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your lint-staged command call \"NO_LOGS=true lint-staged ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n config: Config;\n configName: string;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n config: eslintConfig,\n configName: \"eslint\",\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n config: jsonConfig,\n configName: \"json\",\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n config: markdownConfig,\n configName: \"markdown\",\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n config: secretlintConfig,\n configName: \"secretlint\",\n dependencies: [\"secretlint\"],\n },\n {\n config: stylesheetsConfig,\n configName: \"stylesheets\",\n dependencies: [\"stylelint\"],\n },\n {\n config: testsConfig,\n configName: \"tests\",\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n config: typescriptConfig,\n configName: \"typescript\",\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: Record<string, Record<string, boolean>> = {};\n\ngroups.forEach((plugin) => {\n const { config, configName, dependencies } = plugin;\n\n // eslint-disable-next-line security/detect-object-injection\n if ((anolilabLintStagedConfig as unknown as Record<string, Record<string, false | undefined>>)[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n // eslint-disable-next-line security/detect-object-injection\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n // eslint-disable-next-line security/detect-object-injection\n (possiblePlugins[configName] as Record<string, boolean>)[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) => (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anolilab/lint-staged-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Shareable Lint-Staged Config for any project.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"rimraf": "^5.0.5",
|
|
111
111
|
"semantic-release": "^22.0.5",
|
|
112
112
|
"tsup": "^7.2.0",
|
|
113
|
-
"type-fest": "^4.
|
|
113
|
+
"type-fest": "^4.4.0",
|
|
114
114
|
"typescript": "5.2.2",
|
|
115
115
|
"vitest": "^0.34.6"
|
|
116
116
|
},
|
package/dist/chunk-2ADQIOER.mjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { a as a$1 } from './chunk-HGDREIGE.mjs';
|
|
2
|
-
import { a as a$2 } from './chunk-COM4XKFJ.mjs';
|
|
3
|
-
import { env } from 'process';
|
|
4
|
-
|
|
5
|
-
var a={[`**/*.{${["ts","mts","cts"].join(",")}}`]:e=>{let o=new Set;return e.forEach(s=>{try{let t=a$1("tsconfig.json",s);o.add(`${a$2()} exec tsc --noEmit --project ${t}`);}catch(t){env.DEBUG&&console.error(t);}}),[...o]}},m=a;
|
|
6
|
-
|
|
7
|
-
export { m as a };
|
|
8
|
-
//# sourceMappingURL=out.js.map
|
|
9
|
-
//# sourceMappingURL=chunk-2ADQIOER.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","get_package_manager_default","error","typescript_default"],"mappings":"kFAAA,OAAS,OAAAA,MAAW,UAOpB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,KAAM,MAAO,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,EAAIC,GAAwB,CACnE,IAAMC,EAAW,IAAI,IAErB,OAAAD,EAAU,QAASE,GAAa,CAC5B,GAAI,CAEA,IAAMC,EAAeC,EAAqB,gBAAiBF,CAAwB,EAEnFD,EAAS,IAAI,GAAGI,EAAkB,CAAC,gCAAgCF,CAAY,EAAE,CACrF,OAASG,EAAO,CACRR,EAAI,OACJ,QAAQ,MAAMQ,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGL,CAAQ,CACvB,CACJ,EAEOM,EAAQR","sourcesContent":["import { env } from \"node:process\";\n\nimport type { Config } from \"lint-staged\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\nimport getPackageManager from \"../utils/get-package-manager\";\n\nconst group: Config = {\n [`**/*.{${[\"ts\", \"mts\", \"cts\"].join(\",\")}}`]: (filenames: string[]) => {\n const commands = new Set<string>();\n\n filenames.forEach((filePath) => {\n try {\n // eslint-disable-next-line no-template-curly-in-string\n const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\") as string;\n\n commands.add(`${getPackageManager()} exec tsc --noEmit --project ${tsconfigPath}`);\n } catch (error) {\n if (env[\"DEBUG\"]) {\n console.error(error);\n }\n }\n });\n\n return [...commands];\n },\n};\n\nexport default group;\n"]}
|
package/dist/chunk-LROKPUXN.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkVU6SMFTD_js = require('./chunk-VU6SMFTD.js');
|
|
4
|
-
var chunkP4FK54EG_js = require('./chunk-P4FK54EG.js');
|
|
5
|
-
var process = require('process');
|
|
6
|
-
|
|
7
|
-
var a={[`**/*.{${["ts","mts","cts"].join(",")}}`]:e=>{let o=new Set;return e.forEach(s=>{try{let t=chunkVU6SMFTD_js.a("tsconfig.json",s);o.add(`${chunkP4FK54EG_js.a()} exec tsc --noEmit --project ${t}`);}catch(t){process.env.DEBUG&&console.error(t);}}),[...o]}},m=a;
|
|
8
|
-
|
|
9
|
-
exports.a = m;
|
|
10
|
-
//# sourceMappingURL=out.js.map
|
|
11
|
-
//# sourceMappingURL=chunk-LROKPUXN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","get_package_manager_default","error","typescript_default"],"mappings":"gFAAA,OAAS,OAAAA,MAAW,UAOpB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,KAAM,MAAO,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,EAAIC,GAAwB,CACnE,IAAMC,EAAW,IAAI,IAErB,OAAAD,EAAU,QAASE,GAAa,CAC5B,GAAI,CAEA,IAAMC,EAAeC,EAAqB,gBAAiBF,CAAwB,EAEnFD,EAAS,IAAI,GAAGI,EAAkB,CAAC,gCAAgCF,CAAY,EAAE,CACrF,OAASG,EAAO,CACRR,EAAI,OACJ,QAAQ,MAAMQ,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGL,CAAQ,CACvB,CACJ,EAEOM,EAAQR","sourcesContent":["import { env } from \"node:process\";\n\nimport type { Config } from \"lint-staged\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\nimport getPackageManager from \"../utils/get-package-manager\";\n\nconst group: Config = {\n [`**/*.{${[\"ts\", \"mts\", \"cts\"].join(\",\")}}`]: (filenames: string[]) => {\n const commands = new Set<string>();\n\n filenames.forEach((filePath) => {\n try {\n // eslint-disable-next-line no-template-curly-in-string\n const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\") as string;\n\n commands.add(`${getPackageManager()} exec tsc --noEmit --project ${tsconfigPath}`);\n } catch (error) {\n if (env[\"DEBUG\"]) {\n console.error(error);\n }\n }\n });\n\n return [...commands];\n },\n};\n\nexport default group;\n"]}
|
package/dist/chunk-SAPGJRYB.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkVU6SMFTD_js = require('./chunk-VU6SMFTD.js');
|
|
4
|
-
var chunkKP7AH4EU_js = require('./chunk-KP7AH4EU.js');
|
|
5
|
-
var chunkP4FK54EG_js = require('./chunk-P4FK54EG.js');
|
|
6
|
-
var packageJsonUtils = require('@anolilab/package-json-utils');
|
|
7
|
-
var path = require('path');
|
|
8
|
-
var eslint = require('eslint');
|
|
9
|
-
var shellQuote = require('shell-quote');
|
|
10
|
-
|
|
11
|
-
!global.anolilabLintStagedPackageJsonConfig&&packageJsonUtils.pkg&&(global.anolilabLintStagedPackageJsonConfig=packageJsonUtils.pkg.anolilab?.["lint-staged-config"]);var S=global.anolilabLintStagedPackageJsonConfig??{},h=S;var F=n=>{let t={};return n.forEach(s=>{let i=path.dirname(s);t[i]||(t[i]=[]),t[i].push(s);}),t},b=F;var A=async n=>{let t=new eslint.ESLint,i=(await Promise.allSettled(n.map(async e=>await t.isPathIgnored(e)))).map(e=>{if(e.status==="fulfilled")return e.value;throw console.error(`
|
|
12
|
-
Unable to determine if file is ignored.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
${e.reason}`),new Error("Stopping lint-staged because of an error.")});return n.filter((e,r)=>!i[r]).map(e=>`"${chunkKP7AH4EU_js.a?e:shellQuote.quote([e])}"`)},w=A;var o=h?.settings?.eslint??{},c=[];(packageJsonUtils.hasDependency("eslint-plugin-react-hooks")||packageJsonUtils.hasDevDependency("eslint-plugin-react-hooks"))&&c.push("react-hooks/exhaustive-deps:off");(packageJsonUtils.hasDependency("eslint-plugin-eslint-comments")||packageJsonUtils.hasDevDependency("eslint-plugin-eslint-comments")||packageJsonUtils.isPackageAvailable("eslint-plugin-eslint-comments"))&&c.push("eslint-comments/no-unused-disable:off");var a=".eslintrc",D=()=>{let n=[];o["max-warnings"]!==void 0&&Number.isNaN(o["max-warnings"])?n.push(`--max-warnings=${o["max-warnings"]}`):o["max-warnings"]!==!1&&n.push("--max-warnings=0");let t=[...o.rules??[],...c].filter(i=>i.trim().length>0);t.length>0&&n.push(t.map(i=>`--rule "${i}"`).join(" "));let s=[...o["fix-type"]??["layout"]].filter(i=>i.trim().length>0);return s.length>0&&n.push(`--fix-type ${s.join(",")}`,"--fix"),o.cache&&n.push("--cache"),n},M=async n=>{let t=await w(n),s=D();if(o.config)return s.push(`--config ${o.config}`),[`${chunkP4FK54EG_js.a()} exec eslint ${s.join(" ")} ${t.join(" ")}`];let i=b(t),g=[];return Object.values(i).forEach(e=>{let r;[a,`${a}.js`,`${a}.cjs`,`${a}.json`,`${a}.yaml`,`${a}.yml`].forEach(j=>{if(!r)try{r=chunkVU6SMFTD_js.a(j,e[0]);}catch{}}),r&&g.push(`${chunkP4FK54EG_js.a()} exec eslint ${s.join(" ")} --config ${r} ${e.join(" ")}`);}),g},m=M;var C=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml"];global.hasAnolilabLintStagedMarkdownCli||(global.hasAnolilabLintStagedMarkdownCli=packageJsonUtils.hasDependency("markdownlint-cli")||packageJsonUtils.hasDevDependency("markdownlint-cli"));global.hasAnolilabLintStagedMarkdownCli2||(global.hasAnolilabLintStagedMarkdownCli2=packageJsonUtils.hasDependency("markdownlint-cli2")||packageJsonUtils.hasDevDependency("markdownlint-cli2"));!global.hasAnolilabLintStagedMarkdownCli&&!global.hasAnolilabLintStagedMarkdownCli2&&C.push("md");var N={[`**/*.{${["json","json5","jsonc"].join(",")}}`]:async n=>[...await m(n)],[`**/*.{${[C].join(",")}}`]:async n=>[`${chunkP4FK54EG_js.a()} exec prettier --write ${chunkKP7AH4EU_js.b(n)}`,...await m(n)]},nn=N;
|
|
16
|
-
|
|
17
|
-
exports.a = h;
|
|
18
|
-
exports.b = nn;
|
|
19
|
-
//# sourceMappingURL=out.js.map
|
|
20
|
-
//# sourceMappingURL=chunk-SAPGJRYB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/groups/eslint/index.ts","../src/groups/eslint/create-eslint-commands.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts"],"names":["hasDependency","hasDevDependency","isPackageAvailable","pkg","config","lint_staged_config_default","dirname","groupFilePathsByDirectoryName","filePaths","groups","filePath","directoryName","group_file_paths_by_directory_name_default","ESLint","quote","removeIgnoredFiles","filenames","eslint","ignoredFiles","filename","promise","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","fixType","type","createEslintCommands","filteredFiles","get_package_manager_default","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"+HAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,iBAAA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CAAU,MAAO,GAAGA,CAAU,OAAQ,GAAGA,CAAU,QAAS,GAAGA,CAAU,QAAS,GAAGA,CAAU,MAAM,EAAE,QAASY,GAAe,CAC3I,GAAI,CAAAnC,EAIJ,GAAI,CAEAA,EAASoC,EAAqBD,EAAY/B,EAAU,CAAC,CAAiB,CAC1E,MAAQ,CAER,CACJ,CAAC,EAEGJ,GACAkC,EAAe,KAAK,GAAGF,EAAkB,CAAC,gBAAgBP,EAAgB,KAAK,GAAG,CAAC,aAAazB,CAAM,IAAII,EAAU,KAAK,GAAG,CAAC,EAAE,CAEvI,CAAC,EAEM8B,CACX,EAEOG,EAAQP,EDzHf,IAAMQ,EAAa,CAAC,MAAO,KAAM,MAAO,MAAO,KAAM,MAAO,MAAO,OAAQ,MAAO,MAAO,MAAO,MAAM,EAEjG,OAAO,mCACR,OAAO,iCAAmC1C,EAAc,kBAAkB,GAAKC,EAAiB,kBAAkB,GAGjH,OAAO,oCACR,OAAO,kCAAoCD,EAAc,mBAAmB,GAAKC,EAAiB,mBAAmB,GAGrH,CAAC,OAAO,kCAAoC,CAAC,OAAO,mCACpDyC,EAAW,KAAK,IAAI,EAGxB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,OAAQ,QAAS,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO3B,GAAwB,CAAC,GAAI,MAAMyB,EAAqBzB,CAAS,CAAE,EAC9H,CAAC,SAAS,CAAC0B,CAAU,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO1B,GAAwB,CACjE,GAAGoB,EAAkB,CAAC,0BAA0BQ,EAAY5B,CAAS,CAAC,GACtE,GAAI,MAAMyB,EAAqBzB,CAAS,CAC5C,CACJ,EAEO6B,GAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\nimport getPackageManager from \"../../utils/get-package-manager\";\nimport createEslintCommands from \"./create-eslint-commands\";\n\nconst extensions = [\"cjs\", \"js\", \"mjs\", \"cts\", \"ts\", \"mts\", \"yml\", \"yaml\", \"jsx\", \"tsx\", \"mdx\", \"toml\"];\n\nif (!global.hasAnolilabLintStagedMarkdownCli) {\n global.hasAnolilabLintStagedMarkdownCli = hasDependency(\"markdownlint-cli\") || hasDevDependency(\"markdownlint-cli\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli2) {\n global.hasAnolilabLintStagedMarkdownCli2 = hasDependency(\"markdownlint-cli2\") || hasDevDependency(\"markdownlint-cli2\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMarkdownCli2) {\n extensions.push(\"md\");\n}\n\nconst group: Config = {\n [`**/*.{${[\"json\", \"json5\", \"jsonc\"].join(\",\")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],\n [`**/*.{${[extensions].join(\",\")}}`]: async (filenames: string[]) => [\n `${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\n","import { hasDependency, hasDevDependency, isPackageAvailable } from \"@anolilab/package-json-utils\";\n\nimport getNearestConfigPath from \"../../utils/get-nearest-config-path\";\nimport getPackageManager from \"../../utils/get-package-manager\";\nimport anolilabLintStagedConfig from \"../../utils/lint-staged-config\";\nimport groupFilePathsByDirectoryName from \"./group-file-paths-by-directory-name\";\nimport removeIgnoredFiles from \"./remove-ignored-files\";\n\ninterface EslintConfig {\n cache?: boolean;\n config?: string;\n \"fix-type\"?: string[];\n \"max-warnings\"?: number | string | false;\n rules?: string[];\n}\n\ninterface ESLintSettings {\n settings?: {\n eslint?: EslintConfig;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nconst eslintSettings: EslintConfig = (anolilabLintStagedConfig as ESLintSettings)?.settings?.eslint ?? ({} as EslintConfig);\n\nconst eslintGlobalRulesForFix: string[] = [];\n\nif (hasDependency(\"eslint-plugin-react-hooks\") || hasDevDependency(\"eslint-plugin-react-hooks\")) {\n // react-hooks/eslint and react in general is very strict about exhaustively\n // declaring the dependencies when using the useEffect, useCallback... hooks.\n //\n // In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable\n // by the developer, leading to some exceptions in the code. That said it should be avoided.\n //\n // While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to\n // automatically fix it from lint-staged as it can potentially break a legit intent.\n //\n // Reminder that a good practice is to always declare the dependencies when using the hooks,\n // and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:\n //\n // // eslint-disable-next-line react-hooks/exhaustive-deps\n //\n // Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass\n // shallow rendering limitations.\n //\n // @see https://reactjs.org/docs/hooks-rules.html\n // @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments\n eslintGlobalRulesForFix.push(\"react-hooks/exhaustive-deps:off\");\n}\n\nif (\n hasDependency(\"eslint-plugin-eslint-comments\") ||\n hasDevDependency(\"eslint-plugin-eslint-comments\") ||\n isPackageAvailable(\"eslint-plugin-eslint-comments\")\n) {\n eslintGlobalRulesForFix.push(\"eslint-comments/no-unused-disable:off\");\n}\n\nconst configFile = \".eslintrc\";\n\nconst createEslintArguments = (): string[] => {\n const eslintArguments: string[] = [];\n\n if (eslintSettings[\"max-warnings\"] !== undefined && Number.isNaN(eslintSettings[\"max-warnings\"])) {\n eslintArguments.push(`--max-warnings=${eslintSettings[\"max-warnings\"]}`);\n } else if (eslintSettings[\"max-warnings\"] !== false) {\n eslintArguments.push(\"--max-warnings=0\");\n }\n\n const rules = [...(eslintSettings.rules ?? []), ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0);\n\n if (rules.length > 0) {\n eslintArguments.push(rules.map((rule) => `--rule \"${rule}\"`).join(\" \"));\n }\n\n // For lint-staged it's safer to not apply the fix command if it changes the AST\n // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type\n const fixType = [...(eslintSettings[\"fix-type\"] ?? [\"layout\"])].filter((type) => type.trim().length > 0);\n\n if (fixType.length > 0) {\n eslintArguments.push(`--fix-type ${fixType.join(\",\")}`, \"--fix\");\n }\n\n if (eslintSettings.cache) {\n eslintArguments.push(\"--cache\");\n }\n\n return eslintArguments;\n};\n\nconst createEslintCommands = async (filenames: string[]): Promise<string[]> => {\n const filteredFiles = await removeIgnoredFiles(filenames);\n\n const eslintArguments = createEslintArguments();\n\n if (eslintSettings.config) {\n eslintArguments.push(`--config ${eslintSettings.config}`);\n\n return [`${getPackageManager()} exec eslint ${eslintArguments.join(\" \")} ${filteredFiles.join(\" \")}`];\n }\n\n const groupedFilesNames = groupFilePathsByDirectoryName(filteredFiles);\n const eslintCommands: string[] = [];\n\n Object.values(groupedFilesNames).forEach((filePaths) => {\n let config: string | undefined;\n\n [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`].forEach((configName) => {\n if (config) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-template-curly-in-string\n config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\") as string;\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`${getPackageManager()} exec eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n","import { pkg } from \"@anolilab/package-json-utils\";\n\nif (!global.anolilabLintStagedPackageJsonConfig && pkg) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n global.anolilabLintStagedPackageJsonConfig = pkg[\"anolilab\"]?.[\"lint-staged-config\"];\n}\n\nconst config: Record<string, boolean | undefined> = global.anolilabLintStagedPackageJsonConfig ?? {};\n\nexport default config;\n","import { dirname } from \"node:path\";\n\nconst groupFilePathsByDirectoryName = (filePaths: string[]): Record<string, string[]> => {\n const groups: Record<string, string[]> = {};\n\n filePaths.forEach((filePath) => {\n const directoryName = dirname(filePath);\n\n // eslint-disable-next-line security/detect-object-injection\n if (!groups[directoryName]) {\n // eslint-disable-next-line security/detect-object-injection\n groups[directoryName] = [];\n }\n // eslint-disable-next-line security/detect-object-injection\n (groups[directoryName] as string[]).push(filePath);\n });\n\n return groups;\n};\n\nexport default groupFilePathsByDirectoryName;\n","import { ESLint } from \"eslint\";\nimport { quote } from \"shell-quote\";\n\nimport isWindows from \"../../utils/is-windows\";\n\nconst removeIgnoredFiles = async (filenames: string[]): Promise<string[]> => {\n const eslint = new ESLint();\n // eslint-disable-next-line compat/compat\n const promises = await Promise.allSettled(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\n const ignoredFiles = promises.map((promise) => {\n if (promise.status === \"fulfilled\") {\n return promise.value;\n }\n\n console.error(`\\nUnable to determine if file is ignored.\\n\\n\\n${promise.reason}`);\n\n throw new Error(\"Stopping lint-staged because of an error.\");\n });\n\n // eslint-disable-next-line security/detect-object-injection\n const filteredFiles = filenames.filter((_, index) => !ignoredFiles[index]);\n\n return filteredFiles.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`);\n};\n\nexport default removeIgnoredFiles;\n"]}
|
package/dist/chunk-UFMJP5NU.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { a as a$2 } from './chunk-HGDREIGE.mjs';
|
|
2
|
-
import { b as b$1, a as a$3 } from './chunk-PP4XAK3E.mjs';
|
|
3
|
-
import { a as a$1 } from './chunk-COM4XKFJ.mjs';
|
|
4
|
-
import { pkg, hasDependency, hasDevDependency, isPackageAvailable } from '@anolilab/package-json-utils';
|
|
5
|
-
import { dirname } from 'path';
|
|
6
|
-
import { ESLint } from 'eslint';
|
|
7
|
-
import { quote } from 'shell-quote';
|
|
8
|
-
|
|
9
|
-
!global.anolilabLintStagedPackageJsonConfig&&pkg&&(global.anolilabLintStagedPackageJsonConfig=pkg.anolilab?.["lint-staged-config"]);var S=global.anolilabLintStagedPackageJsonConfig??{},h=S;var F=n=>{let t={};return n.forEach(s=>{let i=dirname(s);t[i]||(t[i]=[]),t[i].push(s);}),t},b=F;var A=async n=>{let t=new ESLint,i=(await Promise.allSettled(n.map(async e=>await t.isPathIgnored(e)))).map(e=>{if(e.status==="fulfilled")return e.value;throw console.error(`
|
|
10
|
-
Unable to determine if file is ignored.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
${e.reason}`),new Error("Stopping lint-staged because of an error.")});return n.filter((e,r)=>!i[r]).map(e=>`"${a$3?e:quote([e])}"`)},w=A;var o=h?.settings?.eslint??{},c=[];(hasDependency("eslint-plugin-react-hooks")||hasDevDependency("eslint-plugin-react-hooks"))&&c.push("react-hooks/exhaustive-deps:off");(hasDependency("eslint-plugin-eslint-comments")||hasDevDependency("eslint-plugin-eslint-comments")||isPackageAvailable("eslint-plugin-eslint-comments"))&&c.push("eslint-comments/no-unused-disable:off");var a=".eslintrc",D=()=>{let n=[];o["max-warnings"]!==void 0&&Number.isNaN(o["max-warnings"])?n.push(`--max-warnings=${o["max-warnings"]}`):o["max-warnings"]!==!1&&n.push("--max-warnings=0");let t=[...o.rules??[],...c].filter(i=>i.trim().length>0);t.length>0&&n.push(t.map(i=>`--rule "${i}"`).join(" "));let s=[...o["fix-type"]??["layout"]].filter(i=>i.trim().length>0);return s.length>0&&n.push(`--fix-type ${s.join(",")}`,"--fix"),o.cache&&n.push("--cache"),n},M=async n=>{let t=await w(n),s=D();if(o.config)return s.push(`--config ${o.config}`),[`${a$1()} exec eslint ${s.join(" ")} ${t.join(" ")}`];let i=b(t),g=[];return Object.values(i).forEach(e=>{let r;[a,`${a}.js`,`${a}.cjs`,`${a}.json`,`${a}.yaml`,`${a}.yml`].forEach(j=>{if(!r)try{r=a$2(j,e[0]);}catch{}}),r&&g.push(`${a$1()} exec eslint ${s.join(" ")} --config ${r} ${e.join(" ")}`);}),g},m=M;var C=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml"];global.hasAnolilabLintStagedMarkdownCli||(global.hasAnolilabLintStagedMarkdownCli=hasDependency("markdownlint-cli")||hasDevDependency("markdownlint-cli"));global.hasAnolilabLintStagedMarkdownCli2||(global.hasAnolilabLintStagedMarkdownCli2=hasDependency("markdownlint-cli2")||hasDevDependency("markdownlint-cli2"));!global.hasAnolilabLintStagedMarkdownCli&&!global.hasAnolilabLintStagedMarkdownCli2&&C.push("md");var N={[`**/*.{${["json","json5","jsonc"].join(",")}}`]:async n=>[...await m(n)],[`**/*.{${[C].join(",")}}`]:async n=>[`${a$1()} exec prettier --write ${b$1(n)}`,...await m(n)]},nn=N;
|
|
14
|
-
|
|
15
|
-
export { h as a, nn as b };
|
|
16
|
-
//# sourceMappingURL=out.js.map
|
|
17
|
-
//# sourceMappingURL=chunk-UFMJP5NU.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/groups/eslint/index.ts","../src/groups/eslint/create-eslint-commands.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts"],"names":["hasDependency","hasDevDependency","isPackageAvailable","pkg","config","lint_staged_config_default","dirname","groupFilePathsByDirectoryName","filePaths","groups","filePath","directoryName","group_file_paths_by_directory_name_default","ESLint","quote","removeIgnoredFiles","filenames","eslint","ignoredFiles","filename","promise","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","fixType","type","createEslintCommands","filteredFiles","get_package_manager_default","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"kIAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,iBAAAD,EAAe,oBAAAC,EAAkB,sBAAAC,MAA0B,+BCApE,OAAS,OAAAC,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,EAAI,WAAc,oBAAoB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AAI,CAEAA,EAASoC,EAAqBD,EAAY/B,EAAU,CAAC,CAAiB,CAC1E,MAAQ,CAER,CACJ,CAAC,EAEGJ,GACAkC,EAAe,KAAK,GAAGF,EAAkB,CAAC,gBAAgBP,EAAgB,KAAK,GAAG,CAAC,aAAazB,CAAM,IAAII,EAAU,KAAK,GAAG,CAAC,EAAE,CAEvI,CAAC,EAEM8B,CACX,EAEOG,EAAQP,EDzHf,IAAMQ,EAAa,CAAC,MAAO,KAAM,MAAO,MAAO,KAAM,MAAO,MAAO,OAAQ,MAAO,MAAO,MAAO,MAAM,EAEjG,OAAO,mCACR,OAAO,iCAAmC1C,EAAc,kBAAkB,GAAKC,EAAiB,kBAAkB,GAGjH,OAAO,oCACR,OAAO,kCAAoCD,EAAc,mBAAmB,GAAKC,EAAiB,mBAAmB,GAGrH,CAAC,OAAO,kCAAoC,CAAC,OAAO,mCACpDyC,EAAW,KAAK,IAAI,EAGxB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,OAAQ,QAAS,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO3B,GAAwB,CAAC,GAAI,MAAMyB,EAAqBzB,CAAS,CAAE,EAC9H,CAAC,SAAS,CAAC0B,CAAU,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO1B,GAAwB,CACjE,GAAGoB,EAAkB,CAAC,0BAA0BQ,EAAY5B,CAAS,CAAC,GACtE,GAAI,MAAMyB,EAAqBzB,CAAS,CAC5C,CACJ,EAEO6B,GAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\nimport getPackageManager from \"../../utils/get-package-manager\";\nimport createEslintCommands from \"./create-eslint-commands\";\n\nconst extensions = [\"cjs\", \"js\", \"mjs\", \"cts\", \"ts\", \"mts\", \"yml\", \"yaml\", \"jsx\", \"tsx\", \"mdx\", \"toml\"];\n\nif (!global.hasAnolilabLintStagedMarkdownCli) {\n global.hasAnolilabLintStagedMarkdownCli = hasDependency(\"markdownlint-cli\") || hasDevDependency(\"markdownlint-cli\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli2) {\n global.hasAnolilabLintStagedMarkdownCli2 = hasDependency(\"markdownlint-cli2\") || hasDevDependency(\"markdownlint-cli2\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMarkdownCli2) {\n extensions.push(\"md\");\n}\n\nconst group: Config = {\n [`**/*.{${[\"json\", \"json5\", \"jsonc\"].join(\",\")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],\n [`**/*.{${[extensions].join(\",\")}}`]: async (filenames: string[]) => [\n `${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\n","import { hasDependency, hasDevDependency, isPackageAvailable } from \"@anolilab/package-json-utils\";\n\nimport getNearestConfigPath from \"../../utils/get-nearest-config-path\";\nimport getPackageManager from \"../../utils/get-package-manager\";\nimport anolilabLintStagedConfig from \"../../utils/lint-staged-config\";\nimport groupFilePathsByDirectoryName from \"./group-file-paths-by-directory-name\";\nimport removeIgnoredFiles from \"./remove-ignored-files\";\n\ninterface EslintConfig {\n cache?: boolean;\n config?: string;\n \"fix-type\"?: string[];\n \"max-warnings\"?: number | string | false;\n rules?: string[];\n}\n\ninterface ESLintSettings {\n settings?: {\n eslint?: EslintConfig;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nconst eslintSettings: EslintConfig = (anolilabLintStagedConfig as ESLintSettings)?.settings?.eslint ?? ({} as EslintConfig);\n\nconst eslintGlobalRulesForFix: string[] = [];\n\nif (hasDependency(\"eslint-plugin-react-hooks\") || hasDevDependency(\"eslint-plugin-react-hooks\")) {\n // react-hooks/eslint and react in general is very strict about exhaustively\n // declaring the dependencies when using the useEffect, useCallback... hooks.\n //\n // In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable\n // by the developer, leading to some exceptions in the code. That said it should be avoided.\n //\n // While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to\n // automatically fix it from lint-staged as it can potentially break a legit intent.\n //\n // Reminder that a good practice is to always declare the dependencies when using the hooks,\n // and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:\n //\n // // eslint-disable-next-line react-hooks/exhaustive-deps\n //\n // Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass\n // shallow rendering limitations.\n //\n // @see https://reactjs.org/docs/hooks-rules.html\n // @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments\n eslintGlobalRulesForFix.push(\"react-hooks/exhaustive-deps:off\");\n}\n\nif (\n hasDependency(\"eslint-plugin-eslint-comments\") ||\n hasDevDependency(\"eslint-plugin-eslint-comments\") ||\n isPackageAvailable(\"eslint-plugin-eslint-comments\")\n) {\n eslintGlobalRulesForFix.push(\"eslint-comments/no-unused-disable:off\");\n}\n\nconst configFile = \".eslintrc\";\n\nconst createEslintArguments = (): string[] => {\n const eslintArguments: string[] = [];\n\n if (eslintSettings[\"max-warnings\"] !== undefined && Number.isNaN(eslintSettings[\"max-warnings\"])) {\n eslintArguments.push(`--max-warnings=${eslintSettings[\"max-warnings\"]}`);\n } else if (eslintSettings[\"max-warnings\"] !== false) {\n eslintArguments.push(\"--max-warnings=0\");\n }\n\n const rules = [...(eslintSettings.rules ?? []), ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0);\n\n if (rules.length > 0) {\n eslintArguments.push(rules.map((rule) => `--rule \"${rule}\"`).join(\" \"));\n }\n\n // For lint-staged it's safer to not apply the fix command if it changes the AST\n // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type\n const fixType = [...(eslintSettings[\"fix-type\"] ?? [\"layout\"])].filter((type) => type.trim().length > 0);\n\n if (fixType.length > 0) {\n eslintArguments.push(`--fix-type ${fixType.join(\",\")}`, \"--fix\");\n }\n\n if (eslintSettings.cache) {\n eslintArguments.push(\"--cache\");\n }\n\n return eslintArguments;\n};\n\nconst createEslintCommands = async (filenames: string[]): Promise<string[]> => {\n const filteredFiles = await removeIgnoredFiles(filenames);\n\n const eslintArguments = createEslintArguments();\n\n if (eslintSettings.config) {\n eslintArguments.push(`--config ${eslintSettings.config}`);\n\n return [`${getPackageManager()} exec eslint ${eslintArguments.join(\" \")} ${filteredFiles.join(\" \")}`];\n }\n\n const groupedFilesNames = groupFilePathsByDirectoryName(filteredFiles);\n const eslintCommands: string[] = [];\n\n Object.values(groupedFilesNames).forEach((filePaths) => {\n let config: string | undefined;\n\n [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`].forEach((configName) => {\n if (config) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-template-curly-in-string\n config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\") as string;\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`${getPackageManager()} exec eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n","import { pkg } from \"@anolilab/package-json-utils\";\n\nif (!global.anolilabLintStagedPackageJsonConfig && pkg) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n global.anolilabLintStagedPackageJsonConfig = pkg[\"anolilab\"]?.[\"lint-staged-config\"];\n}\n\nconst config: Record<string, boolean | undefined> = global.anolilabLintStagedPackageJsonConfig ?? {};\n\nexport default config;\n","import { dirname } from \"node:path\";\n\nconst groupFilePathsByDirectoryName = (filePaths: string[]): Record<string, string[]> => {\n const groups: Record<string, string[]> = {};\n\n filePaths.forEach((filePath) => {\n const directoryName = dirname(filePath);\n\n // eslint-disable-next-line security/detect-object-injection\n if (!groups[directoryName]) {\n // eslint-disable-next-line security/detect-object-injection\n groups[directoryName] = [];\n }\n // eslint-disable-next-line security/detect-object-injection\n (groups[directoryName] as string[]).push(filePath);\n });\n\n return groups;\n};\n\nexport default groupFilePathsByDirectoryName;\n","import { ESLint } from \"eslint\";\nimport { quote } from \"shell-quote\";\n\nimport isWindows from \"../../utils/is-windows\";\n\nconst removeIgnoredFiles = async (filenames: string[]): Promise<string[]> => {\n const eslint = new ESLint();\n // eslint-disable-next-line compat/compat\n const promises = await Promise.allSettled(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\n const ignoredFiles = promises.map((promise) => {\n if (promise.status === \"fulfilled\") {\n return promise.value;\n }\n\n console.error(`\\nUnable to determine if file is ignored.\\n\\n\\n${promise.reason}`);\n\n throw new Error(\"Stopping lint-staged because of an error.\");\n });\n\n // eslint-disable-next-line security/detect-object-injection\n const filteredFiles = filenames.filter((_, index) => !ignoredFiles[index]);\n\n return filteredFiles.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`);\n};\n\nexport default removeIgnoredFiles;\n"]}
|