UNPKG

@anolilab/eslint-config

Version:

ESLint shareable config for the Anolilab JavaScript style guide.

79 lines (74 loc) 4.29 kB
'use strict'; var chunk5RAVHY5O_js = require('./chunk-5RAVHY5O.js'); var fs = require('fs'); var path = require('path'); var util = require('util'); var packageJsonUtils = require('@anolilab/package-json-utils'); var process = require('process'); var C,O,m,g=chunk5RAVHY5O_js.a(()=>{C=util.promisify(fs.writeFile),O=async()=>{let t=path.join(packageJsonUtils.projectPath,".eslintignore");if(fs.existsSync(t)){console.warn("\u26A0\uFE0F .eslintignore already exists");return}await C(t,"","utf8");},m=O;});var k,s,E,y,d=chunk5RAVHY5O_js.a(()=>{k=util.promisify(fs.writeFile);console.log("Configuring @anolilab/eslint-config",packageJsonUtils.projectPath,` `);s=".eslintrc",E=async()=>{for(let o of [s,`${s}.js`,`${s}.cjs`,`${s}.json`,`${s}.yaml`,`${s}.yml`])if(fs.existsSync(path.join(packageJsonUtils.projectPath,o))){console.warn(`\u26A0\uFE0F ${o} already exists; Make sure that it includes the following for @anolilab/eslint-config' to work as it should: { extends: ["@anolilab/eslint-config"] }.`);return}let t=path.join(packageJsonUtils.projectPath,`.eslintrc.${packageJsonUtils.packageIsTypeModule?"c":""}js`),a="",c=` parserOptions: { ecmaVersion: "latest", sourceType: ${packageJsonUtils.packageIsTypeModule?'"module"':'"commonjs"'}, },`,p=path.join(packageJsonUtils.projectPath,"tsconfig.json"),e="latest";if(fs.existsSync(p)){let o=JSON.parse(fs.readFileSync(p,"utf8"));o.compilerOptions?.target&&(e=o.compilerOptions.target,e=e.toLowerCase()==="es2022"||e.toLowerCase()==="esnext"?"latest":e.toLowerCase().replace("es",""),e!=="latest"&&e!=="2022"&&e!=="2021"&&e!=="6"&&(a=`, "plugin:es-x/restrict-to-es${e}"`)),c=` parserOptions: { project: true, ecmaVersion: ${e==="latest"?`"${e}"`:e}, sourceType: ${packageJsonUtils.packageIsTypeModule?'"module"':'"commonjs"'}, },`;}let w=`/** @ts-check */ const { defineConfig } = require('@anolilab/eslint-config/define-config'); ${["es2015","es2017","es2020","es2021","latest"].includes(e)?'const { globals } = require("@anolilab/eslint-config/globals");':""} /// <reference types="@eslint-types/unicorn" /> /// <reference types="@eslint-types/typescript-eslint" /> /// <reference types="@eslint-types/jsdoc" /> /// <reference types="@eslint-types/import" /> /// <reference types="@eslint-types/deprecation" /> module.exports = defineConfig({ root: true, extends: ["@anolilab/eslint-config"${a}], ignorePatterns: ["!**/*"], env: { // Your environments (which contains several predefined global variables) // Most environments are loaded automatically if our rules are added },${c} globals: {${["es2015","es2017","es2020","es2021","latest"].includes(e)?` ...globals.${e==="latest"?"es2021":e},`:""} // Your global variables (setting to false means it's not allowed to be reassigned) // myGlobal: false }, rules: { // Customize your rules }, overrides: [ { files: [ "**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts", "**/*.js", "**/*.jsx", ], // Set parserOptions.project for the project to allow TypeScript to create the type-checker behind the scenes when we run linting parserOptions: {}, rules: {}, }, { files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"], // Set parserOptions.project for the project to allow TypeScript to create the type-checker behind the scenes when we run linting parserOptions: {}, rules: {}, }, { files: ["**/*.js", "**/*.jsx"], rules: {}, }, ], }); `;await k(t,w,"utf8");},y=E;});var J=chunk5RAVHY5O_js.b(()=>{g();d();process.env.CI&&process.exit(0);console.log("Configuring @anolilab/eslint-config",packageJsonUtils.projectPath,` `);(async()=>{try{await Promise.all([y(),m()]),console.log("\u{1F60E} Everything went well, have fun!"),process.exit(0);}catch(t){console.log("\u{1F62C} something went wrong:"),console.error(t),process.exit(1);}})();});var postinstall = J(); module.exports = postinstall; //# sourceMappingURL=out.js.map //# sourceMappingURL=postinstall.js.map