UNPKG

eslint-config-chariz

Version:

ESLint config used at Chariz

211 lines (209 loc) 8.16 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // index.js var index_exports = {}; __export(index_exports, { default: () => index_default }); module.exports = __toCommonJS(index_exports); var import_config = require("eslint/config"); var import_globals = __toESM(require("globals"), 1); var import_js = __toESM(require("@eslint/js"), 1); var import_eslint_plugin_jsx_a11y = __toESM(require("eslint-plugin-jsx-a11y"), 1); var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1); var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1); var import_eslint_plugin_simple_import_sort = __toESM(require("eslint-plugin-simple-import-sort"), 1); var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1); var import_typescript_eslint = __toESM(require("typescript-eslint"), 1); var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1); function index_default({ ts = true, react = false, vue = false, node = true, browser = true } = {}) { return (0, import_config.defineConfig)([ // Base JS import_js.default.configs.recommended, // TypeScript ts ? [ import_typescript_eslint.default.configs.strict, import_typescript_eslint.default.configs.stylistic ] : [], // React react ? [ import_eslint_plugin_react.default.configs.flat.recommended, import_eslint_plugin_react.default.configs.flat["jsx-runtime"], import_eslint_plugin_react_hooks.default.configs.flat.recommended ] : [], vue ? [ import_eslint_plugin_vue.default.configs["flat/recommended"] ] : [], // Unicorn import_eslint_plugin_unicorn.default.configs.all, // a11y import_eslint_plugin_jsx_a11y.default.flatConfigs.strict, // Our config { name: "eslint-config-chariz/main", files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}", "!**/.nuxt/**/*"], languageOptions: { ecmaVersion: "latest", sourceType: "module", globals: { ...import_globals.default.builtin, ...import_globals.default.es2026, ...node ? import_globals.default.node : {}, ...browser ? { ...import_globals.default.browser, ...import_globals.default.serviceworker, ...import_globals.default.jquery } : {} } }, plugins: { "simple-import-sort": import_eslint_plugin_simple_import_sort.default }, rules: { "array-bracket-newline": ["error", "consistent"], "array-bracket-spacing": ["error", "never"], "array-callback-return": "error", "array-element-newline": ["error", "consistent"], "comma-dangle": ["error", "never"], "dot-location": ["error", "property"], eqeqeq: ["error", "always", { null: "ignore" }], "func-call-spacing": ["error", "never"], "function-call-argument-newline": ["error", "consistent"], indent: ["error", "tab", { SwitchCase: 0, offsetTernaryExpressions: true }], "max-lines-per-function": ["warn", { max: 300 }], "max-params": ["warn", { max: 5 }], "multiline-comment-style": ["error", "separate-lines"], "multiline-ternary": ["error", "always-multiline"], "newline-per-chained-call": ["error", { ignoreChainWithDepth: 1 }], "no-empty": "off", "no-implicit-coercion": "error", // Disabling because this false-positives a lot when using spaces to align things. It’s too // noisy to use an eslint disable comment every time this gets in the way. "no-mixed-spaces-and-tabs": "off", "no-spaced-func": "off", // Has a lot of false positives "no-unused-vars": "off", "no-useless-return": "error", "no-var": "error", "no-warning-comments": "warn", "object-curly-newline": [ "error", { multiline: true, consistent: true } ], "object-curly-spacing": ["error", "always"], "object-shorthand": ["error", "always"], "one-var": ["error", "never"], "padded-blocks": ["error", "never"], "prefer-const": ["error", { destructuring: "all" }], "prefer-template": "error", "quote-props": ["error", "as-needed"], quotes: ["error", "double", { allowTemplateLiterals: true }], semi: ["error", "always", { omitLastInOneLineBlock: true }], "sort-imports": [ "error", { ignoreCase: true, ignoreDeclarationSort: true } ], "space-before-function-paren": "off", "spaced-comment": ["error", "always", { markers: ["/", "!", "*"] }], "import/no-anonymous-default-export": "off", "unicorn/consistent-function-scoping": "off", "unicorn/custom-error-definition": "off", "unicorn/filename-case": [ "warn", { cases: { pascalCase: true, kebabCase: true, camelCase: true }, ignore: ["API", "ID", "IP", "PDF", "URL", "OMG", "WTF", "BBQ"] } ], "unicorn/no-anonymous-default-export": "off", "unicorn/no-array-callback-reference": "off", "unicorn/no-array-sort": "off", "unicorn/no-await-expression-member": "off", "unicorn/no-keyword-prefix": "off", "unicorn/no-negated-condition": "off", "unicorn/no-null": "off", "unicorn/no-static-only-class": "off", // This rule is confusing. What am I meant to fix? "unicorn/no-unsafe-regex": "off", "unicorn/no-useless-undefined": ["error", { checkArguments: false }], "unicorn/prefer-node-protocol": "off", "unicorn/prevent-abbreviations": "off", "unicorn/switch-case-braces": ["error", "avoid"] } }, // TypeScript ts ? { rules: { "@typescript-eslint/no-non-null-assertion": "off", // Has a lot of false positives, tsc catches this anyway "@typescript-eslint/no-unused-vars": "off" } } : {}, // React/Vue react || vue ? { name: "eslint-config-chariz/jsx", files: ["**/*.{jsx,tsx,vue}"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } } : {}, react ? { name: "eslint-config-chariz/react", files: ["**/*.{jsx,tsx}"], settings: { react: { version: "19" } }, rules: { "react/no-unknown-property": ["error", { ignore: ["class", "for"] }] } } : {}, vue ? { name: "eslint-config-chariz/vue", files: ["**/*.vue"], rules: { "vue/multi-word-component-names": "off" } } : {} ]); }