@anolilab/eslint-config 7.2.0 → 7.2.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 +7 -0
- package/dist/config/plugins/es.js +4 -2
- package/dist/config/plugins/es.js.map +1 -1
- package/dist/config/plugins/es.mjs +4 -2
- package/dist/config/plugins/es.mjs.map +1 -1
- package/dist/postinstall.js +1 -1
- package/dist/postinstall.js.map +1 -1
- package/dist/postinstall.mjs +1 -1
- package/dist/postinstall.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## @anolilab/eslint-config [7.2.1](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/eslint-config@7.2.0...@anolilab/eslint-config@7.2.1) (2023-06-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* changed eslint-plugin-es to eslint-plugin-es-x ([168c42e](https://github.com/anolilab/javascript-style-guide/commit/168c42ed9b66be6cc0bef3cbceeda1fa7c712424))
|
|
7
|
+
|
|
1
8
|
## @anolilab/eslint-config [7.2.0](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/eslint-config@7.1.0...@anolilab/eslint-config@7.2.0) (2023-06-25)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVJL7NPM4_js = require('../../chunk-VJL7NPM4.js');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
var t=chunkVJL7NPM4_js.a("all",{plugins:["es-x"],settings:{es:{aggressive:!0}}}),r=t;
|
|
6
|
+
|
|
7
|
+
module.exports = r;
|
|
6
8
|
//# sourceMappingURL=out.js.map
|
|
7
9
|
//# sourceMappingURL=es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/plugins/es.ts"],"names":["config","es_default"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/config/plugins/es.ts"],"names":["config","createConfig","es_default"],"mappings":"4CAIA,IAAMA,EAAwBC,EAAa,MAAO,CAC9C,QAAS,CAAC,MAAM,EAChB,SAAU,CACN,GAAI,CAAE,WAAY,EAAK,CAC3B,CACJ,CAAC,EAEMC,EAAQF","sourcesContent":["import type { Linter } from \"eslint\";\n\nimport { createConfig } from \"../../utils/create-config\";\n\nconst config: Linter.Config = createConfig(\"all\", {\n plugins: [\"es-x\"],\n settings: {\n es: { aggressive: true },\n },\n});\n\nexport default config;\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { a } from '../../chunk-5IW32NSH.mjs';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var t=a("all",{plugins:["es-x"],settings:{es:{aggressive:!0}}}),r=t;
|
|
4
|
+
|
|
5
|
+
export { r as default };
|
|
4
6
|
//# sourceMappingURL=out.js.map
|
|
5
7
|
//# sourceMappingURL=es.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/plugins/es.ts"],"names":["config","es_default"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/config/plugins/es.ts"],"names":["config","createConfig","es_default"],"mappings":"6CAIA,IAAMA,EAAwBC,EAAa,MAAO,CAC9C,QAAS,CAAC,MAAM,EAChB,SAAU,CACN,GAAI,CAAE,WAAY,EAAK,CAC3B,CACJ,CAAC,EAEMC,EAAQF","sourcesContent":["import type { Linter } from \"eslint\";\n\nimport { createConfig } from \"../../utils/create-config\";\n\nconst config: Linter.Config = createConfig(\"all\", {\n plugins: [\"es-x\"],\n settings: {\n es: { aggressive: true },\n },\n});\n\nexport default config;\n"]}
|
package/dist/postinstall.js
CHANGED
|
@@ -10,7 +10,7 @@ process.env.CI&&process.exit(0);var p=util.promisify(fs.writeFile);console.log("
|
|
|
10
10
|
parserOptions: {
|
|
11
11
|
ecmaVersion: "latest",
|
|
12
12
|
sourceType: ${packageJsonUtils.packageIsTypeModule?'"module"':'"commonjs"'},
|
|
13
|
-
},`,a=path.join(packageJsonUtils.projectPath,"tsconfig.json");if(fs.existsSync(a)){let c=JSON.parse(fs.readFileSync(a,"utf8")),e="latest";c.compilerOptions?.target&&(e=c.compilerOptions.target,e=e.toLowerCase()==="es2022"||e.toLowerCase()==="esnext"?"latest":e.toLowerCase().replace("es",""),e!=="latest"&&e!=="2022"&&e!=="2021"&&e!=="
|
|
13
|
+
},`,a=path.join(packageJsonUtils.projectPath,"tsconfig.json");if(fs.existsSync(a)){let c=JSON.parse(fs.readFileSync(a,"utf8")),e="latest";c.compilerOptions?.target&&(e=c.compilerOptions.target,e=e.toLowerCase()==="es2022"||e.toLowerCase()==="esnext"?"latest":e.toLowerCase().replace("es",""),e!=="latest"&&e!=="2022"&&e!=="2021"&&e!=="6"&&(i=`, "plugin:es-x/restrict-to-es${e}"`)),l=`
|
|
14
14
|
parserOptions: {
|
|
15
15
|
project: "./tsconfig.json",
|
|
16
16
|
ecmaVersion: ${e==="latest"?`"${e}"`:e},
|
package/dist/postinstall.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/postinstall.ts"],"names":["packageIsTypeModule","projectPath","existsSync","readFileSync","writeFile","join","promisify","writeFileAsync","writeEslintRc","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,EAMpE,IAAMO,EAAgB,IAAM,CACxB,IAAMC,EAAaJ,EAAKJ,EAAa,cAAc,EAE/CS,EAAgB,GAChBC,EAAgB;AAAA;AAAA;AAAA,sBAGFX,EAAsB,WAAa;AAAA,QAG/CY,EAAeP,EAAKJ,EAAa,eAAe,EAEtD,GAAIC,EAAWU,CAAY,EAAG,CAC1B,IAAMC,EAAW,KAAK,MAAMV,EAAaS,EAAc,MAAM,CAAC,EAE1DE,EAAc,SAEdD,EAAS,iBAAiB,SAC1BC,EAAcD,EAAS,gBAAgB,OAEvCC,EAAcA,EAAY,YAAY,IAAM,UAAYA,EAAY,YAAY,IAAM,SAAW,SAAWA,EAAY,YAAY,EAAE,QAAQ,KAAM,EAAE,EAElJA,IAAgB,UAAYA,IAAgB,QAAUA,IAAgB,QAAUA,IAAgB,
|
|
1
|
+
{"version":3,"sources":["../src/postinstall.ts"],"names":["packageIsTypeModule","projectPath","existsSync","readFileSync","writeFile","join","promisify","writeFileAsync","writeEslintRc","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,EAMpE,IAAMO,EAAgB,IAAM,CACxB,IAAMC,EAAaJ,EAAKJ,EAAa,cAAc,EAE/CS,EAAgB,GAChBC,EAAgB;AAAA;AAAA;AAAA,sBAGFX,EAAsB,WAAa;AAAA,QAG/CY,EAAeP,EAAKJ,EAAa,eAAe,EAEtD,GAAIC,EAAWU,CAAY,EAAG,CAC1B,IAAMC,EAAW,KAAK,MAAMV,EAAaS,EAAc,M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,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\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 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 if (existsSync(eslintPath)) {\n console.warn(`⚠️ .eslintrc.cjs 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 return writeFileAsync(eslintPath, content, \"utf-8\");\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, \"\", \"utf-8\");\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
|
@@ -8,7 +8,7 @@ process.env.CI&&process.exit(0);var p=promisify(writeFile);console.log("Configur
|
|
|
8
8
|
parserOptions: {
|
|
9
9
|
ecmaVersion: "latest",
|
|
10
10
|
sourceType: ${packageIsTypeModule?'"module"':'"commonjs"'},
|
|
11
|
-
},`,a=join(projectPath,"tsconfig.json");if(existsSync(a)){let c=JSON.parse(readFileSync(a,"utf8")),e="latest";c.compilerOptions?.target&&(e=c.compilerOptions.target,e=e.toLowerCase()==="es2022"||e.toLowerCase()==="esnext"?"latest":e.toLowerCase().replace("es",""),e!=="latest"&&e!=="2022"&&e!=="2021"&&e!=="
|
|
11
|
+
},`,a=join(projectPath,"tsconfig.json");if(existsSync(a)){let c=JSON.parse(readFileSync(a,"utf8")),e="latest";c.compilerOptions?.target&&(e=c.compilerOptions.target,e=e.toLowerCase()==="es2022"||e.toLowerCase()==="esnext"?"latest":e.toLowerCase().replace("es",""),e!=="latest"&&e!=="2022"&&e!=="2021"&&e!=="6"&&(i=`, "plugin:es-x/restrict-to-es${e}"`)),l=`
|
|
12
12
|
parserOptions: {
|
|
13
13
|
project: "./tsconfig.json",
|
|
14
14
|
ecmaVersion: ${e==="latest"?`"${e}"`:e},
|
package/dist/postinstall.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/postinstall.ts"],"names":["packageIsTypeModule","projectPath","existsSync","readFileSync","writeFile","join","promisify","writeFileAsync","writeEslintRc","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,EAMpE,IAAMO,EAAgB,IAAM,CACxB,IAAMC,EAAaJ,EAAKJ,EAAa,cAAc,EAE/CS,EAAgB,GAChBC,EAAgB;AAAA;AAAA;AAAA,sBAGFX,EAAsB,WAAa;AAAA,QAG/CY,EAAeP,EAAKJ,EAAa,eAAe,EAEtD,GAAIC,EAAWU,CAAY,EAAG,CAC1B,IAAMC,EAAW,KAAK,MAAMV,EAAaS,EAAc,MAAM,CAAC,EAE1DE,EAAc,SAEdD,EAAS,iBAAiB,SAC1BC,EAAcD,EAAS,gBAAgB,OAEvCC,EAAcA,EAAY,YAAY,IAAM,UAAYA,EAAY,YAAY,IAAM,SAAW,SAAWA,EAAY,YAAY,EAAE,QAAQ,KAAM,EAAE,EAElJA,IAAgB,UAAYA,IAAgB,QAAUA,IAAgB,QAAUA,IAAgB,
|
|
1
|
+
{"version":3,"sources":["../src/postinstall.ts"],"names":["packageIsTypeModule","projectPath","existsSync","readFileSync","writeFile","join","promisify","writeFileAsync","writeEslintRc","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,EAMpE,IAAMO,EAAgB,IAAM,CACxB,IAAMC,EAAaJ,EAAKJ,EAAa,cAAc,EAE/CS,EAAgB,GAChBC,EAAgB;AAAA;AAAA;AAAA,sBAGFX,E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AAC,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\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 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 if (existsSync(eslintPath)) {\n console.warn(`⚠️ .eslintrc.cjs 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 return writeFileAsync(eslintPath, content, \"utf-8\");\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, \"\", \"utf-8\");\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.1",
|
|
4
4
|
"description": "ESLint shareable config for the Anolilab JavaScript style guide.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"eslint-import-resolver-typescript": "^3.5.5",
|
|
126
126
|
"eslint-plugin-antfu": "^0.39.5",
|
|
127
127
|
"eslint-plugin-compat": "^4.1.4",
|
|
128
|
-
"eslint-plugin-es": "^
|
|
128
|
+
"eslint-plugin-es-x": "^7.1.0",
|
|
129
129
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
130
130
|
"eslint-plugin-html": "^7.1.0",
|
|
131
131
|
"eslint-plugin-i": "^2.27.5",
|