UNPKG

@storm-software/eslint

Version:

A package containing the base ESLint configuration used by Storm Software across many projects.

1,446 lines (1,416 loc) 641 kB
import { isInEditorEnv, interopDefault, ensurePackages, renameRules, parserPlain, isPackageInScope } from './chunk-Z2ZFJBUD.js'; import { getTsConfigPath } from './chunk-WEPTDP5X.js'; import { banner_plugin_default } from './chunk-2FWJ22PW.js'; import { getFileBanner } from './chunk-UVAZFUOB.js'; import { GLOB_EXCLUDE, GLOB_TS, GLOB_TSX, GLOB_JSX, GLOB_MARKDOWN, GLOB_ASTRO_TS, GLOB_SRC, GLOB_TESTS, GLOB_ASTRO, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_YAML, GLOB_TOML, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_MDX, GLOB_CSS, GLOB_POSTCSS, GLOB_SCSS, GLOB_LESS, GLOB_HTML, GLOB_XML, GLOB_SVG, GLOB_GRAPHQL, GLOB_SRC_EXT, GLOB_SRC_FILE } from './chunk-WHUEAYCR.js'; import { findWorkspaceRoot } from './chunk-EIPIQB5E.js'; import { joinPaths } from './chunk-ZZRQVLBJ.js'; import { __commonJS, init_esm_shims, __toESM, __require, __filename as __filename$1 } from './chunk-QO5ZXGIE.js'; import * as __import__microsoft_tsdocConfig from '@microsoft/tsdoc-config'; import * as __import_path from 'path'; import * as __import_fs from 'fs'; import * as __import__microsoft_tsdoc from '@microsoft/tsdoc'; import { FlatConfigComposer } from 'eslint-flat-config-utils'; import { isPackageExists } from 'local-pkg'; import cspellConfig from '@cspell/eslint-plugin/recommended'; import defu from 'defu'; import '@cspell/eslint-plugin'; import default3 from '@nx/eslint-plugin/nx.js'; import default4 from '@vitest/eslint-plugin'; import Module, { createRequire, isBuiltin } from 'node:module'; import path16, { join } from 'node:path'; import { ResolverFactory } from 'unrs-resolver'; import { setRuleContext, getTsconfigWithContext } from 'eslint-import-context'; import fs3, { existsSync, readFileSync } from 'node:fs'; import debug from 'debug'; import { SourceCode } from 'eslint'; import { stableHash } from 'stable-hash-x'; import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types'; import { fileURLToPath } from 'node:url'; import vm from 'node:vm'; import { expand } from 'brace-expansion'; import * as semver from 'semver'; import isGlob from 'is-glob'; import eslintUnsupportedApi from 'eslint/use-at-your-own-risk'; import default5 from 'eslint-plugin-import-zod'; import default6 from 'eslint-plugin-n'; import default7 from 'eslint-plugin-no-only-tests'; import default8 from 'eslint-plugin-no-secrets'; import default9 from 'eslint-plugin-perfectionist'; import * as jsoncParser from 'jsonc-eslint-parser'; import * as yamlParser from 'yaml-eslint-parser'; import process2 from 'node:process'; import { findUpSync } from 'find-up-simple'; import { parsePnpmWorkspaceYaml } from 'pnpm-workspace-yaml'; import { basename, normalize as normalize$1, resolve as resolve$1, dirname } from 'pathe'; import { globSync } from 'tinyglobby'; import default10 from 'eslint-plugin-prettier'; import default11 from 'eslint-plugin-unicorn'; import default12 from 'eslint-plugin-unused-imports'; import { loadConfig } from 'c12'; import chalk from 'chalk'; import { readFile } from 'node:fs/promises'; import globalsLib from 'globals'; import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors'; import { readCachedProjectGraph, createProjectGraphAsync } from '@nx/devkit'; import config2 from 'eslint-plugin-prettier/recommended'; import { configs as configs$1 } from 'eslint-plugin-regexp'; // ../../node_modules/.pnpm/eslint-plugin-tsdoc@0.4.0_patch_hash=11b9fbe0e91a2ce3492e80b89a7502a9ff364683b23b9bdfc2c979d988e1682b/node_modules/eslint-plugin-tsdoc/lib/Debug.js var require_Debug = __commonJS({ "../../node_modules/.pnpm/eslint-plugin-tsdoc@0.4.0_patch_hash=11b9fbe0e91a2ce3492e80b89a7502a9ff364683b23b9bdfc2c979d988e1682b/node_modules/eslint-plugin-tsdoc/lib/Debug.js"(exports) { init_esm_shims(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Debug = void 0; var Debug = class { // To debug the plugin, temporarily uncomment the body of this function static log(message2) { } }; exports.Debug = Debug; } }); var require_ConfigCache = __commonJS({ "../../node_modules/.pnpm/eslint-plugin-tsdoc@0.4.0_patch_hash=11b9fbe0e91a2ce3492e80b89a7502a9ff364683b23b9bdfc2c979d988e1682b/node_modules/eslint-plugin-tsdoc/lib/ConfigCache.js"(exports) { init_esm_shims(); var __import___Debug = __toESM(require_Debug()); var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === void 0) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = exports && exports.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); } __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigCache = void 0; var tsdoc_config_1 = __import__microsoft_tsdocConfig; var path23 = __importStar(__import_path); var Debug_1 = __import___Debug; function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _fs = __import_fs; var _path = __import_path; var MAX_PATH_SEARCH_DEPTH2 = 30; var depth2 = 0; var ROOT_FILES = [ "storm-workspace.json", "storm-workspace.json", "storm-workspace.yaml", "storm-workspace.yml", "storm-workspace.js", "storm-workspace.ts", ".storm-workspace.json", ".storm-workspace.yaml", ".storm-workspace.yml", ".storm-workspace.js", ".storm-workspace.ts", "lerna.json", "nx.json", "turbo.json", "npm-workspace.json", "yarn-workspace.json", "pnpm-workspace.json", "npm-workspace.yaml", "yarn-workspace.yaml", "pnpm-workspace.yaml", "npm-workspace.yml", "yarn-workspace.yml", "pnpm-workspace.yml", "npm-lock.json", "yarn-lock.json", "pnpm-lock.json", "npm-lock.yaml", "yarn-lock.yaml", "pnpm-lock.yaml", "npm-lock.yml", "yarn-lock.yml", "pnpm-lock.yml", "bun.lockb" ]; var ROOT_DIRECTORIES = [ ".storm-workspace", ".nx", ".github", ".vscode", ".verdaccio" ]; function findWorkspaceRoot3(startPath) { const _startPath = _nullishCoalesce(startPath, () => process.cwd()); if (ROOT_DIRECTORIES.some( (endDirName) => _fs.existsSync.call(void 0, _path.join.call(void 0, _startPath, endDirName)) )) { return _startPath; } if (ROOT_FILES.some( (endFileName) => _fs.existsSync.call(void 0, _path.join.call(void 0, _startPath, endFileName)) )) { return _startPath; } if (_startPath !== "/" && depth2++ < MAX_PATH_SEARCH_DEPTH2) { const parent = _path.join.call(void 0, _startPath, ".."); return findWorkspaceRoot3(parent); } return void 0; } var CACHE_CHECK_INTERVAL_MS = 3 * 1e3; var CACHE_EXPIRE_MS = 20 * 1e3; var CACHE_MAX_SIZE = 100; var ConfigCache = class _ConfigCache { /** * Node.js equivalent of performance.now(). */ static _getTimeInMs() { const [seconds, nanoseconds] = process.hrtime(); return seconds * 1e3 + nanoseconds / 1e6; } static getForSourceFile(sourceFilePath, tsConfigRootDir) { const sourceFileFolder = path23.dirname(path23.resolve(sourceFilePath)); const configFilePath = tsConfigRootDir ? path23.join(tsConfigRootDir, tsdoc_config_1.TSDocConfigFile.FILENAME) : tsdoc_config_1.TSDocConfigFile.findConfigPathForFolder(sourceFileFolder); const cacheKey = configFilePath || sourceFileFolder + "/"; Debug_1.Debug.log(`Cache key: "${cacheKey}"`); const nowMs = _ConfigCache._getTimeInMs(); let cachedConfig = void 0; cachedConfig = _ConfigCache._cachedConfigs.get(cacheKey); if (cachedConfig) { Debug_1.Debug.log("Cache hit"); const loadAgeMs = nowMs - cachedConfig.loadTimeMs; const lastCheckAgeMs = nowMs - cachedConfig.lastCheckTimeMs; if (loadAgeMs > CACHE_EXPIRE_MS || loadAgeMs < 0) { Debug_1.Debug.log("Evicting because item is expired"); cachedConfig = void 0; _ConfigCache._cachedConfigs.delete(cacheKey); } else if (lastCheckAgeMs > CACHE_CHECK_INTERVAL_MS || lastCheckAgeMs < 0) { Debug_1.Debug.log("Checking for modifications"); cachedConfig.lastCheckTimeMs = nowMs; if (cachedConfig.configFile.checkForModifiedFiles()) { Debug_1.Debug.log("Evicting because item was modified"); cachedConfig = void 0; _ConfigCache._cachedConfigs.delete(cacheKey); } } } if (!cachedConfig) { if (_ConfigCache._cachedConfigs.size > CACHE_MAX_SIZE) { Debug_1.Debug.log("Clearing cache"); _ConfigCache._cachedConfigs.clear(); } const configFile = tsdoc_config_1.TSDocConfigFile.loadFile(configFilePath); if (configFile.fileNotFound) { Debug_1.Debug.log(`File not found: "${configFilePath}"`); } else { Debug_1.Debug.log(`Loaded: "${configFilePath}"`); } cachedConfig = { configFile, lastCheckTimeMs: nowMs, loadTimeMs: nowMs }; _ConfigCache._cachedConfigs.set(cacheKey, cachedConfig); } return cachedConfig.configFile; } static _checkConfigFilePath(workspaceRoot, configFilePath) { const workspaceRootPath = workspaceRoot ? workspaceRoot : "./"; if (!configFilePath) { return void 0; } if (_fs.existsSync(configFilePath)) { return configFilePath; } else if (_fs.existsSync( path23.join( workspaceRootPath, configFilePath ) )) { return path23.join( workspaceRootPath, configFilePath ); } else if (_fs.existsSync( path23.join( workspaceRootPath, "node_modules", configFilePath ) )) { return path23.join( workspaceRootPath, "node_modules", configFilePath ); } else if (_fs.existsSync( path23.join( workspaceRootPath, "node_modules", "@storm-software", "tsdoc", configFilePath ) )) { return path23.join( workspaceRootPath, "node_modules", "@storm-software", "tsdoc", configFilePath ); } else if (_fs.existsSync( path23.join( workspaceRootPath, "node_modules", "@storm-software", "tsdoc", "config", configFilePath ) )) { return path23.join( workspaceRootPath, "node_modules", "@storm-software", "tsdoc", "config", configFilePath ); } else if (_fs.existsSync( path23.join( workspaceRootPath, "node_modules", "@storm-software", "tsdoc", "dist", configFilePath ) )) { return path23.join( workspaceRootPath, "node_modules", "@storm-software", "tsdoc", "dist", configFilePath ); } return void 0; } static getStormConfigFile(options) { const type = options && options.type ? options.type : "recommended"; const configFile = options && options.configFile ? options.configFile : void 0; let workspaceRoot = ""; if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) { workspaceRoot = process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH; } if (!workspaceRoot) { workspaceRoot = findWorkspaceRoot3(); } let currentConfigFile = process.env.STORM_TSDOC_CONFIG_FILE ? process.env.STORM_TSDOC_CONFIG_FILE : configFile; Debug_1.Debug.log(`Config file from user options: ${currentConfigFile || "(none)"}`); let configFilePath = _ConfigCache._checkConfigFilePath( workspaceRoot, currentConfigFile ); if (!configFilePath) { currentConfigFile = `${((process.env.STORM_TSDOC_TYPE ? process.env.STORM_TSDOC_TYPE : type) || "recommended").replace(/\.jsonc?$/, "")}.json`; Debug_1.Debug.log(`Config file from user options not found, trying: ${currentConfigFile}`); configFilePath = _ConfigCache._checkConfigFilePath( workspaceRoot, currentConfigFile ); if (!configFilePath) { configFilePath = _ConfigCache._checkConfigFilePath( workspaceRoot, "recommended.json" ); if (!configFilePath) { configFilePath = _ConfigCache._checkConfigFilePath( workspaceRoot, "tsdoc.json" ); } } } const cacheKey = configFilePath || "missing-config-file"; Debug_1.Debug.log(`Storm Software Configuration Cache key: "${cacheKey}"`); const nowMs = _ConfigCache._getTimeInMs(); let cachedConfig = void 0; cachedConfig = _ConfigCache._cachedConfigs.get(cacheKey); if (cachedConfig) { Debug_1.Debug.log("Cache hit"); const loadAgeMs = nowMs - cachedConfig.loadTimeMs; const lastCheckAgeMs = nowMs - cachedConfig.lastCheckTimeMs; if (loadAgeMs > CACHE_EXPIRE_MS || loadAgeMs < 0) { Debug_1.Debug.log("Evicting because item is expired"); cachedConfig = void 0; _ConfigCache._cachedConfigs.delete(cacheKey); } else if (lastCheckAgeMs > CACHE_CHECK_INTERVAL_MS || lastCheckAgeMs < 0) { Debug_1.Debug.log("Checking for modifications"); cachedConfig.lastCheckTimeMs = nowMs; if (cachedConfig.configFile.checkForModifiedFiles()) { Debug_1.Debug.log("Evicting because item was modified"); cachedConfig = void 0; _ConfigCache._cachedConfigs.delete(cacheKey); } } } if (!cachedConfig) { if (_ConfigCache._cachedConfigs.size > CACHE_MAX_SIZE) { Debug_1.Debug.log("Clearing cache"); _ConfigCache._cachedConfigs.clear(); } const configFile2 = tsdoc_config_1.TSDocConfigFile.loadFile(configFilePath); if (configFile2.fileNotFound) { Debug_1.Debug.log(`File not found: "${configFilePath}"`); } else { Debug_1.Debug.log(`Loaded: "${configFilePath}"`); } cachedConfig = { configFile: configFile2, lastCheckTimeMs: nowMs, loadTimeMs: nowMs }; _ConfigCache._cachedConfigs.set(cacheKey, cachedConfig); } return cachedConfig.configFile; } }; exports.ConfigCache = ConfigCache; ConfigCache._cachedConfigs = /* @__PURE__ */ new Map(); ConfigCache._cachedPaths = /* @__PURE__ */ new Map(); } }); var require_lib = __commonJS({ "../../node_modules/.pnpm/eslint-plugin-tsdoc@0.4.0_patch_hash=11b9fbe0e91a2ce3492e80b89a7502a9ff364683b23b9bdfc2c979d988e1682b/node_modules/eslint-plugin-tsdoc/lib/index.js"(exports, module) { init_esm_shims(); var __import___Debug = __toESM(require_Debug()); var __import___ConfigCache = __toESM(require_ConfigCache()); var tsdoc_1 = __import__microsoft_tsdoc; var Debug_1 = __import___Debug; var ConfigCache_1 = __import___ConfigCache; var tsdocMessageIds = {}; var defaultTSDocConfiguration = new tsdoc_1.TSDocConfiguration(); defaultTSDocConfiguration.allTsdocMessageIds.forEach((messageId) => { tsdocMessageIds[messageId] = `${messageId}: {{unformattedText}}`; }); var plugin4 = { rules: { // NOTE: The actual ESLint rule name will be "tsdoc/syntax". It is calculated by deleting "eslint-plugin-" // from the NPM package name, and then appending this string. syntax: { meta: { messages: Object.assign({ "error-loading-storm-config": `Error loading Storm Software's shared TSDoc config file: {{details}} Please ensure "@storm-software/tsdoc" is installed in the workspace root.`, "error-loading-config-file": "Error loading TSDoc config file:\n{{details}}", "error-applying-storm-config": "Error applying Storm Software's shared TSDoc configuration: {{details}}", "error-applying-config": "Error applying TSDoc configuration: {{details}}" }, tsdocMessageIds), type: "problem", docs: { description: "Validates that TypeScript documentation comments conform to the TSDoc standard", category: "Stylistic Issues", recommended: true, url: "https://tsdoc.org/pages/packages/eslint-plugin-tsdoc" }, schema: [ { type: "object", properties: { type: { type: "string", enum: ["typedoc", "api-extractor", "base", "core", "callouts", "recommended"], description: "The TSDoc configuration type to use from '@storm-software/tsdoc'. Defaults to 'recommended' (@storm-software/tsdoc/recommended.json)." }, configFile: { type: "string", description: "The TSDoc configuration file to use." } }, additionalProperties: false } ] }, defaultOptions: [ { type: "recommended" } ], create: (context) => { const tsdocConfiguration = new tsdoc_1.TSDocConfiguration(); const tsConfigDir = context.parserOptions.tsconfigRootDir; const sourceFilePath = context.filename; Debug_1.Debug.log(`Linting: "${sourceFilePath}"`); try { let tsdocConfigFile = {}; try { const userOptions = context.options ? Array.isArray(context.options) ? context.options.length > 0 ? context.options[0] : {} : context.options : {}; const config3 = { type: userOptions.type || "recommended", configFile: userOptions.configFile }; Debug_1.Debug.log(`Using eslint-plugin-tsdoc config: ${JSON.stringify(config3, void 0, 2)}`); tsdocConfigFile = ConfigCache_1.ConfigCache.getStormConfigFile(config3); if (!tsdocConfigFile.fileNotFound) { if (tsdocConfigFile.hasErrors) { context.report({ loc: { line: 1, column: 1 }, messageId: "error-loading-storm-config", data: { details: tsdocConfigFile.getErrorSummary() } }); } try { tsdocConfigFile.configureParser(tsdocConfiguration); } catch (e) { context.report({ loc: { line: 1, column: 1 }, messageId: "error-applying-storm-config", data: { details: e.message } }); } } } catch (e) { context.report({ loc: { line: 1, column: 1 }, messageId: "error-loading-storm-config", data: { details: `Unexpected exception: ${e.message}` } }); } if (!tsdocConfigFile || tsdocConfigFile.fileNotFound || tsdocConfigFile.hasErrors) { tsdocConfigFile = ConfigCache_1.ConfigCache.getForSourceFile(sourceFilePath, tsConfigDir); if (!tsdocConfigFile.fileNotFound) { if (tsdocConfigFile.hasErrors) { context.report({ loc: { line: 1, column: 1 }, messageId: "error-loading-config-file", data: { details: tsdocConfigFile.getErrorSummary() } }); } try { tsdocConfigFile.configureParser(tsdocConfiguration); } catch (e) { context.report({ loc: { line: 1, column: 1 }, messageId: "error-applying-config", data: { details: e.message } }); } } } } catch (e) { context.report({ loc: { line: 1, column: 1 }, messageId: "error-loading-config-file", data: { details: `Unexpected exception: ${e.message}` } }); } const tsdocParser = new tsdoc_1.TSDocParser(tsdocConfiguration); const sourceCode = context.getSourceCode(); const checkCommentBlocks = function(node2) { for (const comment of sourceCode.getAllComments()) { if (comment.type !== "Block") { continue; } if (!comment.range) { continue; } const textRange = tsdoc_1.TextRange.fromStringRange(sourceCode.text, comment.range[0], comment.range[1]); if (textRange.length < 5) { continue; } if (textRange.buffer[textRange.pos + 2] !== "*") { continue; } const parserContext = tsdocParser.parseRange(textRange); for (const message2 of parserContext.log.messages) { context.report({ loc: { start: sourceCode.getLocFromIndex(message2.textRange.pos), end: sourceCode.getLocFromIndex(message2.textRange.end) }, messageId: message2.messageId, data: { unformattedText: message2.unformattedText } }); } } }; return { Program: checkCommentBlocks }; } } } }; module.exports = plugin4; } }); // src/preset.ts init_esm_shims(); // src/configs/astro.ts init_esm_shims(); async function astro(options = {}) { const { files = [GLOB_ASTRO], overrides = {}, stylistic: stylistic2 = true } = options; const [pluginAstro, parserAstro, parserTs] = await Promise.all([ interopDefault(import('eslint-plugin-astro')), interopDefault(import('astro-eslint-parser')), interopDefault(import('@typescript-eslint/parser')) ]); return [ { name: "storm/astro/setup", plugins: { astro: pluginAstro } }, { files, languageOptions: { globals: pluginAstro.environments.astro.globals, parser: parserAstro, parserOptions: { extraFileExtensions: [".astro"], parser: parserTs }, sourceType: "module" }, name: "storm/astro/rules", processor: "astro/client-side-ts", rules: { // use recommended rules "astro/missing-client-only-directive-value": "error", "astro/no-conflict-set-directives": "error", "astro/no-deprecated-astro-canonicalurl": "error", "astro/no-deprecated-astro-fetchcontent": "error", "astro/no-deprecated-astro-resolve": "error", "astro/no-deprecated-getentrybyslug": "error", "astro/no-set-html-directive": "off", "astro/no-unused-define-vars-in-style": "error", "astro/semi": "off", "astro/valid-compile": "error", ...stylistic2 ? { "style/indent": "off", "style/jsx-closing-tag-location": "off", "style/jsx-one-expression-per-line": "off", "style/no-multiple-empty-lines": "off" } : {}, ...overrides } } ]; } // src/configs/cspell.ts init_esm_shims(); async function cspell(options = {}) { const { configFile = "./.vscode/cspell.json", overrides = {} } = options; return [ { name: "storm/cspell/rules", ...cspellConfig, rules: { ...cspellConfig.rules, "@cspell/spellchecker": [ "warn", { configFile: joinPaths(findWorkspaceRoot(), configFile), generateSuggestions: true, numSuggestions: 10, autoFix: true } ], ...overrides } } ]; } // src/configs/disables.ts init_esm_shims(); async function disables() { return [ { files: [`**/scripts/${GLOB_SRC}`], name: "storm/disables/scripts", rules: { "no-console": "off", "ts/explicit-function-return-type": "off" } }, { files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`], name: "storm/disables/cli", rules: { "no-console": "off" } }, { files: ["**/*.d.?([cm])ts"], name: "storm/disables/dts", rules: { "eslint-comments/no-unlimited-disable": "off", "import/no-duplicates": "off", "no-restricted-syntax": "off", "unused-imports/no-unused-vars": "off" } }, { files: ["**/*.js", "**/*.cjs"], name: "storm/disables/cjs", rules: { "ts/no-require-imports": "off" } }, { files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`], name: "storm/disables/config-files", rules: { "no-console": "off", "ts/explicit-function-return-type": "off" } } ]; } // src/configs/formatters.ts init_esm_shims(); // src/configs/stylistic.ts init_esm_shims(); var StylisticConfigDefaults = { indent: 2, jsx: true, quotes: "double", semi: true }; async function stylistic(options = {}) { const { indent = 2, jsx: jsx2 = true, overrides = {}, quotes = "double", semi = true, lineEndings = "unix" } = { ...StylisticConfigDefaults, ...options }; const pluginStylistic = await interopDefault( import('@stylistic/eslint-plugin') ); const config3 = pluginStylistic.configs.customize({ indent, jsx: jsx2, pluginName: "style", quotes, semi }); return [ { name: "storm/stylistic/rules", plugins: { style: pluginStylistic }, rules: { ...config3.rules, "style/lines-around-comment": "off", "style/linebreak-style": ["error", lineEndings], "style/comma-dangle": ["error", "never"], "style/comma-style": ["error", "last"], "style/quotes": ["error", quotes], "style/semi": ["error", semi ? "always" : "never"], "style/indent": ["error", indent, { SwitchCase: 1 }], "style/operator-linebreak": [ "error", "after", { overrides: { "=": "none", "?": "before", ":": "before" } } ], "style/jsx-indent": ["error", indent], "style/jsx-quotes": [ "error", quotes === "single" ? "prefer-single" : "prefer-double" ], "style/brace-style": ["error", "1tbs", { allowSingleLine: false }], ...overrides } } ]; } // src/configs/formatters.ts function mergePrettierOptions(options, overrides = {}) { return { ...options, ...overrides, plugins: [...overrides.plugins || [], ...options.plugins || []] }; } async function formatters(options = {}, stylistic2 = {}) { if (options === true) { const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml"); options = { astro: isPackageInScope("prettier-plugin-astro"), css: true, graphql: true, html: true, markdown: true, svg: isPrettierPluginXmlInScope, xml: isPrettierPluginXmlInScope }; } await ensurePackages([ "eslint-plugin-format", options.astro ? "prettier-plugin-astro" : void 0, options.xml || options.svg ? "@prettier/plugin-xml" : void 0 ]); const { indent = 2, quotes = "double", semi = true } = { ...StylisticConfigDefaults, ...stylistic2 }; const prettierOptions = defu( { proseWrap: "always", quoteProps: "preserve", bracketSameLine: true, bracketSpacing: true, arrowParens: "avoid", endOfLine: "lf", printWidth: 120, semi, singleQuote: quotes === "single", tabWidth: typeof indent === "number" ? indent : 2, trailingComma: "none", useTabs: indent === "tab" }, options.prettierOptions ?? {} ); const prettierXmlOptions = { xmlQuoteAttributes: "double", xmlSelfClosingSpace: true, xmlSortAttributesByKey: false, xmlWhitespaceSensitivity: "ignore" }; const dprintOptions = defu( { indentWidth: typeof indent === "number" ? indent : 2, quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble", useTabs: indent === "tab" }, options.dprintOptions ?? {} ); const pluginFormat = await interopDefault(import('eslint-plugin-format')); const configs4 = [ { name: "storm/formatter/setup", plugins: { format: pluginFormat } } ]; if (options.css) { configs4.push( { files: [GLOB_CSS, GLOB_POSTCSS], languageOptions: { parser: parserPlain }, name: "storm/formatter/css", rules: { "format/prettier": [ "error", mergePrettierOptions(prettierOptions, { parser: "css" }) ] } }, { files: [GLOB_SCSS], languageOptions: { parser: parserPlain }, name: "storm/formatter/scss", rules: { "format/prettier": [ "error", mergePrettierOptions(prettierOptions, { parser: "scss" }) ] } }, { files: [GLOB_LESS], languageOptions: { parser: parserPlain }, name: "storm/formatter/less", rules: { "format/prettier": [ "error", mergePrettierOptions(prettierOptions, { parser: "less" }) ] } } ); } if (options.html) { configs4.push({ files: [GLOB_HTML], languageOptions: { parser: parserPlain }, name: "storm/formatter/html", rules: { "format/prettier": [ "error", mergePrettierOptions(prettierOptions, { parser: "html" }) ] } }); } if (options.xml) { configs4.push({ files: [GLOB_XML], languageOptions: { parser: parserPlain }, name: "storm/formatter/xml", rules: { "format/prettier": [ "error", mergePrettierOptions( { ...prettierXmlOptions, ...prettierOptions }, { parser: "xml", plugins: ["@prettier/plugin-xml"] } ) ] } }); } if (options.svg) { configs4.push({ files: [GLOB_SVG], languageOptions: { parser: parserPlain }, name: "storm/formatter/svg", rules: { "format/prettier": [ "error", mergePrettierOptions( { ...prettierXmlOptions, ...prettierOptions }, { parser: "xml", plugins: ["@prettier/plugin-xml"] } ) ] } }); } if (options.markdown) { const formater = options.markdown === true ? "prettier" : options.markdown; configs4.push({ files: [GLOB_MARKDOWN], languageOptions: { parser: parserPlain }, name: "storm/formatter/markdown", rules: { [`format/${formater}`]: [ "error", formater === "prettier" ? mergePrettierOptions(prettierOptions, { embeddedLanguageFormatting: "off", parser: "markdown" }) : { ...dprintOptions, language: "markdown" } ] } }); } if (options.astro) { configs4.push({ files: [GLOB_ASTRO], languageOptions: { parser: parserPlain }, name: "storm/formatter/astro", rules: { "format/prettier": [ "error", mergePrettierOptions(prettierOptions, { parser: "astro", plugins: ["prettier-plugin-astro"] }) ] } }); configs4.push({ files: [GLOB_ASTRO, GLOB_ASTRO_TS], name: "storm/formatter/astro/disables", rules: { "style/arrow-parens": "off", "style/block-spacing": "off", "style/comma-dangle": "off", "style/indent": "off", "style/no-multi-spaces": "off", "style/quotes": "off", "style/semi": "off" } }); } if (options.graphql) { configs4.push({ files: [GLOB_GRAPHQL], languageOptions: { parser: parserPlain }, name: "storm/formatter/graphql", rules: { "format/prettier": [ "error", mergePrettierOptions(prettierOptions, { parser: "graphql" }) ] } }); } return configs4; } // src/configs/graphql.ts init_esm_shims(); async function graphql(options = {}) { const { relay = true, operations = true, schema = true, overrides = {} } = options; await ensurePackages([ "@graphql-eslint/eslint-plugin", "eslint-plugin-relay" ]); const [pluginGraphQL, pluginRelay] = await Promise.all([ interopDefault(import('@graphql-eslint/eslint-plugin')), interopDefault(import('eslint-plugin-relay')) ]); return [ { name: "storm/graphql/setup", files: ["**/*.graphql", "**/*.gql"], languageOptions: { parser: pluginGraphQL.parser }, plugins: { "@graphql-eslint": pluginGraphQL } }, { name: "storm/graphql/rules", plugins: { graphql: pluginGraphQL }, rules: { ...schema ? { "@graphql-eslint/description-style": "error", "@graphql-eslint/known-argument-names": "error", "@graphql-eslint/known-directives": "error", "@graphql-eslint/known-type-names": "error", "@graphql-eslint/lone-schema-definition": "error", "@graphql-eslint/naming-convention": [ "error", { types: "PascalCase", FieldDefinition: "camelCase", InputValueDefinition: "camelCase", Argument: "camelCase", DirectiveDefinition: "camelCase", EnumValueDefinition: "UPPER_CASE", "FieldDefinition[parent.name.value=Query]": { forbiddenPrefixes: ["query", "get"], forbiddenSuffixes: ["Query"] }, "FieldDefinition[parent.name.value=Mutation]": { forbiddenPrefixes: ["mutation"], forbiddenSuffixes: ["Mutation"] }, "FieldDefinition[parent.name.value=Subscription]": { forbiddenPrefixes: ["subscription"], forbiddenSuffixes: ["Subscription"] }, "EnumTypeDefinition,EnumTypeExtension": { forbiddenPrefixes: ["Enum"], forbiddenSuffixes: ["Enum"] }, "InterfaceTypeDefinition,InterfaceTypeExtension": { forbiddenPrefixes: ["Interface"], forbiddenSuffixes: ["Interface"] }, "UnionTypeDefinition,UnionTypeExtension": { forbiddenPrefixes: ["Union"], forbiddenSuffixes: ["Union"] }, "ObjectTypeDefinition,ObjectTypeExtension": { forbiddenPrefixes: ["Type"], forbiddenSuffixes: ["Type"] } } ], "@graphql-eslint/no-hashtag-description": "error", "@graphql-eslint/no-typename-prefix": "error", "@graphql-eslint/no-unreachable-types": "error", "@graphql-eslint/possible-type-extension": "error", "@graphql-eslint/provided-required-arguments": "error", "@graphql-eslint/require-deprecation-reason": "error", "@graphql-eslint/require-description": [ "error", { types: true, DirectiveDefinition: true, rootField: true } ], "@graphql-eslint/strict-id-in-types": "error", "@graphql-eslint/unique-directive-names": "error", "@graphql-eslint/unique-directive-names-per-location": "error", "@graphql-eslint/unique-enum-value-names": "error", "@graphql-eslint/unique-field-definition-names": "error", "@graphql-eslint/unique-operation-types": "error", "@graphql-eslint/unique-type-names": "error" } : {}, ...operations ? { "@graphql-eslint/executable-definitions": "error", "@graphql-eslint/fields-on-correct-type": "error", "@graphql-eslint/fragments-on-composite-type": "error", "@graphql-eslint/known-argument-names": "error", "@graphql-eslint/known-directives": "error", "@graphql-eslint/known-fragment-names": "error", "@graphql-eslint/known-type-names": "error", "@graphql-eslint/lone-anonymous-operation": "error", "@graphql-eslint/naming-convention": [ "error", { VariableDefinition: "camelCase", OperationDefinition: { style: "PascalCase", forbiddenPrefixes: [ "Query", "Mutation", "Subscription", "Get" ], forbiddenSuffixes: ["Query", "Mutation", "Subscription"] }, FragmentDefinition: { style: "PascalCase", forbiddenPrefixes: ["Fragment"], forbiddenSuffixes: ["Fragment"] } } ], "@graphql-eslint/no-anonymous-operations": "error", "@graphql-eslint/no-deprecated": "error", "@graphql-eslint/no-duplicate-fields": "error", "@graphql-eslint/no-fragment-cycles": "error", "@graphql-eslint/no-undefined-variables": "error", "@graphql-eslint/no-unused-fragments": "error", "@graphql-eslint/no-unused-variables": "error", "@graphql-eslint/one-field-subscriptions": "error", "@graphql-eslint/overlapping-fields-can-be-merged": "error", "@graphql-eslint/possible-fragment-spread": "error", "@graphql-eslint/provided-required-arguments": "error", "@graphql-eslint/require-selections": "error", "@graphql-eslint/scalar-leafs": "error", "@graphql-eslint/selection-set-depth": ["error", { maxDepth: 7 }], "@graphql-eslint/unique-argument-names": "error", "@graphql-eslint/unique-directive-names-per-location": "error", "@graphql-eslint/unique-fragment-name": "error", "@graphql-eslint/unique-input-field-names": "error", "@graphql-eslint/unique-operation-name": "error", "@graphql-eslint/unique-variable-names": "error", "@graphql-eslint/value-literals-of-correct-type": "error", "@graphql-eslint/variables-are-input-types": "error", "@graphql-eslint/variables-in-allowed-position": "error" } : {}, ...overrides } }, relay ? { name: "storm/graphql/relay", plugins: { relay: pluginRelay }, rules: { // errors "relay/graphql-syntax": "error", "relay/graphql-naming": "error", // warnings "relay/compat-uses-vars": "warn", "relay/generated-typescript-types": "warn", "relay/no-future-added-value": "warn", "relay/unused-fields": "warn", "relay/must-colocate-fragment-spreads": "warn", "relay/function-required-argument": "warn", "relay/hook-required-argument": "warn", // @graphql-eslint rules "@graphql-eslint/relay-arguments": "error", "@graphql-eslint/relay-connection-types": "error", "@graphql-eslint/relay-edge-types": "error", "@graphql-eslint/relay-page-info": "error" } } : {} ]; } // src/configs/ignores.ts init_esm_shims(); async function ignores(userIgnores = []) { return [ { ignores: [...GLOB_EXCLUDE, ...userIgnores], name: "storm/ignores" } ]; } // src/configs/imports.ts init_esm_shims(); // src/plugins.ts init_esm_shims(); // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/index.js init_esm_shims(); // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/electron.js init_esm_shims(); var electron_default = { settings: { "import-x/core-modules": ["electron"] } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/errors.js init_esm_shims(); var errors_default = { plugins: ["import-x"], rules: { "import-x/no-unresolved": 2, "import-x/named": 2, "import-x/namespace": 2, "import-x/default": 2, "import-x/export": 2 } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/flat/electron.js init_esm_shims(); var electron_default2 = { settings: { "import-x/core-modules": ["electron"] } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/flat/errors.js init_esm_shims(); var errors_default2 = { rules: { "import-x/no-unresolved": 2, "import-x/named": 2, "import-x/namespace": 2, "import-x/default": 2, "import-x/export": 2 } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/flat/react-native.js init_esm_shims(); var react_native_default = { settings: { "import-x/resolver": { node: { extensions: [".js", ".web.js", ".ios.js", ".android.js"] } } } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/flat/react.js init_esm_shims(); var react_default = { settings: { "import-x/extensions": [".js", ".jsx", ".mjs", ".cjs"] }, languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/flat/recommended.js init_esm_shims(); var recommended_default = { rules: { "import-x/no-unresolved": "error", "import-x/named": "error", "import-x/namespace": "error", "import-x/default": "error", "import-x/export": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", "import-x/no-duplicates": "warn" } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/flat/stage-0.js init_esm_shims(); var stage_0_default = { rules: { "import-x/no-deprecated": 1 } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/flat/typescript.js init_esm_shims(); var typeScriptExtensions = [".ts", ".tsx", ".cts", ".mts"]; var allExtensions = [ ...typeScriptExtensions, ".js", ".jsx", ".cjs", ".mjs" ]; var typescript_default = { settings: { "import-x/extensions": allExtensions, "import-x/external-module-folders": ["node_modules", "node_modules/@types"], "import-x/parsers": { "@typescript-eslint/parser": [...typeScriptExtensions] }, "import-x/resolver": { typescript: true } }, rules: { "import-x/named": "off" } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/flat/warnings.js init_esm_shims(); var warnings_default = { rules: { "import-x/no-named-as-default": 1, "import-x/no-named-as-default-member": 1, "import-x/no-rename-default": 1, "import-x/no-duplicates": 1 } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/react-native.js init_esm_shims(); var react_native_default2 = { settings: { "import-x/resolver": { node: { extensions: [".js", ".web.js", ".ios.js", ".android.js"] } } } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/react.js init_esm_shims(); var react_default2 = { settings: { "import-x/extensions": [".js", ".jsx"] }, parserOptions: { ecmaFeatures: { jsx: true } } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/recommended.js init_esm_shims(); var recommended_default2 = { plugins: ["import-x"], rules: { "import-x/no-unresolved": "error", "import-x/named": "error", "import-x/namespace": "error", "import-x/default": "error", "import-x/export": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", "import-x/no-duplicates": "warn" }, parserOptions: { sourceType: "module", ecmaVersion: 2018 } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/stage-0.js init_esm_shims(); var stage_0_default2 = { plugins: ["import-x"], rules: { "import-x/no-deprecated": 1 } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/typescript.js init_esm_shims(); var typeScriptExtensions2 = [".ts", ".tsx", ".cts", ".mts"]; var allExtensions2 = [ ...typeScriptExtensions2, ".js", ".jsx", ".cjs", ".mjs" ]; var typescript_default2 = { settings: { "import-x/extensions": allExtensions2, "import-x/external-module-folders": ["node_modules", "node_modules/@types"], "import-x/parsers": { "@typescript-eslint/parser": [...typeScriptExtensions2] }, "import-x/resolver": { typescript: true } }, rules: { "import-x/named": "off" } }; // ../../node_modules/.pnpm/eslint-plugin-import-x@4.16.2_patch_hash=2fde63e367ada6ae348459ff5a2b0bbc53a12189dad6a5_b49ca862ca181cee53391dd5f2abeca1/node_modules/eslint-plugin-import-x/lib/config/warnings.js init_esm_shims(); var warnings_default2 = { plugins: ["import-x"], rules: { "import-x/no-named-as-default": 1, "import-x/no-named-as-default-member": 1, "import-x/no-rename-def