@anolilab/lint-staged-config 2.0.1 → 2.0.3

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 CHANGED
@@ -1,3 +1,45 @@
1
+ ## @anolilab/lint-staged-config [2.0.3](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@2.0.2...@anolilab/lint-staged-config@2.0.3) (2023-08-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Update package dependencies ([a8786f2](https://github.com/anolilab/javascript-style-guide/commit/a8786f219badb9ebd4af825d28be85d3d2eea89c))
7
+
8
+
9
+ ### Miscellaneous Chores
10
+
11
+ * Add eslint-disable for no-template-curly-in-string in typescript.ts ([56473a4](https://github.com/anolilab/javascript-style-guide/commit/56473a42821eb66ffe52835dd1e41d064da94983))
12
+ * **deps:** update all non-major dependencies ([#722](https://github.com/anolilab/javascript-style-guide/issues/722)) ([76b3c10](https://github.com/anolilab/javascript-style-guide/commit/76b3c10387d333541c84b39300db503d00f4f78f))
13
+ * **deps:** update devdependencies ([#724](https://github.com/anolilab/javascript-style-guide/issues/724)) ([4dc5902](https://github.com/anolilab/javascript-style-guide/commit/4dc5902b7a2fb5892923bf8eaedbe6f60cf0fce6))
14
+ * **deps:** update eslint ([5d2daef](https://github.com/anolilab/javascript-style-guide/commit/5d2daefe7d777a23b3c83535d3f3a51915942f20))
15
+
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * **@anolilab/package-json-utils:** upgraded to 3.0.3
21
+ * **@anolilab/semantic-release-preset:** upgraded to 6.0.3
22
+
23
+ ## @anolilab/lint-staged-config [2.0.2](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@2.0.1...@anolilab/lint-staged-config@2.0.2) (2023-07-26)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * included 'skip.js' in package.json for several packages ([1c84b33](https://github.com/anolilab/javascript-style-guide/commit/1c84b33435abc75666214632eba4566f36c78e1a))
29
+
30
+
31
+ ### Miscellaneous Chores
32
+
33
+ * **deps:** update dependency stylelint to v15.10.2 ([061c2cf](https://github.com/anolilab/javascript-style-guide/commit/061c2cff2e5b02d1decd2c01a07136cb042be7a9))
34
+ * Upgrade vite version in lint-staged-config ([ea52ad5](https://github.com/anolilab/javascript-style-guide/commit/ea52ad5e3bd672a2973f151bdf04ce6113980fce))
35
+
36
+
37
+
38
+ ### Dependencies
39
+
40
+ * **@anolilab/package-json-utils:** upgraded to 3.0.2
41
+ * **@anolilab/semantic-release-preset:** upgraded to 6.0.2
42
+
1
43
  ## @anolilab/lint-staged-config [2.0.1](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@2.0.0...@anolilab/lint-staged-config@2.0.1) (2023-07-19)
2
44
 
3
45
 
@@ -12,4 +12,4 @@ var shellQuote = require('shell-quote');
12
12
  exports.a = u;
13
13
  exports.b = K;
14
14
  //# sourceMappingURL=out.js.map
15
- //# sourceMappingURL=chunk-ZPLALNOC.js.map
15
+ //# sourceMappingURL=chunk-4XL6CMQH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/groups/eslint/index.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts","../src/groups/eslint/create-eslint-commands.ts"],"names":["hasDependency","hasDevDependency","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","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","r","fixType","type","createEslintCommands","filteredFiles","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"uFAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,OAAAC,MAA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,KAAK,GAAG,CAAC,aAAaxB,CAAM,IAAII,EAAU,KAAK,GAAG,CAAC,EAAE,CAElI,CAAC,EAEM6B,CACX,EAEOG,EAAQN,EJlHf,IAAMO,EAAa,CAAC,MAAO,KAAM,MAAO,MAAO,KAAM,MAAO,MAAO,OAAQ,MAAO,MAAO,MAAO,MAAM,EAEjG,OAAO,mCACR,OAAO,iCAAmCxC,EAAc,kBAAkB,GAAKC,EAAiB,kBAAkB,GAGjH,OAAO,oCACR,OAAO,kCAAoCD,EAAc,mBAAmB,GAAKC,EAAiB,mBAAmB,GAGrH,CAAC,OAAO,kCAAoC,CAAC,OAAO,mCACpDuC,EAAW,KAAK,IAAI,EAGxB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,OAAQ,QAAS,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO1B,GAAwB,CAAC,GAAI,MAAMwB,EAAqBxB,CAAS,CAAE,EAC9H,CAAC,SAAS,CAACyB,CAAU,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAOzB,GAAwB,CACjE,oBAAoB2B,EAAY3B,CAAS,CAAC,GAC1C,GAAI,MAAMwB,EAAqBxB,CAAS,CAC5C,CACJ,EAEO4B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\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 `prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\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","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { 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 ignoredFiles = await Promise.all(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\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","import getNearestConfigPath from \"../../utils/get-nearest-config-path\";\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 = [\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 \"react-hooks/exhaustive-deps: 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 = [];\n\n if (eslintSettings.rules !== undefined && Array.isArray(eslintSettings.rules)) {\n rules.push([...eslintSettings.rules, ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0).map((r) => `\"${r.trim()}\"`));\n } else {\n rules.push(eslintGlobalRulesForFix.map((r) => `\"${r.trim()}\"`));\n }\n\n if (rules.length > 0) {\n eslintArguments.push(`--rule ${rules.join(\" --rule \")}`);\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 [`cross-env NO_LOGS=true 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 config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\") as string;\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n"]}
1
+ {"version":3,"sources":["../src/groups/eslint/index.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts","../src/groups/eslint/create-eslint-commands.ts"],"names":["hasDependency","hasDevDependency","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","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","r","fixType","type","createEslintCommands","filteredFiles","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"uFAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,OAAAC,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,EAAI,WAAc,oBAAoB,GAGvF,IAAMC,EAA8C,OAAO,qCAAuC,CAAC,EAE5FC,EAAQD,ECTf,OAAS,WAAAE,MAAe,OAExB,IAAMC,EAAiCC,GAAkD,CACrF,IAAMC,EAAmC,CAAC,EAE1C,OAAAD,EAAU,QAASE,GAAa,CAC5B,IAAMC,EAAgBL,EAAQI,CAAQ,EAGjCD,EAAOE,CAAa,IAErBF,EAAOE,CAAa,EAAI,CAAC,GAG5BF,EAAOE,CAAa,EAAe,KAAKD,CAAQ,CACrD,CAAC,EAEMD,CACX,EAEOG,EAAQL,ECnBf,OAAS,UAAAM,MAAc,SACvB,OAAS,SAAAC,MAAa,cAItB,IAAMC,EAAqB,MAAOC,GAA2C,CACzE,IAAMC,EAAS,IAAIJ,EAEbK,EAAe,MAAM,QAAQ,IAAIF,EAAU,IAAI,MAAOG,GAAa,MAAMF,EAAO,cAAcE,CAAQ,CAAC,CAAC,EAI9G,OAFsBH,EAAU,OAAO,CAACI,EAAGC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,oBAAoB2B,EAAY3B,CAAS,CAAC,GAC1C,GAAI,MAAMwB,EAAqBxB,CAAS,CAC5C,CACJ,EAEO4B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\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 `prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\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","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { 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 ignoredFiles = await Promise.all(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\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","import getNearestConfigPath from \"../../utils/get-nearest-config-path\";\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 = [\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 \"react-hooks/exhaustive-deps: 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 = [];\n\n if (eslintSettings.rules !== undefined && Array.isArray(eslintSettings.rules)) {\n rules.push([...eslintSettings.rules, ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0).map((r) => `\"${r.trim()}\"`));\n } else {\n rules.push(eslintGlobalRulesForFix.map((r) => `\"${r.trim()}\"`));\n }\n\n if (rules.length > 0) {\n eslintArguments.push(`--rule ${rules.join(\" --rule \")}`);\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 [`cross-env NO_LOGS=true 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(`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n"]}
@@ -5,4 +5,4 @@ var e={[`**/*.{${["ts","mts","cts"].join(",")}}`]:n=>{let o=new Set;return n.for
5
5
 
6
6
  export { a };
7
7
  //# sourceMappingURL=out.js.map
8
- //# sourceMappingURL=chunk-475NPYYW.mjs.map
8
+ //# sourceMappingURL=chunk-FUJCV56D.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","error","typescript_default"],"mappings":"yCACA,OAAS,OAAAA,MAAW,UAIpB,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,CACA,IAAMC,EAAeC,EAAqB,gBAAiBF,CAAwB,EAEnFD,EAAS,IAAI,0BAA0BE,CAAY,EAAE,CACzD,OAASE,EAAP,CACMP,EAAI,OACJ,QAAQ,MAAMO,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGJ,CAAQ,CACvB,CACJ,EAEOK,EAAQP","sourcesContent":["import type { Config } from \"lint-staged\";\nimport { env } from \"node:process\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\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 const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\") as string;\n\n commands.add(`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"]}
1
+ {"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","error","typescript_default"],"mappings":"yCACA,OAAS,OAAAA,MAAW,UAIpB,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,0BAA0BE,CAAY,EAAE,CACzD,OAASE,EAAP,CACMP,EAAI,OACJ,QAAQ,MAAMO,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGJ,CAAQ,CACvB,CACJ,EAEOK,EAAQP","sourcesContent":["import type { Config } from \"lint-staged\";\nimport { env } from \"node:process\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\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(`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"]}
@@ -7,4 +7,4 @@ var e={[`**/*.{${["ts","mts","cts"].join(",")}}`]:n=>{let o=new Set;return n.for
7
7
 
8
8
  exports.a = a;
9
9
  //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=chunk-LGBPJJYW.js.map
10
+ //# sourceMappingURL=chunk-K4JGCNPB.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","error","typescript_default"],"mappings":"wCACA,OAAS,OAAAA,MAAW,UAIpB,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,CACA,IAAMC,EAAeC,EAAqB,gBAAiBF,CAAwB,EAEnFD,EAAS,IAAI,0BAA0BE,CAAY,EAAE,CACzD,OAASE,EAAP,CACMP,EAAI,OACJ,QAAQ,MAAMO,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGJ,CAAQ,CACvB,CACJ,EAEOK,EAAQP","sourcesContent":["import type { Config } from \"lint-staged\";\nimport { env } from \"node:process\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\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 const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\") as string;\n\n commands.add(`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"]}
1
+ {"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","error","typescript_default"],"mappings":"wCACA,OAAS,OAAAA,MAAW,UAIpB,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,0BAA0BE,CAAY,EAAE,CACzD,OAASE,EAAP,CACMP,EAAI,OACJ,QAAQ,MAAMO,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGJ,CAAQ,CACvB,CACJ,EAEOK,EAAQP","sourcesContent":["import type { Config } from \"lint-staged\";\nimport { env } from \"node:process\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\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(`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"]}
@@ -9,4 +9,4 @@ import { quote } from 'shell-quote';
9
9
 
10
10
  export { u as a, K as b };
11
11
  //# sourceMappingURL=out.js.map
12
- //# sourceMappingURL=chunk-V5RHC5X7.mjs.map
12
+ //# sourceMappingURL=chunk-WGTU26NP.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/groups/eslint/index.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts","../src/groups/eslint/create-eslint-commands.ts"],"names":["hasDependency","hasDevDependency","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","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","r","fixType","type","createEslintCommands","filteredFiles","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"yFAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,OAAAC,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,EAAI,WAAc,oBAAoB,GAGvF,IAAMC,EAA8C,OAAO,qCAAuC,CAAC,EAE5FC,EAAQD,ECTf,OAAS,WAAAE,MAAe,OAExB,IAAMC,EAAiCC,GAAkD,CACrF,IAAMC,EAAmC,CAAC,EAE1C,OAAAD,EAAU,QAASE,GAAa,CAC5B,IAAMC,EAAgBL,EAAQI,CAAQ,EAGjCD,EAAOE,CAAa,IAErBF,EAAOE,CAAa,EAAI,CAAC,GAG5BF,EAAOE,CAAa,EAAe,KAAKD,CAAQ,CACrD,CAAC,EAEMD,CACX,EAEOG,EAAQL,ECnBf,OAAS,UAAAM,MAAc,SACvB,OAAS,SAAAC,MAAa,cAItB,IAAMC,EAAqB,MAAOC,GAA2C,CACzE,IAAMC,EAAS,IAAIJ,EAEbK,EAAe,MAAM,QAAQ,IAAIF,EAAU,IAAI,MAAOG,GAAa,MAAMF,EAAO,cAAcE,CAAQ,CAAC,CAAC,EAI9G,OAFsBH,EAAU,OAAO,CAACI,EAAGC,IAAU,CAACH,EAAaG,CAAK,CAAC,E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C1C,GAAI,MAAMwB,EAAqBxB,CAAS,CAC5C,CACJ,EAEO4B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\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 `prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\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","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { 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 ignoredFiles = await Promise.all(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\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","import getNearestConfigPath from \"../../utils/get-nearest-config-path\";\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 = [\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 \"react-hooks/exhaustive-deps: 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 = [];\n\n if (eslintSettings.rules !== undefined && Array.isArray(eslintSettings.rules)) {\n rules.push([...eslintSettings.rules, ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0).map((r) => `\"${r.trim()}\"`));\n } else {\n rules.push(eslintGlobalRulesForFix.map((r) => `\"${r.trim()}\"`));\n }\n\n if (rules.length > 0) {\n eslintArguments.push(`--rule ${rules.join(\" --rule \")}`);\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 [`cross-env NO_LOGS=true 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 config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\") as string;\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n"]}
1
+ {"version":3,"sources":["../src/groups/eslint/index.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts","../src/groups/eslint/create-eslint-commands.ts"],"names":["hasDependency","hasDevDependency","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","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","r","fixType","type","createEslintCommands","filteredFiles","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"yFAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,OAAAC,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,EAAI,WAAc,oBAAoB,GAGvF,IAAMC,EAA8C,OAAO,qCAAuC,CAAC,EAE5FC,EAAQD,ECTf,OAAS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AAM,MAAO,MAAO,KAAM,MAAO,MAAO,OAAQ,MAAO,MAAO,MAAO,MAAM,EAEjG,OAAO,mCACR,OAAO,iCAAmCxC,EAAc,kBAAkB,GAAKC,EAAiB,kBAAkB,GAGjH,OAAO,oCACR,OAAO,kCAAoCD,EAAc,mBAAmB,GAAKC,EAAiB,mBAAmB,GAGrH,CAAC,OAAO,kCAAoC,CAAC,OAAO,mCACpDuC,EAAW,KAAK,IAAI,EAGxB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,OAAQ,QAAS,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO1B,GAAwB,CAAC,GAAI,MAAMwB,EAAqBxB,CAAS,CAAE,EAC9H,CAAC,SAAS,CAACyB,CAAU,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAOzB,GAAwB,CACjE,oBAAoB2B,EAAY3B,CAAS,CAAC,GAC1C,GAAI,MAAMwB,EAAqBxB,CAAS,CAC5C,CACJ,EAEO4B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\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 `prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\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","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { 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 ignoredFiles = await Promise.all(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\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","import getNearestConfigPath from \"../../utils/get-nearest-config-path\";\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 = [\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 \"react-hooks/exhaustive-deps: 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 = [];\n\n if (eslintSettings.rules !== undefined && Array.isArray(eslintSettings.rules)) {\n rules.push([...eslintSettings.rules, ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0).map((r) => `\"${r.trim()}\"`));\n } else {\n rules.push(eslintGlobalRulesForFix.map((r) => `\"${r.trim()}\"`));\n }\n\n if (rules.length > 0) {\n eslintArguments.push(`--rule ${rules.join(\" --rule \")}`);\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 [`cross-env NO_LOGS=true 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(`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n"]}
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkZPLALNOC_js = require('../../chunk-ZPLALNOC.js');
3
+ var chunk4XL6CMQH_js = require('../../chunk-4XL6CMQH.js');
4
4
  require('../../chunk-MUEXM65V.js');
5
5
  require('../../chunk-26UFUGBI.js');
6
6
 
7
7
 
8
8
 
9
- module.exports = chunkZPLALNOC_js.b;
9
+ module.exports = chunk4XL6CMQH_js.b;
10
10
  //# sourceMappingURL=out.js.map
11
11
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export { b as default } from '../../chunk-V5RHC5X7.mjs';
1
+ export { b as default } from '../../chunk-WGTU26NP.mjs';
2
2
  import '../../chunk-5L2ZI35J.mjs';
3
3
  import '../../chunk-32WCNCA6.mjs';
4
4
  //# sourceMappingURL=out.js.map
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkLGBPJJYW_js = require('../chunk-LGBPJJYW.js');
3
+ var chunkK4JGCNPB_js = require('../chunk-K4JGCNPB.js');
4
4
  require('../chunk-MUEXM65V.js');
5
5
 
6
6
 
7
7
 
8
- module.exports = chunkLGBPJJYW_js.a;
8
+ module.exports = chunkK4JGCNPB_js.a;
9
9
  //# sourceMappingURL=out.js.map
10
10
  //# sourceMappingURL=typescript.js.map
@@ -1,4 +1,4 @@
1
- export { a as default } from '../chunk-475NPYYW.mjs';
1
+ export { a as default } from '../chunk-FUJCV56D.mjs';
2
2
  import '../chunk-5L2ZI35J.mjs';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=typescript.mjs.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkLGBPJJYW_js = require('./chunk-LGBPJJYW.js');
4
- var chunkZPLALNOC_js = require('./chunk-ZPLALNOC.js');
3
+ var chunkK4JGCNPB_js = require('./chunk-K4JGCNPB.js');
4
+ var chunk4XL6CMQH_js = require('./chunk-4XL6CMQH.js');
5
5
  require('./chunk-MUEXM65V.js');
6
6
  var chunkGWSF22B6_js = require('./chunk-GWSF22B6.js');
7
7
  var chunkCZNOXHD3_js = require('./chunk-CZNOXHD3.js');
@@ -12,7 +12,7 @@ require('./chunk-26UFUGBI.js');
12
12
  var process = require('process');
13
13
  var packageJsonUtils = require('@anolilab/package-json-utils');
14
14
 
15
- var y=[{config:chunkZPLALNOC_js.b,configName:"eslint",dependencies:["prettier","eslint"]},{config:chunkGWSF22B6_js.a,configName:"json",dependencies:["prettier","sort-package-json"]},{config:chunkCZNOXHD3_js.a,configName:"markdown",dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{config:chunk6EWZW5LF_js.a,configName:"secretlint",dependencies:["secretlint"]},{config:chunkFZFCZD6I_js.a,configName:"stylesheets",dependencies:["stylelint"]},{config:chunkVAUDCZ4C_js.a,configName:"tests",dependencies:["vite","jest","ava"]},{config:chunkLGBPJJYW_js.a,configName:"typescript",dependencies:["typescript"]}],g={},r=[],a={};y.forEach(t=>{let{config:n,configName:i,dependencies:l}=t;if(chunkZPLALNOC_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(`
15
+ var y=[{config:chunk4XL6CMQH_js.b,configName:"eslint",dependencies:["prettier","eslint"]},{config:chunkGWSF22B6_js.a,configName:"json",dependencies:["prettier","sort-package-json"]},{config:chunkCZNOXHD3_js.a,configName:"markdown",dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{config:chunk6EWZW5LF_js.a,configName:"secretlint",dependencies:["secretlint"]},{config:chunkFZFCZD6I_js.a,configName:"stylesheets",dependencies:["stylelint"]},{config:chunkVAUDCZ4C_js.a,configName:"tests",dependencies:["vite","jest","ava"]},{config:chunkK4JGCNPB_js.a,configName:"typescript",dependencies:["typescript"]}],g={},r=[],a={};y.forEach(t=>{let{config:n,configName:i,dependencies:l}=t;if(chunk4XL6CMQH_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(`
16
16
  @anolilab/lint-stage-config loaded the following plugins:
17
17
  `),r.forEach(n=>{o(` ${n}`);}));let t=!1;Object.entries(a).forEach(([n,i])=>{Object.values(i).some(Boolean)&&(t=!0,o(`
18
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 CHANGED
@@ -1,5 +1,5 @@
1
- import { a as a$7 } from './chunk-475NPYYW.mjs';
2
- import { a as a$1, b } from './chunk-V5RHC5X7.mjs';
1
+ import { a as a$7 } from './chunk-FUJCV56D.mjs';
2
+ import { a as a$1, b } from './chunk-WGTU26NP.mjs';
3
3
  import './chunk-5L2ZI35J.mjs';
4
4
  import { a as a$2 } from './chunk-YBLR7X5F.mjs';
5
5
  import { a as a$3 } from './chunk-KNLP6LX4.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anolilab/lint-staged-config",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Shareable Lint-Staged Config for any project.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -79,6 +79,7 @@
79
79
  "types": "dist/index.d.ts",
80
80
  "files": [
81
81
  "dist",
82
+ "skip.js",
82
83
  "group",
83
84
  "README.md",
84
85
  "CHANGELOG.md",
@@ -93,37 +94,37 @@
93
94
  "test:coverage": "vitest --config ./vitest.config.ts --run --coverage"
94
95
  },
95
96
  "dependencies": {
96
- "@anolilab/package-json-utils": "3.0.1",
97
+ "@anolilab/package-json-utils": "3.0.3",
97
98
  "cross-env": "^7.0.3",
98
99
  "find-up": "5.0.0",
99
100
  "shell-quote": "^1.8.1"
100
101
  },
101
102
  "devDependencies": {
102
- "@anolilab/semantic-release-preset": "6.0.1",
103
+ "@anolilab/semantic-release-preset": "6.0.3",
103
104
  "@total-typescript/ts-reset": "^0.4.2",
104
105
  "@types/lint-staged": "^13.2.0",
105
106
  "@types/shell-quote": "^1.7.1",
106
- "@vitest/coverage-v8": "^0.33.0",
107
+ "@vitest/coverage-v8": "^0.34.1",
107
108
  "husky": "^8.0.3",
108
109
  "lint-staged": "^13.2.3",
109
110
  "rimraf": "^5.0.1",
110
111
  "semantic-release": "^21.0.7",
111
- "tsup": "^7.1.0",
112
- "type-fest": "^4.0.0",
112
+ "tsup": "^7.2.0",
113
+ "type-fest": "^4.1.0",
113
114
  "typescript": "5.1.6",
114
- "vitest": "^0.33.0"
115
+ "vitest": "^0.34.1"
115
116
  },
116
117
  "peerDependencies": {
117
118
  "husky": "^8.x",
118
119
  "lint-staged": "^13.x"
119
120
  },
120
121
  "optionalDependencies": {
121
- "eslint": "^8.45.0",
122
- "jest": "^29.6.1",
123
- "prettier": "^3.0.0",
122
+ "eslint": "^8.46.0",
123
+ "jest": "^29.6.2",
124
+ "prettier": "^3.0.1",
124
125
  "secretlint": "^7.0.3",
125
- "stylelint": "^15.10.1",
126
- "vite": "^4.4.4"
126
+ "stylelint": "^15.10.2",
127
+ "vite": "^4.4.8"
127
128
  },
128
129
  "engines": {
129
130
  "node": ">=18"
package/skip.js ADDED
@@ -0,0 +1,7 @@
1
+ if (process.env.SKIP_BUILD) {
2
+ // eslint-disable-next-line unicorn/no-process-exit
3
+ process.exit(0);
4
+ } else {
5
+ // eslint-disable-next-line unicorn/no-process-exit
6
+ process.exit(1);
7
+ }