@anolilab/eslint-config 7.2.2 → 7.2.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 +13 -0
- package/README.md +4 -2
- package/dist/postinstall.js +3 -3
- package/dist/postinstall.js.map +1 -1
- package/dist/postinstall.mjs +3 -3
- package/dist/postinstall.mjs.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## @anolilab/eslint-config [7.2.3](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/eslint-config@7.2.2...@anolilab/eslint-config@7.2.3) (2023-06-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* added mjs to the postinstall script ([cc098ed](https://github.com/anolilab/javascript-style-guide/commit/cc098ed5c63efa45562f35e6ebf6f13a68531228))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Miscellaneous Chores
|
|
10
|
+
|
|
11
|
+
* **deps:** update eslint ([1209404](https://github.com/anolilab/javascript-style-guide/commit/120940410a500066aa6f4e646a279cc6b801c0f3))
|
|
12
|
+
* update readme ([8350799](https://github.com/anolilab/javascript-style-guide/commit/8350799ea6e310d6f6d9af53d333b40e85180984))
|
|
13
|
+
|
|
1
14
|
## @anolilab/eslint-config [7.2.2](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/eslint-config@7.2.1...@anolilab/eslint-config@7.2.2) (2023-06-25)
|
|
2
15
|
|
|
3
16
|
|
package/README.md
CHANGED
|
@@ -32,8 +32,6 @@ Our package serves as a valuable resource for JavaScript/Typescript-based projec
|
|
|
32
32
|
|
|
33
33
|
In summary, our package provides comprehensive and adaptable ESLint configurations for JavaScript and Typescript projects. It empowers you to achieve code quality while minimizing overhead and maximizing productivity throughout your workspaces.
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
35
|
## Highlights
|
|
38
36
|
|
|
39
37
|
- Zero-config, but configurable when needed.
|
|
@@ -68,6 +66,10 @@ If you don’t have a `.eslintrc.js`, we will create the file for you after inst
|
|
|
68
66
|
|
|
69
67
|
If you already have a `.eslintrc.js`, then you can extend the `.eslintrc.js`, with `@anolilab/eslint-config`.
|
|
70
68
|
|
|
69
|
+
> Note: If the script detects an existing `.eslintrc.js` file, it will not overwrite it.
|
|
70
|
+
|
|
71
|
+
> Note: It can happen that the postinstall script don't run, then you have to add the `.eslintrc.js` manually.
|
|
72
|
+
|
|
71
73
|
> Note: Our default export contains all of our ESLint rules, including ECMAScript 6+. `@anolilab/eslint-config` use the `ecmaVersion`:`2021` as default.
|
|
72
74
|
>
|
|
73
75
|
> To change this configuration, change `env: { es2021: false, then active you needed env }` same for, `parserOptions: { "ecmaVersion": 2021 change the version }`
|
package/dist/postinstall.js
CHANGED
|
@@ -6,9 +6,9 @@ var path = require('path');
|
|
|
6
6
|
var util = require('util');
|
|
7
7
|
|
|
8
8
|
process.env.CI&&process.exit(0);var f=util.promisify(fs.writeFile);console.log("Configuring @anolilab/eslint-config",packageJsonUtils.projectPath,`
|
|
9
|
-
`);var
|
|
9
|
+
`);var t=".eslintrc",d=()=>{for(let o of [t,`${t}.js`,`${t}.cjs`,`${t}.mjs`,`${t}.json`,`${t}.yaml`,`${t}.yml`])if(fs.existsSync(path.join(packageJsonUtils.projectPath,o)))return console.warn(`\u26A0\uFE0F ${o} already exists;
|
|
10
10
|
Make sure that it includes the following for @anolilab/eslint-config'
|
|
11
|
-
to work as it should: { extends: ["@anolilab/eslint-config"] }.`),Promise.resolve();let
|
|
11
|
+
to work as it should: { extends: ["@anolilab/eslint-config"] }.`),Promise.resolve();let s=path.join(packageJsonUtils.projectPath,".eslintrc.js"),a="",c=`
|
|
12
12
|
parserOptions: {
|
|
13
13
|
ecmaVersion: "latest",
|
|
14
14
|
sourceType: ${packageJsonUtils.packageIsTypeModule?'"module"':'"commonjs"'},
|
|
@@ -60,6 +60,6 @@ ${packageJsonUtils.packageIsTypeModule?"export default":"module.exports ="} {
|
|
|
60
60
|
},
|
|
61
61
|
],
|
|
62
62
|
};
|
|
63
|
-
`;return f(
|
|
63
|
+
`;return f(s,m,"utf8")},w=()=>{let s=path.join(packageJsonUtils.projectPath,".eslintignore");return fs.existsSync(s)?(console.warn("\u26A0\uFE0F .eslintignore already exists"),Promise.resolve()):f(s,"","utf8")};(async()=>{try{await Promise.all([d(),w()]),console.log("\u{1F60E} Everything went well, have fun!"),process.exit(0);}catch(s){console.log("\u{1F62C} something went wrong:"),console.error(s),process.exit(1);}})();
|
|
64
64
|
//# sourceMappingURL=out.js.map
|
|
65
65
|
//# sourceMappingURL=postinstall.js.map
|
package/dist/postinstall.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/postinstall.ts"],"names":["packageIsTypeModule","projectPath","existsSync","readFileSync","writeFile","join","promisify","writeFileAsync","configFile","writeEslintRc","filename","eslintPath","pluginExtends","parserOptions","tsconfigPath","tsConfig","ecmaVersion","content","writeEslintIgnore","eslintIgnorePath","error"],"mappings":"AAAA,OAAS,uBAAAA,EAAqB,eAAAC,MAAmB,+BACjD,OAAS,cAAAC,EAAY,gBAAAC,EAAc,aAAAC,MAAiB,KACpD,OAAS,QAAAC,MAAY,OACrB,OAAS,aAAAC,MAAiB,OAGtB,QAAQ,IAAI,IAEZ,QAAQ,KAAK,CAAC,EAGlB,IAAMC,EAAiBD,EAAUF,CAAS,EAE1C,QAAQ,IAAI,sCAAuCH,EAAa;AAAA,CAAI,EAEpE,IAAMO,EAAa,YAMbC,EAAgB,IAAM,CAExB,QAAWC,IAAY,CAACF,EAAY,GAAGA,OAAiB,GAAGA,QAAkB,GAAGA,SAAmB,GAAGA,SAAmB,GAAGA,OAAgB,
|
|
1
|
+
{"version":3,"sources":["../src/postinstall.ts"],"names":["packageIsTypeModule","projectPath","existsSync","readFileSync","writeFile","join","promisify","writeFileAsync","configFile","writeEslintRc","filename","eslintPath","pluginExtends","par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AAa;AAAA,OAErD,CAEA,IAAMiB,EAAU;AAAA;AAAA,EAElBjB,EAAsB,iBAAmB;AAAA;AAAA,yCAEFY;AAAA;AAAA;AAAA;AAAA;AAAA,QAKjCC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoCJ,OAAON,EAAeI,EAAYM,EAAS,MAAM,CACrD,EAKMC,EAAoB,IAAM,CAC5B,IAAMC,EAAmBd,EAAKJ,EAAa,eAAe,EAE1D,OAAIC,EAAWiB,CAAgB,GAC3B,QAAQ,KAAK,4CAAkC,EAExC,QAAQ,QAAQ,GAGpBZ,EAAeY,EAAkB,GAAI,MAAM,CACtD,GAGC,SAAY,CACT,GAAI,CAEA,MAAM,QAAQ,IAAI,CAACV,EAAc,EAAGS,EAAkB,CAAC,CAAC,EAExD,QAAQ,IAAI,4CAAqC,EAGjD,QAAQ,KAAK,CAAC,CAClB,OAASE,EAAP,CACE,QAAQ,IAAI,kCAA2B,EACvC,QAAQ,MAAMA,CAAK,EAGnB,QAAQ,KAAK,CAAC,CAClB,CACJ,GAAG","sourcesContent":["import { packageIsTypeModule, projectPath } from \"@anolilab/package-json-utils\";\nimport { existsSync, readFileSync, writeFile } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport type { TsConfigJson } from \"type-fest\";\n\nif (process.env[\"CI\"]) {\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(0);\n}\n\nconst writeFileAsync = promisify(writeFile);\n\nconsole.log(\"Configuring @anolilab/eslint-config\", projectPath, \"\\n\");\n\nconst configFile = \".eslintrc\";\n\n/**\n * Writes .eslintrc.js if it doesn't exist. Warns if it exists.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeEslintRc = () => {\n // eslint-disable-next-line no-restricted-syntax\n for (const filename of [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.mjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`]) {\n if (existsSync(join(projectPath, filename))) {\n console.warn(`⚠️ ${filename} already exists;\nMake sure that it includes the following for @anolilab/eslint-config'\nto work as it should: { extends: [\"@anolilab/eslint-config\"] }.`);\n\n return Promise.resolve();\n }\n }\n\n const eslintPath = join(projectPath, \".eslintrc.js\");\n\n let pluginExtends = \"\";\n let parserOptions = `\n parserOptions: {\n ecmaVersion: \"latest\",\n sourceType: ${packageIsTypeModule ? '\"module\"' : '\"commonjs\"'},\n },`;\n\n const tsconfigPath = join(projectPath, \"tsconfig.json\");\n\n if (existsSync(tsconfigPath)) {\n const tsConfig = JSON.parse(readFileSync(tsconfigPath, \"utf8\")) as TsConfigJson;\n\n let ecmaVersion = \"latest\";\n\n if (tsConfig.compilerOptions?.target) {\n ecmaVersion = tsConfig.compilerOptions.target;\n\n ecmaVersion = ecmaVersion.toLowerCase() === \"es2022\" || ecmaVersion.toLowerCase() === \"esnext\" ? \"latest\" : ecmaVersion.toLowerCase().replace(\"es\", \"\");\n\n if (ecmaVersion !== \"latest\" && ecmaVersion !== \"2022\" && ecmaVersion !== \"2021\" && ecmaVersion !== \"6\") {\n pluginExtends = `, \"plugin:es-x/restrict-to-es${ecmaVersion}\"`;\n }\n }\n\n parserOptions = `\n parserOptions: {\n project: \"./tsconfig.json\",\n ecmaVersion: ${ecmaVersion === \"latest\" ? `\"${ecmaVersion}\"` : ecmaVersion},\n sourceType: ${packageIsTypeModule ? '\"module\"' : '\"commonjs\"'},\n },`;\n }\n\n const content = `/** @ts-check */\n/** @type {import('eslint').Linter.Config} */\n${packageIsTypeModule ? \"export default\" : \"module.exports =\"} {\n root: true,\n extends: [\"@anolilab/eslint-config\"${pluginExtends}],\n ignorePatterns: [\"!**/*\"],\n env: {\n // Your environments (which contains several predefined global variables)\n // Most environments are loaded automatically if our rules are added\n },${parserOptions}\n globals: {\n // Your global variables (setting to false means it's not allowed to be reassigned)\n // myGlobal: false\n },\n rules: {\n // Customize your rules\n },\n overrides: [\n {\n files: [\n \"*.ts\",\n \"*.tsx\",\n \"*.mts\",\n \"*.cts\",\n \"*.js\",\n \"*.jsx\",\n ],\n // Set parserOptions.project for the project to allow TypeScript to create the type-checker behind the scenes when we run linting\n parserOptions: {},\n rules: {},\n },\n {\n files: [\"*.ts\", \"*.tsx\", \"*.mts\", \"*.cts\"],\n // Set parserOptions.project for the project to allow TypeScript to create the type-checker behind the scenes when we run linting\n parserOptions: {},\n rules: {},\n },\n {\n files: [\"*.js\", \"*.jsx\"],\n rules: {},\n },\n ],\n};\n`;\n\n return writeFileAsync(eslintPath, content, \"utf8\");\n};\n\n/**\n * Writes .eslintignore if it doesn't exist. Warns if it exists.\n */\nconst writeEslintIgnore = () => {\n const eslintIgnorePath = join(projectPath, \".eslintignore\");\n\n if (existsSync(eslintIgnorePath)) {\n console.warn(\"⚠️ .eslintignore already exists\");\n\n return Promise.resolve();\n }\n\n return writeFileAsync(eslintIgnorePath, \"\", \"utf8\");\n};\n\n// eslint-disable-next-line unicorn/prefer-top-level-await\n(async () => {\n try {\n // eslint-disable-next-line compat/compat\n await Promise.all([writeEslintRc(), writeEslintIgnore()]);\n\n console.log(\"😎 Everything went well, have fun!\");\n\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(0);\n } catch (error) {\n console.log(\"😬 something went wrong:\");\n console.error(error);\n\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(1);\n }\n})();\n"]}
|
package/dist/postinstall.mjs
CHANGED
|
@@ -4,9 +4,9 @@ import { join } from 'path';
|
|
|
4
4
|
import { promisify } from 'util';
|
|
5
5
|
|
|
6
6
|
process.env.CI&&process.exit(0);var f=promisify(writeFile);console.log("Configuring @anolilab/eslint-config",projectPath,`
|
|
7
|
-
`);var
|
|
7
|
+
`);var t=".eslintrc",d=()=>{for(let o of [t,`${t}.js`,`${t}.cjs`,`${t}.mjs`,`${t}.json`,`${t}.yaml`,`${t}.yml`])if(existsSync(join(projectPath,o)))return console.warn(`\u26A0\uFE0F ${o} already exists;
|
|
8
8
|
Make sure that it includes the following for @anolilab/eslint-config'
|
|
9
|
-
to work as it should: { extends: ["@anolilab/eslint-config"] }.`),Promise.resolve();let
|
|
9
|
+
to work as it should: { extends: ["@anolilab/eslint-config"] }.`),Promise.resolve();let s=join(projectPath,".eslintrc.js"),a="",c=`
|
|
10
10
|
parserOptions: {
|
|
11
11
|
ecmaVersion: "latest",
|
|
12
12
|
sourceType: ${packageIsTypeModule?'"module"':'"commonjs"'},
|
|
@@ -58,6 +58,6 @@ ${packageIsTypeModule?"export default":"module.exports ="} {
|
|
|
58
58
|
},
|
|
59
59
|
],
|
|
60
60
|
};
|
|
61
|
-
`;return f(
|
|
61
|
+
`;return f(s,m,"utf8")},w=()=>{let s=join(projectPath,".eslintignore");return existsSync(s)?(console.warn("\u26A0\uFE0F .eslintignore already exists"),Promise.resolve()):f(s,"","utf8")};(async()=>{try{await Promise.all([d(),w()]),console.log("\u{1F60E} Everything went well, have fun!"),process.exit(0);}catch(s){console.log("\u{1F62C} something went wrong:"),console.error(s),process.exit(1);}})();
|
|
62
62
|
//# sourceMappingURL=out.js.map
|
|
63
63
|
//# sourceMappingURL=postinstall.mjs.map
|
package/dist/postinstall.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/postinstall.ts"],"names":["packageIsTypeModule","projectPath","existsSync","readFileSync","writeFile","join","promisify","writeFileAsync","configFile","writeEslintRc","filename","eslintPath","pluginExtends","parserOptions","tsconfigPath","tsConfig","ecmaVersion","content","writeEslintIgnore","eslintIgnorePath","error"],"mappings":"AAAA,OAAS,uBAAAA,EAAqB,eAAAC,MAAmB,+BACjD,OAAS,cAAAC,EAAY,gBAAAC,EAAc,aAAAC,MAAiB,KACpD,OAAS,QAAAC,MAAY,OACrB,OAAS,aAAAC,MAAiB,OAGtB,QAAQ,IAAI,IAEZ,QAAQ,KAAK,CAAC,EAGlB,IAAMC,EAAiBD,EAAUF,CAAS,EAE1C,QAAQ,IAAI,sCAAuCH,EAAa;AAAA,CAAI,EAEpE,IAAMO,EAAa,YAMbC,EAAgB,IAAM,CAExB,QAAWC,IAAY,CAACF,EAAY,GAAGA,OAAiB,GAAGA,QAAkB,GAAGA,SAAmB,GAAGA,SAAmB,GAAGA,OAAgB,
|
|
1
|
+
{"version":3,"sources":["../src/postinstall.ts"],"names":["packageIsTypeModule","projectPath","existsSync","readFileSync","writeFile","join","promisify","writeFileAsync","configFile","writeEslintRc","filename","eslintPath","pluginExtends","parserOptions","tsconfigPath","tsConfig","ecmaVersion","content","writeEslintIgnore","eslintIgnorePath","error"],"mappings":"AAAA,OAAS,uBAAAA,EAAqB,eAAAC,MAAmB,+BACjD,OAAS,cAAAC,EAAY,gBAAAC,EAAc,aAAAC,MAAiB,KACpD,OAAS,QAAAC,MAAY,OACrB,OAAS,aAAAC,MAAiB,OAGtB,QAAQ,IAAI,IAEZ,QAAQ,KAAK,CAAC,EAGlB,IAAMC,EAAiBD,EAAUF,CAAS,EAE1C,QAAQ,IAAI,sCAAuCH,EAAa;AAAA,CAAI,EAEpE,IAAMO,EAAa,YAMbC,EAAgB,IAAM,CAExB,QAAWC,IAAY,CAACF,EAAY,GAAGA,OAAiB,GAAGA,QAAkB,GAAGA,QAAkB,GAAGA,SAAmB,GAAGA,SAAmB,GAAGA,OAAgB,EAC7J,GAAIN,EAAWG,EAAKJ,EAAaS,CAAQ,CAAC,EACtC,eAAQ,KAAK,iBAAOA;AAAA;AAAA,gEAEgC,EAE7C,QAAQ,QAAQ,EAI/B,IAAMC,EAAaN,EAAKJ,EAAa,cAAc,EAE/CW,EAAgB,GAChBC,EAAgB;AAAA;AAAA;AAAA,sBAGFb,EAAsB,WAAa;AAAA,QAG/Cc,EAAeT,EAAKJ,EAAa,eAAe,EAEtD,GAAIC,EAAWY,CAAY,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,CACJ,GAAG","sourcesContent":["import { packageIsTypeModule, projectPath } from \"@anolilab/package-json-utils\";\nimport { existsSync, readFileSync, writeFile } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport type { TsConfigJson } from \"type-fest\";\n\nif (process.env[\"CI\"]) {\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(0);\n}\n\nconst writeFileAsync = promisify(writeFile);\n\nconsole.log(\"Configuring @anolilab/eslint-config\", projectPath, \"\\n\");\n\nconst configFile = \".eslintrc\";\n\n/**\n * Writes .eslintrc.js if it doesn't exist. Warns if it exists.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeEslintRc = () => {\n // eslint-disable-next-line no-restricted-syntax\n for (const filename of [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.mjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`]) {\n if (existsSync(join(projectPath, filename))) {\n console.warn(`⚠️ ${filename} already exists;\nMake sure that it includes the following for @anolilab/eslint-config'\nto work as it should: { extends: [\"@anolilab/eslint-config\"] }.`);\n\n return Promise.resolve();\n }\n }\n\n const eslintPath = join(projectPath, \".eslintrc.js\");\n\n let pluginExtends = \"\";\n let parserOptions = `\n parserOptions: {\n ecmaVersion: \"latest\",\n sourceType: ${packageIsTypeModule ? '\"module\"' : '\"commonjs\"'},\n },`;\n\n const tsconfigPath = join(projectPath, \"tsconfig.json\");\n\n if (existsSync(tsconfigPath)) {\n const tsConfig = JSON.parse(readFileSync(tsconfigPath, \"utf8\")) as TsConfigJson;\n\n let ecmaVersion = \"latest\";\n\n if (tsConfig.compilerOptions?.target) {\n ecmaVersion = tsConfig.compilerOptions.target;\n\n ecmaVersion = ecmaVersion.toLowerCase() === \"es2022\" || ecmaVersion.toLowerCase() === \"esnext\" ? \"latest\" : ecmaVersion.toLowerCase().replace(\"es\", \"\");\n\n if (ecmaVersion !== \"latest\" && ecmaVersion !== \"2022\" && ecmaVersion !== \"2021\" && ecmaVersion !== \"6\") {\n pluginExtends = `, \"plugin:es-x/restrict-to-es${ecmaVersion}\"`;\n }\n }\n\n parserOptions = `\n parserOptions: {\n project: \"./tsconfig.json\",\n ecmaVersion: ${ecmaVersion === \"latest\" ? `\"${ecmaVersion}\"` : ecmaVersion},\n sourceType: ${packageIsTypeModule ? '\"module\"' : '\"commonjs\"'},\n },`;\n }\n\n const content = `/** @ts-check */\n/** @type {import('eslint').Linter.Config} */\n${packageIsTypeModule ? \"export default\" : \"module.exports =\"} {\n root: true,\n extends: [\"@anolilab/eslint-config\"${pluginExtends}],\n ignorePatterns: [\"!**/*\"],\n env: {\n // Your environments (which contains several predefined global variables)\n // Most environments are loaded automatically if our rules are added\n },${parserOptions}\n globals: {\n // Your global variables (setting to false means it's not allowed to be reassigned)\n // myGlobal: false\n },\n rules: {\n // Customize your rules\n },\n overrides: [\n {\n files: [\n \"*.ts\",\n \"*.tsx\",\n \"*.mts\",\n \"*.cts\",\n \"*.js\",\n \"*.jsx\",\n ],\n // Set parserOptions.project for the project to allow TypeScript to create the type-checker behind the scenes when we run linting\n parserOptions: {},\n rules: {},\n },\n {\n files: [\"*.ts\", \"*.tsx\", \"*.mts\", \"*.cts\"],\n // Set parserOptions.project for the project to allow TypeScript to create the type-checker behind the scenes when we run linting\n parserOptions: {},\n rules: {},\n },\n {\n files: [\"*.js\", \"*.jsx\"],\n rules: {},\n },\n ],\n};\n`;\n\n return writeFileAsync(eslintPath, content, \"utf8\");\n};\n\n/**\n * Writes .eslintignore if it doesn't exist. Warns if it exists.\n */\nconst writeEslintIgnore = () => {\n const eslintIgnorePath = join(projectPath, \".eslintignore\");\n\n if (existsSync(eslintIgnorePath)) {\n console.warn(\"⚠️ .eslintignore already exists\");\n\n return Promise.resolve();\n }\n\n return writeFileAsync(eslintIgnorePath, \"\", \"utf8\");\n};\n\n// eslint-disable-next-line unicorn/prefer-top-level-await\n(async () => {\n try {\n // eslint-disable-next-line compat/compat\n await Promise.all([writeEslintRc(), writeEslintIgnore()]);\n\n console.log(\"😎 Everything went well, have fun!\");\n\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(0);\n } catch (error) {\n console.log(\"😬 something went wrong:\");\n console.error(error);\n\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(1);\n }\n})();\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anolilab/eslint-config",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.3",
|
|
4
4
|
"description": "ESLint shareable config for the Anolilab JavaScript style guide.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -167,14 +167,14 @@
|
|
|
167
167
|
"eslint-plugin-jest-async": "^1.0.3",
|
|
168
168
|
"eslint-plugin-jest-dom": "^5.0.1",
|
|
169
169
|
"eslint-plugin-jest-formatting": "^3.1.0",
|
|
170
|
-
"eslint-plugin-jsdoc": "^46.
|
|
170
|
+
"eslint-plugin-jsdoc": "^46.3.0",
|
|
171
171
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
172
172
|
"eslint-plugin-no-unsanitized": "^4.0.2",
|
|
173
173
|
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
|
174
174
|
"eslint-plugin-react": "^7.32.2",
|
|
175
175
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
176
176
|
"eslint-plugin-react-redux": "^4.0.0",
|
|
177
|
-
"eslint-plugin-storybook": "^0.6.
|
|
177
|
+
"eslint-plugin-storybook": "^0.6.12",
|
|
178
178
|
"eslint-plugin-tailwindcss": "^3.12.1",
|
|
179
179
|
"eslint-plugin-etc": "^2.0.3",
|
|
180
180
|
"eslint-plugin-testing-library": "^5.11.0",
|
|
@@ -196,21 +196,21 @@
|
|
|
196
196
|
"eslint-plugin-ava": "^14.0.0",
|
|
197
197
|
"eslint-plugin-babel": "^5.3.1",
|
|
198
198
|
"eslint-plugin-cypress": "^2.13.3",
|
|
199
|
-
"eslint-plugin-jest": "^27.2.
|
|
199
|
+
"eslint-plugin-jest": "^27.2.2",
|
|
200
200
|
"eslint-plugin-jest-async": "^1.0.3",
|
|
201
201
|
"eslint-plugin-jest-dom": "^5.0.1",
|
|
202
202
|
"eslint-plugin-jest-formatting": "^3.1.0",
|
|
203
203
|
"eslint-plugin-playwright": "^0.15.1",
|
|
204
|
-
"eslint-plugin-jsdoc": "^46.
|
|
204
|
+
"eslint-plugin-jsdoc": "^46.3.0",
|
|
205
205
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
206
|
-
"eslint-plugin-n": "^16.0.
|
|
206
|
+
"eslint-plugin-n": "^16.0.1",
|
|
207
207
|
"eslint-plugin-no-unsanitized": "^4.0.2",
|
|
208
208
|
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
|
209
209
|
"@tanstack/eslint-plugin-query": "^4.29.9",
|
|
210
210
|
"eslint-plugin-react": "^7.32.2",
|
|
211
211
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
212
212
|
"eslint-plugin-react-redux": "^4.0.0",
|
|
213
|
-
"eslint-plugin-storybook": "^0.6.
|
|
213
|
+
"eslint-plugin-storybook": "^0.6.12",
|
|
214
214
|
"eslint-plugin-tailwindcss": "^3.12.1",
|
|
215
215
|
"eslint-plugin-testing-library": "^5.11.0",
|
|
216
216
|
"eslint-plugin-tsdoc": "^0.2.17",
|