"use strict"; 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 __name = (target, value) => __defProp(target, "name", { value, configurable: true }); 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); // src/index.ts var src_exports = {}; __export(src_exports, { createEslintConfig: () => createEslintConfig, default: () => src_default }); module.exports = __toCommonJS(src_exports); // src/config.ts var supportedJsFileTypesSet = [ "js", "mjs", "cjs" ]; var supportedTsFileTypesSet = [ "ts", "mts", "cts" ]; var supportedJsxFileTypesSet = [ "jsx", "mjsx" ]; var supportedTsxFileTypesSet = [ "tsx", "mtsx" ]; var supportedJsFileTypes = supportedJsFileTypesSet.join(","); var supportedTsFileTypes = supportedTsFileTypesSet.join(","); var supportedJsxFileTypes = supportedJsxFileTypesSet.join(","); var supportedTsxFileTypes = supportedTsxFileTypesSet.join(","); var supportedAllFileTypesSet = [ ...supportedJsFileTypesSet, ...supportedTsFileTypesSet, ...supportedJsxFileTypesSet, ...supportedTsxFileTypesSet ]; var supportedAllFileTypes = supportedAllFileTypesSet.join(","); var supportedReactFileTypesSet = [ ...supportedJsxFileTypesSet, ...supportedTsxFileTypesSet ]; var supportedReactFileTypes = supportedReactFileTypesSet.join(","); // src/features/storybook.ts var storybook = __toESM(require("eslint-plugin-storybook"), 1); var rules = [ { // enabling support for storybook stories and main config files: [ `**/*.stories.{${supportedAllFileTypes}}`, `**/*.story.{${supportedAllFileTypes}}` ], plugins: { storybook }, rules: { ...storybook.configs.recommended.overrides[0].rules, ...storybook.configs.csf.overrides[0].rules, ...storybook.configs["csf-strict"].rules, "storybook/csf-component": "error", "storybook/hierarchy-separator": "error", "storybook/no-redundant-story-name": "error", "storybook/prefer-pascal-case": "error" } }, { files: [ `**/.storybook/main.{${[ ...supportedJsFileTypes, ...supportedTsFileTypes ].join(",")}}` ], plugins: { storybook }, rules: storybook.configs.recommended.overrides[1].rules } ]; // src/features/reactjs.ts var react = __toESM(require("eslint-plugin-react"), 1); var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1); var import_eslint_plugin_jsx_a11y = __toESM(require("eslint-plugin-jsx-a11y"), 1); var import_parser = __toESM(require("@typescript-eslint/parser"), 1); var omitJsxA11yDeprecated = /* @__PURE__ */ __name(() => { const reactAccessibilityRulesWithoutDeprecated = structuredClone({ ...import_eslint_plugin_jsx_a11y.default.configs.recommended.rules }); delete reactAccessibilityRulesWithoutDeprecated["jsx-a11y/label-has-for"]; return Object.freeze(reactAccessibilityRulesWithoutDeprecated); }, "omitJsxA11yDeprecated"); var rules2 = [ { // enabling support for react files: [ `**/*.{${supportedReactFileTypes}}` ], plugins: { react }, languageOptions: { globals: { React: "readonly", JSX: "readonly" }, parser: import_parser.default, parserOptions: { ecmaFeatures: { modules: true, jsx: true }, project: true, jsxPragma: null } } }, { files: [ `**/*.{${supportedReactFileTypes}}` ], plugins: { react }, settings: { react: { version: "detect" } }, rules: { ...react.configs.recommended.rules, ...react.configs["jsx-runtime"].rules, "react/prop-types": "off", "react/no-unstable-nested-components": "error", "react/jsx-no-useless-fragment": "error", "react/jsx-boolean-value": "error", "react/jsx-fragments": [ "error", "syntax" ], "react/hook-use-state": "error", "react/jsx-no-leaked-render": "error", "react/iframe-missing-sandbox": "error", "react/no-access-state-in-setstate": "error", "react/no-this-in-sfc": "error", "react/prefer-read-only-props": "error", "react/jsx-pascal-case": "error" } }, { // enabling support for react accessibility rules files: [ `**/*.{${supportedReactFileTypes}}` ], plugins: { "jsx-a11y": import_eslint_plugin_jsx_a11y.default }, rules: omitJsxA11yDeprecated() }, { // enabling support for react hooks rules files: [ `**/*.{${supportedAllFileTypes}}` ], plugins: { "react-hooks": import_eslint_plugin_react_hooks.default }, rules: import_eslint_plugin_react_hooks.default.configs.recommended.rules } ]; // src/features/lodash.ts var import_eslint_plugin_lodash_f = __toESM(require("eslint-plugin-lodash-f"), 1); var rules3 = [ { // enabling support for correcting lodash imports files: [ `**/*.{${supportedAllFileTypes}}` ], plugins: { "lodash-f": import_eslint_plugin_lodash_f.default }, rules: { "lodash-f/import-scope": [ "error", "member" ] } } ]; // src/features/nextjs.ts var import_eslint_plugin_next = __toESM(require("@next/eslint-plugin-next"), 1); var rules4 = [ { // enabling support for nextjs files: [ `**/*.{${supportedAllFileTypes}}` ], plugins: { "@next/next": import_eslint_plugin_next.default }, rules: { ...import_eslint_plugin_next.default.configs.recommended.rules, ...import_eslint_plugin_next.default.configs["core-web-vitals"].rules } } ]; // src/features/playwright.ts var import_eslint_plugin_playwright = __toESM(require("eslint-plugin-playwright"), 1); var rules5 = [ { // enabling support for playwright files: [ `**/*.{${[ supportedJsFileTypes, supportedTsFileTypes ].join(",")}}` ], plugins: { playwright: import_eslint_plugin_playwright.default }, rules: { ...import_eslint_plugin_playwright.default.configs["flat/recommended"].rules } } ]; // src/features/vitest.ts var import_eslint_plugin_vitest = __toESM(require("eslint-plugin-vitest"), 1); var rules6 = [ { // enabling support for vitest files: [ `**/*.{test,spec}.{${supportedAllFileTypes}}`, `**/tests/**/*.{${supportedAllFileTypes}}`, `**/__tests__/**/*.{${supportedAllFileTypes}}` ], plugins: { vitest: import_eslint_plugin_vitest.default }, rules: import_eslint_plugin_vitest.default.configs.recommended.rules } ]; // src/features/turbo.ts var turbo = __toESM(require("eslint-plugin-turbo"), 1); var rules7 = [ { // enabling support for turbo files: [ `**/turbo.json` ], plugins: { turbo }, rules: { ...turbo.configs.recommended.rules } } ]; // src/features/tailwind.ts var import_eslint_plugin_tailwindcss = __toESM(require("eslint-plugin-tailwindcss"), 1); var rules8 = [ { // enabling support for tailwindcss files: [ `**/*.{${supportedAllFileTypes}}` ], plugins: { tailwindcss: import_eslint_plugin_tailwindcss.default }, rules: { ...import_eslint_plugin_tailwindcss.default.configs.recommended.rules, "tailwindcss/classnames-order": "off" } } ]; // src/features/typescript.ts var import_parser2 = __toESM(require("@typescript-eslint/parser"), 1); var import_eslint_plugin2 = __toESM(require("@typescript-eslint/eslint-plugin"), 1); // src/rules/typescript.ts var import_eslint_plugin = __toESM(require("@typescript-eslint/eslint-plugin"), 1); var strictTypescriptRules = import_eslint_plugin.default.configs["strict-type-checked"].rules; var stylisticTypescriptRules = import_eslint_plugin.default.configs["stylistic-type-checked"].rules; var customTypescriptRules = { "@typescript-eslint/consistent-type-exports": [ // https://typescript-eslint.io/rules/consistent-type-exports/ "error", { fixMixedExportsWithInlineTypeSpecifier: true } ], "@typescript-eslint/consistent-type-imports": [ // https://typescript-eslint.io/rules/consistent-type-imports/ // requires 'emitDecoratorMetadata' in tsconfig to be **true** "error", { fixStyle: "inline-type-imports" } ], "@typescript-eslint/explicit-function-return-type": [ // https://typescript-eslint.io/rules/explicit-function-return-type/ "error", { allowIIFEs: true } ], "@typescript-eslint/explicit-module-boundary-types": [ // https://typescript-eslint.io/rules/explicit-module-boundary-types/ "error" ], "@typescript-eslint/method-signature-style": [ // https://typescript-eslint.io/rules/method-signature-style/ "error" ], "@typescript-eslint/no-import-type-side-effects": [ // https://typescript-eslint.io/rules/no-import-type-side-effects/ "error" ], "@typescript-eslint/no-useless-empty-export": [ // https://typescript-eslint.io/rules/no-useless-empty-export/ "error" ], "@typescript-eslint/promise-function-async": [ // https://typescript-eslint.io/rules/promise-function-async/ "error" ], "@typescript-eslint/require-array-sort-compare": [ // https://typescript-eslint.io/rules/require-array-sort-compare/ "error" ], "@typescript-eslint/no-unsafe-call": [ // https://typescript-eslint.io/rules/no-unsafe-call/ // should not be forced by default, turn on when you really need it "off" ], "@typescript-eslint/no-explicit-any": [ // https://typescript-eslint.io/rules/no-explicit-any/ // should not be forced by default, turn on when you really need it "off" ], "@typescript-eslint/no-unsafe-return": [ // https://typescript-eslint.io/rules/no-unsafe-return/ // should not be forced by default, turn on when you really need it "off" ], "@typescript-eslint/no-unsafe-assignment": [ // https://typescript-eslint.io/rules/no-unsafe-assignment/ // should not be forced by default, turn on when you really need it "off" ], "@typescript-eslint/no-unsafe-member-access": [ // https://typescript-eslint.io/rules/no-unsafe-member-access/ // should not be forced by default, turn on when you really need it "off" ], "@typescript-eslint/no-unsafe-argument": [ // https://typescript-eslint.io/rules/no-unsafe-argument/ // should not be forced by default, turn on when you really need it "off" ] }; // src/features/typescript.ts var rules9 = [ { // enabling parsing typescript files support files: [ `**/*.{${[ supportedTsFileTypes, supportedTsxFileTypes ]}}` ], languageOptions: { parser: import_parser2.default, parserOptions: { ecmaFeatures: { modules: true }, project: true } } }, { // enabling typescript rules files: [ `**/*.{${[ supportedTsFileTypes, supportedTsxFileTypes ]}}` ], plugins: { "@typescript-eslint": import_eslint_plugin2.default }, // more about @typescript-eslint/eslint-plugin rules see: // - https://typescript-eslint.io/linting/configs#recommended-configurations // - https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict.ts rules: { // see possible 'configs' field values: // - https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/index.ts // ...stylisticTypescriptRules, ...strictTypescriptRules, // Custom rules ...customTypescriptRules, // disabling default eslint rule and using @typescript-eslint/no-unused-vars instead // to avoid unnecessary errors for type definitions "no-unused-vars": [ "off" ] } } ]; // src/features/recommended.ts var import_js = __toESM(require("@eslint/js"), 1); var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1); var sonarjs = __toESM(require("eslint-plugin-sonarjs"), 1); // src/rules/unicorn.ts var unicornRules = { "unicorn/error-message": "error", "unicorn/escape-case": "error", "unicorn/expiring-todo-comments": "error", "unicorn/explicit-length-check": "error", "unicorn/new-for-builtins": "error", "unicorn/no-abusive-eslint-disable": "error", "unicorn/no-array-callback-reference": "error", "unicorn/no-array-for-each": "error", "unicorn/no-array-method-this-argument": "error", "unicorn/no-await-expression-member": "error", "unicorn/no-empty-file": "warn", "unicorn/no-instanceof-array": "error", "unicorn/no-invalid-remove-event-listener": "error", "unicorn/no-new-buffer": "error", "unicorn/no-this-assignment": "error", "unicorn/no-unnecessary-await": "error", "unicorn/no-useless-fallback-in-spread": "error", "unicorn/no-useless-length-check": "error", "unicorn/no-useless-promise-resolve-reject": "error", "unicorn/no-useless-spread": "error", "unicorn/no-useless-switch-case": "error", "unicorn/no-zero-fractions": "error", "unicorn/number-literal-case": "error", "unicorn/numeric-separators-style": "error", "unicorn/prefer-add-event-listener": "error", "unicorn/prefer-array-find": "error", "unicorn/prefer-array-flat-map": "error", "unicorn/prefer-array-flat": "error", "unicorn/prefer-at": "error", "unicorn/prefer-blob-reading-methods": "error", "unicorn/prefer-code-point": "error", "unicorn/prefer-date-now": "error", "unicorn/prefer-dom-node-append": "error", "unicorn/prefer-dom-node-dataset": "error", "unicorn/prefer-dom-node-remove": "error", "unicorn/prefer-event-target": "error", "unicorn/prefer-export-from": "error", "unicorn/prefer-keyboard-event-key": "error", "unicorn/prefer-logical-operator-over-ternary": "error", "unicorn/prefer-modern-dom-apis": "error", "unicorn/prefer-modern-math-apis": "error", "unicorn/prefer-negative-index": "error", "unicorn/prefer-node-protocol": "error", "unicorn/prefer-number-properties": "error", "unicorn/prefer-optional-catch-binding": "error", "unicorn/prefer-prototype-methods": "error", "unicorn/prefer-query-selector": "error", "unicorn/prefer-reflect-apply": "error", "unicorn/prefer-regexp-test": "error", "unicorn/prefer-set-size": "error", "unicorn/prefer-string-replace-all": "error", "unicorn/prefer-string-slice": "error", "unicorn/prefer-string-starts-ends-with": "error", "unicorn/prefer-string-trim-start-end": "error", "unicorn/prefer-type-error": "error", "unicorn/relative-url-style": "error", "unicorn/require-array-join-separator": "error", "unicorn/require-number-to-fixed-digits-argument": "error", "unicorn/switch-case-braces": "error", "unicorn/text-encoding-identifier-case": "error", "unicorn/throw-new-error": "error" }; // src/rules/eslint.ts var customEslintRules = { "no-promise-executor-return": [ // https://eslint.org/docs/latest/rules/no-promise-executor-return "error" ], "no-unreachable-loop": [ // https://eslint.org/docs/latest/rules/no-unreachable-loop "error" ], "no-caller": [ // https://eslint.org/docs/latest/rules/no-caller "error" ], "no-extend-native": [ // https://eslint.org/docs/latest/rules/no-extend-native "error" ], "no-extra-bind": [ // https://eslint.org/docs/latest/rules/no-extra-bind "error" ], "no-extra-label": [ // https://eslint.org/docs/latest/rules/no-extra-label "error" ], "no-multi-str": [ // https://eslint.org/docs/latest/rules/no-multi-str "error" ], "no-new-wrappers": [ // https://eslint.org/docs/latest/rules/no-new-wrappers "error" ], "no-object-constructor": [ // https://eslint.org/docs/latest/rules/no-object-constructor "error" ], "no-restricted-properties": [ // https://eslint.org/docs/latest/rules/no-restricted-properties "error", { object: "global", property: "isFinite", message: "Please use Number.isFinite instead" }, { object: "self", property: "isFinite", message: "Please use Number.isFinite instead" }, { object: "window", property: "isFinite", message: "Please use Number.isFinite instead" }, { object: "global", property: "isNaN", message: "Please use Number.isNaN instead" }, { object: "self", property: "isNaN", message: "Please use Number.isNaN instead" }, { object: "window", property: "isNaN", message: "Please use Number.isNaN instead" } ], "no-octal-escape": [ // https://eslint.org/docs/latest/rules/no-octal-escape "error" ], "no-proto": [ // https://eslint.org/docs/latest/rules/no-proto "error" ], "no-sequences": [ // https://eslint.org/docs/latest/rules/no-sequences "error", { allowInParentheses: true } ], "no-void": [ // https://eslint.org/docs/latest/rules/no-void "error" ], "no-array-constructor": [ // https://eslint.org/docs/latest/rules/no-array-constructor "error" ], "no-multi-assign": [ // https://eslint.org/docs/latest/rules/no-multi-assign "error" ], "no-plusplus": [ // https://eslint.org/docs/latest/rules/no-plusplus "error" ], "no-useless-call": [ // https://eslint.org/docs/latest/rules/no-useless-call "error" ], "prefer-object-has-own": [ // https://eslint.org/docs/latest/rules/prefer-object-has-own "error" ], "no-constant-binary-expression": [ // TODO: it seems it has been included into recommended config in the last version. // see https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js // https://eslint.org/docs/latest/rules/no-constant-binary-expression "error" ], "no-lone-blocks": [ // https://eslint.org/docs/latest/rules/no-lone-blocks "error" ], "no-return-assign": [ // https://eslint.org/docs/latest/rules/no-return-assign "error", "always" ], "no-else-return": [ // https://eslint.org/docs/latest/rules/no-else-return "error" ], "prefer-template": [ // https://eslint.org/docs/latest/rules/prefer-template "error" ], "no-param-reassign": [ // https://eslint.org/docs/latest/rules/no-param-reassign "error" ], "array-callback-return": [ // https://eslint.org/docs/latest/rules/array-callback-return "error", { allowImplicit: true, checkForEach: true } ], eqeqeq: [ // https://eslint.org/docs/latest/rules/eqeqeq "error" ], "prefer-arrow-callback": [ // https://eslint.org/docs/latest/rules/prefer-arrow-callback "error" ], "arrow-body-style": [ // https://eslint.org/docs/latest/rules/arrow-body-style "error", "always" ], "no-restricted-syntax": [ // https://eslint.org/docs/latest/rules/no-restricted-syntax "error", { selector: "TSEnumDeclaration", message: "Avoid enums. Use union types instead." } ] }; // src/features/recommended.ts var omitDeprecated = /* @__PURE__ */ __name(() => { const recommendedRulesWithoutDeprecated = structuredClone({ ...import_js.default.configs.recommended.rules }); delete recommendedRulesWithoutDeprecated["no-extra-semi"]; delete recommendedRulesWithoutDeprecated["no-mixed-spaces-and-tabs"]; return Object.freeze(recommendedRulesWithoutDeprecated); }, "omitDeprecated"); var rules10 = [ { // https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js files: [ `**/*.{${supportedAllFileTypes}}` ], rules: omitDeprecated() }, { // applying custom eslint rules that are not included into recommended config files: [ `**/*.{${supportedAllFileTypes}}` ], rules: customEslintRules }, { // applying unicorn rules. recommended is not following the idea of this package, // so I hand picked some rules that I think are useful files: [ `**/*.{${supportedAllFileTypes}}` ], plugins: { unicorn: import_eslint_plugin_unicorn.default }, rules: unicornRules }, { // applying sonar rules. there are no many rules there, so recommended would be enough files: [ `**/*.{${supportedAllFileTypes}}` ], plugins: { sonarjs }, // @ts-ignore rules: sonarjs.configs.recommended.rules } ]; // src/features/stylistic.ts var import_eslint_plugin3 = __toESM(require("@stylistic/eslint-plugin"), 1); var rules11 = [ { // // ESLint deprecated of their formatting rules in v8.53.0 and recommended users to migrate to // ESLint Stylistic if developers do not want to use additional formatting tools like prettier. // read more here: https://eslint.org/blog/2023/10/deprecating-formatting-rules/ // // Personally, I think using prettier is better idea, however it still might make sense to // someone in some cases to use ESLint Stylistic. // plugins: { // @ts-ignore "@stylistic": import_eslint_plugin3.default }, files: [ `**/*.{${supportedAllFileTypes}}` ], rules: { ...import_eslint_plugin3.default.configs["recommended-flat"].rules, "@stylistic/no-extra-semi": [ "error" ], "@stylistic/semi": [ "error", "always" ], "@stylistic/arrow-parens": [ "error", "always" ], "@stylistic/brace-style": [ "error", "1tbs" ], "@stylistic/no-multiple-empty-lines": [ "off" ], "@stylistic/no-trailing-spaces": [ "off" ] } } ]; // src/features/graphql.ts var graphql = __toESM(require("@graphql-eslint/eslint-plugin"), 1); var GQL_FILES = [ "**/*.{graphql,gql}" ]; var rules12 = [ { files: GQL_FILES, plugins: { // @ts-ignore "@graphql-eslint": graphql }, languageOptions: { parser: graphql } }, // @ts-ignore { files: GQL_FILES, ...graphql.flatConfigs["schema-recommended"] }, // @ts-ignore { files: GQL_FILES, ...graphql.flatConfigs["operations-recommended"] } ]; // src/createEslintConfig.ts var createEslintConfig = /* @__PURE__ */ __name((opts) => { const options = { useStorybook: false, useLodash: true, useNextjs: false, usePlaywright: false, useVitest: true, useTurbo: true, useTailwind: false, useAsFormatter: false, useGraphQL: false, ...opts }; return [ { ignores: [ ".next/**", ".turbo/**", "node_modules/**" ] }, ...rules10, ...rules9, ...rules2, ...options.useAsFormatter ? rules11 : [], ...options.useStorybook ? rules : [], ...options.useLodash ? rules3 : [], ...options.useNextjs ? rules4 : [], ...options.usePlaywright ? rules5 : [], ...options.useVitest ? rules6 : [], ...options.useTurbo ? rules7 : [], ...options.useTailwind ? rules8 : [], ...options.useGraphQL ? rules12 : [] ]; }, "createEslintConfig"); // src/index.ts var src_default = createEslintConfig({}); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { createEslintConfig });