@qualcomm-ui/eslint-config-mdx 3.0.3 → 4.0.0

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/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import*as e from"eslint-plugin-mdx";import t from"eslint-plugin-react";var __commonJSMin=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),n=__commonJSMin((e=>{var t=[`env`,`extends`,`globals`,`ignorePatterns`,`noInlineConfig`,`overrides`,`parser`,`parserOptions`,`reportUnusedDisableDirectives`,`root`],n=new Set([`basePath`,`ignores`,`name`]);function getConfigName(e,t){return e.name?e.name:`UserConfig${t}`}function getExtensionName(e,t){return typeof e==`string`?e:e.name?e.name:`ExtendedConfig${t}`}function isLegacyConfig(e){if(Array.isArray(e.plugins))return!0;for(let n of t)if(n in e)return!0;return!1}function isGlobalIgnores(e){return Object.keys(e).every(e=>n.has(e))}function getPluginMember(e){let t=e.indexOf(`/`);if(t===-1)return{namespace:``,name:e};let n=e.slice(0,t);if(n[0]===`@`&&n!==`@`){let r=e.indexOf(`/`,t+1);if(r!==-1)return n=e.slice(0,r),{namespace:n,name:e.slice(r+1)}}let r=e.slice(t+1);return{namespace:n,name:r}}function normalizePluginConfig(e,t,n){let r=t.meta?.namespace;if(!r||r===e||!n.rules&&!n.processor&&!n.language)return n;let i={...n};if(i.rules){let t=Object.keys(i.rules),n={};for(let a=0;a<t.length;a++){let o=t[a],{namespace:s,name:c}=getPluginMember(o);s===r?n[`${e}/${c}`]=i.rules[o]:n[o]=i.rules[o]}i.rules=n}if(typeof i.processor==`string`){let{namespace:t,name:n}=getPluginMember(i.processor);t&&t===r&&(i.processor=`${e}/${n}`)}if(typeof i.language==`string`){let{namespace:t,name:n}=getPluginMember(i.language);t===r&&(i.language=`${e}/${n}`)}return i}function deepNormalizePluginConfig(e,t,n,r){if(Array.isArray(n))return n.map(n=>deepNormalizePluginConfig(e,t,n,r));if(isLegacyConfig(n))throw TypeError(`Plugin config "${r}" is an eslintrc config and cannot be used in this context.`);return normalizePluginConfig(e,t,n)}function findPluginConfig(e,t){let{namespace:n,name:r}=getPluginMember(t),i=e.plugins?.[n];if(!i)throw TypeError(`Plugin "${n}" not found.`);let a=i.configs?.[r];if(a&&(Array.isArray(a)||!isLegacyConfig(a)))return deepNormalizePluginConfig(n,i,a,t);let o=i.configs?.[`flat/${r}`];if(o&&(Array.isArray(o)||!isLegacyConfig(o)))return deepNormalizePluginConfig(n,i,o,t);let s=a||o?`Plugin config "${r}" in plugin "${n}" is an eslintrc config and cannot be used in this context.`:`Plugin config "${r}" not found in plugin "${n}".`;throw TypeError(s)}function*flatTraverse(e,t=``){for(let n=0;n<e.length;n++){let r=t?`${t}[${n}]`:`[${n}]`;if(Array.isArray(e[n])){yield*flatTraverse(e[n],r);continue}yield{indexPath:r,value:e[n]}}}function extendConfigFiles(e=[],t=[]){if(!t.length)return e.concat();if(!e.length)return t.concat();let n=[];for(let r of e)for(let e of t){let t=[];Array.isArray(r)?t.push(...r):t.push(r),Array.isArray(e)?t.push(...e):t.push(e),n.push(t)}return n}function extendConfig(e,t,n,r){let i={...n};return isGlobalIgnores(n)||(e.files&&(i.files=extendConfigFiles(e.files,n.files)),e.ignores&&(i.ignores=e.ignores.concat(n.ignores??[]))),i.name=`${t} > ${r}`,e.basePath&&(i.basePath=e.basePath),i}function processExtends(e,t){if(!e.extends)return[e];if(!Array.isArray(e.extends))throw TypeError("The `extends` property must be an array.");let{extends:n,...r}=e,i=new WeakMap,a=n.map(t=>{if(typeof t==`string`){let n=findPluginConfig(e,t);return Array.isArray(n)?n.forEach((e,n)=>{i.set(e,`${t}[${n}]`)}):i.set(n,t),n}return t}),o=[];for(let{indexPath:n,value:s}of flatTraverse(a)){let a=s;if(`basePath`in a)throw TypeError("'basePath' in `extends` is not allowed.");if(`extends`in a)throw TypeError(`Nested 'extends' is not allowed.`);let c=t.get(e),l=i.get(s)??getExtensionName(s,n);o.push(extendConfig(r,c,a,l))}return isGlobalIgnores(r)||o.push(r),o.flat()}function processConfigList(e,t){return e.flatMap(e=>processExtends(e,t))}function defineConfig(...e){let t=new WeakMap,n=[];if(e.length===0)throw TypeError(`Expected one or more arguments.`);for(let{indexPath:r,value:i}of flatTraverse(e)){if(typeof i!=`object`||!i)throw TypeError(`Expected an object but received ${String(i)}.`);let e=i;t.set(e,getConfigName(e,r)),n.push(e)}return processConfigList(n,t)}var r=0;function globalIgnores(e,t){if(!Array.isArray(e))throw TypeError(`ignorePatterns must be an array`);if(e.length===0)throw TypeError(`ignorePatterns must contain at least one pattern`);let n=r++;return{name:t||`globalIgnores ${n}`,ignores:e}}e.defineConfig=defineConfig,e.globalIgnores=globalIgnores})),r={configs:{recommended:(0,__commonJSMin(((e,t)=>{var{defineConfig:r,globalIgnores:i}=n();t.exports={defineConfig:r,globalIgnores:i}}))().defineConfig)({...e.flat,plugins:{...e.flat.plugins,react:t},rules:{...e.flat.rules,"mdx/remark":`error`,"no-unused-expressions":`off`}})}};export{r as default};
1
+ import{createRequire as e}from"node:module";import*as t from"eslint-plugin-mdx";import n from"eslint-plugin-react";var __commonJSMin=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),r=e(import.meta.url),i=__commonJSMin((e=>{var t=r(`node:fs`),n=r(`node:path`),i=[`env`,`extends`,`globals`,`ignorePatterns`,`noInlineConfig`,`overrides`,`parser`,`parserOptions`,`reportUnusedDisableDirectives`,`root`],a=new Set([`basePath`,`ignores`,`name`]);function getConfigName(e,t){return e.name?e.name:`UserConfig${t}`}function getExtensionName(e,t){return typeof e==`string`?e:e.name?e.name:`ExtendedConfig${t}`}function isLegacyConfig(e){if(Array.isArray(e.plugins))return!0;for(let t of i)if(t in e)return!0;return!1}function isGlobalIgnores(e){return Object.keys(e).every(e=>a.has(e))}function getPluginMember(e){let t=e.indexOf(`/`);if(t===-1)return{namespace:``,name:e};let n=e.slice(0,t);if(n[0]===`@`&&n!==`@`){let r=e.indexOf(`/`,t+1);if(r!==-1)return n=e.slice(0,r),{namespace:n,name:e.slice(r+1)}}let r=e.slice(t+1);return{namespace:n,name:r}}function normalizePluginConfig(e,t,n){let r=t.meta?.namespace;if(!r||r===e||!n.rules&&!n.processor&&!n.language)return n;let i={...n};if(i.rules){let t=Object.keys(i.rules),n={};for(let a=0;a<t.length;a++){let o=t[a],{namespace:s,name:c}=getPluginMember(o);s===r?n[`${e}/${c}`]=i.rules[o]:n[o]=i.rules[o]}i.rules=n}if(typeof i.processor==`string`){let{namespace:t,name:n}=getPluginMember(i.processor);t&&t===r&&(i.processor=`${e}/${n}`)}if(typeof i.language==`string`){let{namespace:t,name:n}=getPluginMember(i.language);t===r&&(i.language=`${e}/${n}`)}return i}function deepNormalizePluginConfig(e,t,n,r){if(Array.isArray(n))return n.map(n=>deepNormalizePluginConfig(e,t,n,r));if(isLegacyConfig(n))throw TypeError(`Plugin config "${r}" is an eslintrc config and cannot be used in this context.`);return normalizePluginConfig(e,t,n)}function findPluginConfig(e,t){let{namespace:n,name:r}=getPluginMember(t),i=e.plugins?.[n];if(!i)throw TypeError(`Plugin "${n}" not found.`);let a=i.configs?.[r];if(a&&(Array.isArray(a)||!isLegacyConfig(a)))return deepNormalizePluginConfig(n,i,a,t);let o=i.configs?.[`flat/${r}`];if(o&&(Array.isArray(o)||!isLegacyConfig(o)))return deepNormalizePluginConfig(n,i,o,t);let s=a||o?`Plugin config "${r}" in plugin "${n}" is an eslintrc config and cannot be used in this context.`:`Plugin config "${r}" not found in plugin "${n}".`;throw TypeError(s)}function*flatTraverse(e,t=``){for(let n=0;n<e.length;n++){let r=t?`${t}[${n}]`:`[${n}]`;if(Array.isArray(e[n])){yield*flatTraverse(e[n],r);continue}yield{indexPath:r,value:e[n]}}}function extendConfigFiles(e=[],t=[]){if(!t.length)return e.concat();if(!e.length)return t.concat();let n=[];for(let r of e)for(let e of t){let t=[];Array.isArray(r)?t.push(...r):t.push(r),Array.isArray(e)?t.push(...e):t.push(e),n.push(t)}return n}function extendConfig(e,t,n,r){let i={...n};return isGlobalIgnores(n)||(e.files&&(i.files=extendConfigFiles(e.files,n.files)),e.ignores&&(i.ignores=e.ignores.concat(n.ignores??[]))),i.name=`${t} > ${r}`,e.basePath&&(i.basePath=e.basePath),i}function processExtends(e,t){if(!e.extends)return[e];if(!Array.isArray(e.extends))throw TypeError("The `extends` property must be an array.");let{extends:n,...r}=e,i=new WeakMap,a=n.map(t=>{if(typeof t==`string`){let n=findPluginConfig(e,t);return Array.isArray(n)?n.forEach((e,n)=>{i.set(e,`${t}[${n}]`)}):i.set(n,t),n}return t}),o=[];for(let{indexPath:n,value:s}of flatTraverse(a)){let a=s;if(`basePath`in a)throw TypeError("'basePath' in `extends` is not allowed.");if(`extends`in a)throw TypeError(`Nested 'extends' is not allowed.`);let c=t.get(e),l=i.get(s)??getExtensionName(s,n);o.push(extendConfig(r,c,a,l))}return isGlobalIgnores(r)||o.push(r),o.flat()}function processConfigList(e,t){return e.flatMap(e=>processExtends(e,t))}function defineConfig(...e){let t=new WeakMap,n=[];if(e.length===0)throw TypeError(`Expected one or more arguments.`);for(let{indexPath:r,value:i}of flatTraverse(e)){if(typeof i!=`object`||!i)throw TypeError(`Expected an object but received ${String(i)}.`);let e=i;t.set(e,getConfigName(e,r)),n.push(e)}return processConfigList(n,t)}var o=0;function globalIgnores(e,t){if(!Array.isArray(e))throw TypeError(`ignorePatterns must be an array`);if(e.length===0)throw TypeError(`ignorePatterns must contain at least one pattern`);let n=o++;return{name:t||`globalIgnores ${n}`,ignores:e}}function convertIgnorePatternToMinimatch(e){let t=e.startsWith(`!`),n=t?`!`:``,r=(t?e.slice(1):e).trimEnd();if([``,`**`,`/**`,`**/`].includes(r))return`${n}${r}`;let i=r.indexOf(`/`);return`${n}${i<0||i===r.length-1?`**/`:``}${(i===0?r.slice(1):r).replaceAll(/(?=((?:\\.|[^{(])*))\1([{(])/guy,`$1\\$2`)}${r.endsWith(`/**`)?`/*`:``}`}function ignoreFilePathToPatterns(e){return t.readFileSync(e,`utf8`).split(/\r?\n/u).map(e=>e.trim()).filter(e=>e&&!e.startsWith(`#`)).map(convertIgnorePatternToMinimatch)}function parseOptions(e){if(typeof e==`string`)return{gitignoreResolution:!1,name:e};let t=e??{};if(typeof t!=`object`||Array.isArray(t))throw TypeError("The options argument to `includeIgnoreFile()` should be an object or a string.");let n=t.gitignoreResolution??!1;if(typeof n!=`boolean`)throw TypeError("The `gitignoreResolution` option must be specified a boolean or omitted");let r=t.name??`Imported .gitignore patterns`;if(typeof r!=`string`)throw TypeError("The `name` option must be specified as a string or omitted.");return{gitignoreResolution:n,name:r}}function includeIgnoreFile(e,t){let r=!Array.isArray(e),i=Array.isArray(e)?e:[e];for(let e of i){if(typeof e!=`string`)throw TypeError("The first argument to `includeIgnoreFile()` should be a string or array of strings");if(!n.isAbsolute(e))throw Error(`The ignore file location must be an absolute path. Received ${e}`)}let{gitignoreResolution:a,name:o}=parseOptions(t);return r?{name:o,ignores:ignoreFilePathToPatterns(e),...a?{basePath:n.dirname(e)}:{}}:i.map((e,t)=>({name:`${o} (${t})`,ignores:ignoreFilePathToPatterns(e),...a?{basePath:n.dirname(e)}:{}}))}e.convertIgnorePatternToMinimatch=convertIgnorePatternToMinimatch,e.defineConfig=defineConfig,e.globalIgnores=globalIgnores,e.includeIgnoreFile=includeIgnoreFile})),a={configs:{recommended:(0,__commonJSMin(((e,t)=>{var{defineConfig:n,globalIgnores:r,includeIgnoreFile:a}=i();t.exports={defineConfig:n,globalIgnores:r,includeIgnoreFile:a}}))().defineConfig)({...t.flat,plugins:{...t.flat.plugins,react:n},rules:{...t.flat.rules,"mdx/remark":`error`,"no-unused-expressions":`off`}})}};export{a as default};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../node_modules/.pnpm/@eslint+config-helpers@0.4.2/node_modules/@eslint/config-helpers/dist/cjs/index.cjs","../../../../node_modules/.pnpm/eslint@9.39.1_jiti@2.7.0/node_modules/eslint/lib/config-api.js","../src/recommended.ts","../src/index.ts"],"sourcesContent":["'use strict';\n\n/**\n * @fileoverview defineConfig helper\n * @author Nicholas C. Zakas\n */\n\n//-----------------------------------------------------------------------------\n// Type Definitions\n//-----------------------------------------------------------------------------\n\n/** @import * as $eslintcore from \"@eslint/core\"; */\n/** @typedef {$eslintcore.ConfigObject} Config */\n/** @typedef {$eslintcore.LegacyConfigObject} LegacyConfig */\n/** @typedef {$eslintcore.Plugin} Plugin */\n/** @typedef {$eslintcore.RuleConfig} RuleConfig */\n/** @import * as $typests from \"./types.ts\"; */\n/** @typedef {$typests.ExtendsElement} ExtendsElement */\n/** @typedef {$typests.SimpleExtendsElement} SimpleExtendsElement */\n/** @typedef {$typests.ConfigWithExtends} ConfigWithExtends */\n/** @typedef {$typests.InfiniteArray<Config>} InfiniteConfigArray */\n/** @typedef {$typests.ConfigWithExtendsArray} ConfigWithExtendsArray */\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\nconst eslintrcKeys = [\n\t\"env\",\n\t\"extends\",\n\t\"globals\",\n\t\"ignorePatterns\",\n\t\"noInlineConfig\",\n\t\"overrides\",\n\t\"parser\",\n\t\"parserOptions\",\n\t\"reportUnusedDisableDirectives\",\n\t\"root\",\n];\n\nconst allowedGlobalIgnoreKeys = new Set([\"basePath\", \"ignores\", \"name\"]);\n\n/**\n * Gets the name of a config object.\n * @param {Config} config The config object.\n * @param {string} indexPath The index path of the config object.\n * @return {string} The name of the config object.\n */\nfunction getConfigName(config, indexPath) {\n\tif (config.name) {\n\t\treturn config.name;\n\t}\n\n\treturn `UserConfig${indexPath}`;\n}\n\n/**\n * Gets the name of an extension.\n * @param {SimpleExtendsElement} extension The extension.\n * @param {string} indexPath The index of the extension.\n * @return {string} The name of the extension.\n */\nfunction getExtensionName(extension, indexPath) {\n\tif (typeof extension === \"string\") {\n\t\treturn extension;\n\t}\n\n\tif (extension.name) {\n\t\treturn extension.name;\n\t}\n\n\treturn `ExtendedConfig${indexPath}`;\n}\n\n/**\n * Determines if a config object is a legacy config.\n * @param {Config|LegacyConfig} config The config object to check.\n * @return {config is LegacyConfig} `true` if the config object is a legacy config.\n */\nfunction isLegacyConfig(config) {\n\t// eslintrc's plugins must be an array; while flat config's must be an object.\n\tif (Array.isArray(config.plugins)) {\n\t\treturn true;\n\t}\n\n\tfor (const key of eslintrcKeys) {\n\t\tif (key in config) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Determines if a config object is a global ignores config.\n * @param {Config} config The config object to check.\n * @return {boolean} `true` if the config object is a global ignores config.\n */\nfunction isGlobalIgnores(config) {\n\treturn Object.keys(config).every(key => allowedGlobalIgnoreKeys.has(key));\n}\n\n/**\n * Parses a plugin member ID (rule, processor, etc.) and returns\n * the namespace and member name.\n * @param {string} id The ID to parse.\n * @returns {{namespace:string, name:string}} The namespace and member name.\n */\nfunction getPluginMember(id) {\n\tconst firstSlashIndex = id.indexOf(\"/\");\n\n\tif (firstSlashIndex === -1) {\n\t\treturn { namespace: \"\", name: id };\n\t}\n\n\tlet namespace = id.slice(0, firstSlashIndex);\n\n\t/*\n\t * Special cases:\n\t * 1. The namespace is `@`, that means it's referring to the\n\t * core plugin so `@` is the full namespace.\n\t * 2. The namespace starts with `@`, that means it's referring to\n\t * an npm scoped package. That means the namespace is the scope\n\t * and the package name (i.e., `@eslint/core`).\n\t */\n\tif (namespace[0] === \"@\" && namespace !== \"@\") {\n\t\tconst secondSlashIndex = id.indexOf(\"/\", firstSlashIndex + 1);\n\t\tif (secondSlashIndex !== -1) {\n\t\t\tnamespace = id.slice(0, secondSlashIndex);\n\t\t\treturn { namespace, name: id.slice(secondSlashIndex + 1) };\n\t\t}\n\t}\n\n\tconst name = id.slice(firstSlashIndex + 1);\n\n\treturn { namespace, name };\n}\n\n/**\n * Normalizes the plugin config by replacing the namespace with the plugin namespace.\n * @param {string} userNamespace The namespace of the plugin.\n * @param {Plugin} plugin The plugin config object.\n * @param {Config} config The config object to normalize.\n * @return {Config} The normalized config object.\n */\nfunction normalizePluginConfig(userNamespace, plugin, config) {\n\tconst pluginNamespace = plugin.meta?.namespace;\n\n\t// don't do anything if the plugin doesn't have a namespace or rules\n\tif (\n\t\t!pluginNamespace ||\n\t\tpluginNamespace === userNamespace ||\n\t\t(!config.rules && !config.processor && !config.language)\n\t) {\n\t\treturn config;\n\t}\n\n\tconst result = { ...config };\n\n\t// update the rules\n\tif (result.rules) {\n\t\tconst ruleIds = Object.keys(result.rules);\n\n\t\t/** @type {Record<string,RuleConfig|undefined>} */\n\t\tconst newRules = {};\n\n\t\tfor (let i = 0; i < ruleIds.length; i++) {\n\t\t\tconst ruleId = ruleIds[i];\n\t\t\tconst { namespace: ruleNamespace, name: ruleName } =\n\t\t\t\tgetPluginMember(ruleId);\n\n\t\t\tif (ruleNamespace === pluginNamespace) {\n\t\t\t\tnewRules[`${userNamespace}/${ruleName}`] = result.rules[ruleId];\n\t\t\t} else {\n\t\t\t\tnewRules[ruleId] = result.rules[ruleId];\n\t\t\t}\n\t\t}\n\n\t\tresult.rules = newRules;\n\t}\n\n\t// update the processor\n\n\tif (typeof result.processor === \"string\") {\n\t\tconst { namespace: processorNamespace, name: processorName } =\n\t\t\tgetPluginMember(result.processor);\n\n\t\tif (processorNamespace) {\n\t\t\tif (processorNamespace === pluginNamespace) {\n\t\t\t\tresult.processor = `${userNamespace}/${processorName}`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// update the language\n\tif (typeof result.language === \"string\") {\n\t\tconst { namespace: languageNamespace, name: languageName } =\n\t\t\tgetPluginMember(result.language);\n\n\t\tif (languageNamespace === pluginNamespace) {\n\t\t\tresult.language = `${userNamespace}/${languageName}`;\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Deeply normalizes a plugin config, traversing recursively into an arrays.\n * @param {string} userPluginNamespace The namespace of the plugin.\n * @param {Plugin} plugin The plugin object.\n * @param {Config|LegacyConfig|(Config|LegacyConfig)[]} pluginConfig The plugin config to normalize.\n * @param {string} pluginConfigName The name of the plugin config.\n * @return {InfiniteConfigArray} The normalized plugin config.\n * @throws {TypeError} If the plugin config is a legacy config.\n */\nfunction deepNormalizePluginConfig(\n\tuserPluginNamespace,\n\tplugin,\n\tpluginConfig,\n\tpluginConfigName,\n) {\n\t// if it's an array then it's definitely a new config\n\tif (Array.isArray(pluginConfig)) {\n\t\treturn pluginConfig.map(pluginSubConfig =>\n\t\t\tdeepNormalizePluginConfig(\n\t\t\t\tuserPluginNamespace,\n\t\t\t\tplugin,\n\t\t\t\tpluginSubConfig,\n\t\t\t\tpluginConfigName,\n\t\t\t),\n\t\t);\n\t}\n\n\t// if it's a legacy config, throw an error\n\tif (isLegacyConfig(pluginConfig)) {\n\t\tthrow new TypeError(\n\t\t\t`Plugin config \"${pluginConfigName}\" is an eslintrc config and cannot be used in this context.`,\n\t\t);\n\t}\n\n\treturn normalizePluginConfig(userPluginNamespace, plugin, pluginConfig);\n}\n\n/**\n * Finds a plugin config by name in the given config.\n * @param {Config} config The config object.\n * @param {string} pluginConfigName The name of the plugin config.\n * @return {InfiniteConfigArray} The plugin config.\n * @throws {TypeError} If the plugin config is not found or is a legacy config.\n */\nfunction findPluginConfig(config, pluginConfigName) {\n\tconst { namespace: userPluginNamespace, name: configName } =\n\t\tgetPluginMember(pluginConfigName);\n\tconst plugin = config.plugins?.[userPluginNamespace];\n\n\tif (!plugin) {\n\t\tthrow new TypeError(`Plugin \"${userPluginNamespace}\" not found.`);\n\t}\n\n\tconst directConfig = plugin.configs?.[configName];\n\n\t// Prefer direct config, but fall back to flat config if available\n\tif (directConfig) {\n\t\t// Arrays are always flat configs, and non-legacy configs can be used directly\n\t\tif (Array.isArray(directConfig) || !isLegacyConfig(directConfig)) {\n\t\t\treturn deepNormalizePluginConfig(\n\t\t\t\tuserPluginNamespace,\n\t\t\t\tplugin,\n\t\t\t\tdirectConfig,\n\t\t\t\tpluginConfigName,\n\t\t\t);\n\t\t}\n\t}\n\n\t// If it's a legacy config, or the config does not exist => look for the flat version\n\tconst flatConfig = plugin.configs?.[`flat/${configName}`];\n\tif (\n\t\tflatConfig &&\n\t\t(Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))\n\t) {\n\t\treturn deepNormalizePluginConfig(\n\t\t\tuserPluginNamespace,\n\t\t\tplugin,\n\t\t\tflatConfig,\n\t\t\tpluginConfigName,\n\t\t);\n\t}\n\n\t// If we get here, then the config was either not found or is a legacy config\n\tconst message =\n\t\tdirectConfig || flatConfig\n\t\t\t? `Plugin config \"${configName}\" in plugin \"${userPluginNamespace}\" is an eslintrc config and cannot be used in this context.`\n\t\t\t: `Plugin config \"${configName}\" not found in plugin \"${userPluginNamespace}\".`;\n\tthrow new TypeError(message);\n}\n\n/**\n * Flattens an array while keeping track of the index path.\n * @param {any[]} configList The array to traverse.\n * @param {string} indexPath The index path of the value in a multidimensional array.\n * @return {IterableIterator<{indexPath:string, value:any}>} The flattened list of values.\n */\nfunction* flatTraverse(configList, indexPath = \"\") {\n\tfor (let i = 0; i < configList.length; i++) {\n\t\tconst newIndexPath = indexPath ? `${indexPath}[${i}]` : `[${i}]`;\n\n\t\t// if it's an array then traverse it as well\n\t\tif (Array.isArray(configList[i])) {\n\t\t\tyield* flatTraverse(configList[i], newIndexPath);\n\t\t\tcontinue;\n\t\t}\n\n\t\tyield { indexPath: newIndexPath, value: configList[i] };\n\t}\n}\n\n/**\n * Extends a list of config files by creating every combination of base and extension files.\n * @param {(string|string[])[]} [baseFiles] The base files.\n * @param {(string|string[])[]} [extensionFiles] The extension files.\n * @return {(string|string[])[]} The extended files.\n */\nfunction extendConfigFiles(baseFiles = [], extensionFiles = []) {\n\tif (!extensionFiles.length) {\n\t\treturn baseFiles.concat();\n\t}\n\n\tif (!baseFiles.length) {\n\t\treturn extensionFiles.concat();\n\t}\n\n\t/** @type {(string|string[])[]} */\n\tconst result = [];\n\n\tfor (const baseFile of baseFiles) {\n\t\tfor (const extensionFile of extensionFiles) {\n\t\t\t/*\n\t\t\t * Each entry can be a string or array of strings. The end result\n\t\t\t * needs to be an array of strings, so we need to be sure to include\n\t\t\t * all of the items when there's an array.\n\t\t\t */\n\n\t\t\tconst entry = [];\n\n\t\t\tif (Array.isArray(baseFile)) {\n\t\t\t\tentry.push(...baseFile);\n\t\t\t} else {\n\t\t\t\tentry.push(baseFile);\n\t\t\t}\n\n\t\t\tif (Array.isArray(extensionFile)) {\n\t\t\t\tentry.push(...extensionFile);\n\t\t\t} else {\n\t\t\t\tentry.push(extensionFile);\n\t\t\t}\n\n\t\t\tresult.push(entry);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Extends a config object with another config object.\n * @param {Config} baseConfig The base config object.\n * @param {string} baseConfigName The name of the base config object.\n * @param {Config} extension The extension config object.\n * @param {string} extensionName The index of the extension config object.\n * @return {Config} The extended config object.\n */\nfunction extendConfig(baseConfig, baseConfigName, extension, extensionName) {\n\tconst result = { ...extension };\n\n\t// for global ignores there is no further work to be done, we just keep everything\n\tif (!isGlobalIgnores(extension)) {\n\t\t// for files we need to create every combination of base and extension files\n\t\tif (baseConfig.files) {\n\t\t\tresult.files = extendConfigFiles(baseConfig.files, extension.files);\n\t\t}\n\n\t\t// for ignores we just concatenation the extension ignores onto the base ignores\n\t\tif (baseConfig.ignores) {\n\t\t\tresult.ignores = baseConfig.ignores.concat(extension.ignores ?? []);\n\t\t}\n\t}\n\n\tresult.name = `${baseConfigName} > ${extensionName}`;\n\n\t// @ts-ignore -- ESLint types aren't updated yet\n\tif (baseConfig.basePath) {\n\t\t// @ts-ignore -- ESLint types aren't updated yet\n\t\tresult.basePath = baseConfig.basePath;\n\t}\n\n\treturn result;\n}\n\n/**\n * Processes a list of extends elements.\n * @param {ConfigWithExtends} config The config object.\n * @param {WeakMap<Config, string>} configNames The map of config objects to their names.\n * @return {Config[]} The flattened list of config objects.\n * @throws {TypeError} If the `extends` property is not an array or if nested `extends` is found.\n */\nfunction processExtends(config, configNames) {\n\tif (!config.extends) {\n\t\treturn [config];\n\t}\n\n\tif (!Array.isArray(config.extends)) {\n\t\tthrow new TypeError(\"The `extends` property must be an array.\");\n\t}\n\n\tconst {\n\t\t/** @type {Config[]} */\n\t\textends: extendsList,\n\n\t\t/** @type {Config} */\n\t\t...configObject\n\t} = config;\n\n\tconst extensionNames = new WeakMap();\n\n\t// replace strings with the actual configs\n\tconst objectExtends = extendsList.map(extendsElement => {\n\t\tif (typeof extendsElement === \"string\") {\n\t\t\tconst pluginConfig = findPluginConfig(config, extendsElement);\n\n\t\t\t// assign names\n\t\t\tif (Array.isArray(pluginConfig)) {\n\t\t\t\tpluginConfig.forEach((pluginConfigElement, index) => {\n\t\t\t\t\textensionNames.set(\n\t\t\t\t\t\tpluginConfigElement,\n\t\t\t\t\t\t`${extendsElement}[${index}]`,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\textensionNames.set(pluginConfig, extendsElement);\n\t\t\t}\n\n\t\t\treturn pluginConfig;\n\t\t}\n\n\t\treturn /** @type {Config} */ (extendsElement);\n\t});\n\n\tconst result = [];\n\n\tfor (const { indexPath, value: extendsElement } of flatTraverse(\n\t\tobjectExtends,\n\t)) {\n\t\tconst extension = /** @type {Config} */ (extendsElement);\n\n\t\tif (\"basePath\" in extension) {\n\t\t\tthrow new TypeError(\"'basePath' in `extends` is not allowed.\");\n\t\t}\n\n\t\tif (\"extends\" in extension) {\n\t\t\tthrow new TypeError(\"Nested 'extends' is not allowed.\");\n\t\t}\n\n\t\tconst baseConfigName = /** @type {string} */ (configNames.get(config));\n\t\tconst extensionName =\n\t\t\textensionNames.get(extendsElement) ??\n\t\t\tgetExtensionName(extendsElement, indexPath);\n\n\t\tresult.push(\n\t\t\textendConfig(\n\t\t\t\tconfigObject,\n\t\t\t\tbaseConfigName,\n\t\t\t\textension,\n\t\t\t\textensionName,\n\t\t\t),\n\t\t);\n\t}\n\n\t/*\n\t * If the base config object has only `ignores` and `extends`, then\n\t * removing `extends` turns it into a global ignores, which is not what\n\t * we want. So we need to check if the base config object is a global ignores\n\t * and if so, we don't add it to the array.\n\t *\n\t * (The other option would be to add a `files` entry, but that would result\n\t * in a config that didn't actually do anything because there are no\n\t * other keys in the config.)\n\t */\n\tif (!isGlobalIgnores(configObject)) {\n\t\tresult.push(configObject);\n\t}\n\n\treturn result.flat();\n}\n\n/**\n * Processes a list of config objects and arrays.\n * @param {ConfigWithExtends[]} configList The list of config objects and arrays.\n * @param {WeakMap<Config, string>} configNames The map of config objects to their names.\n * @return {Config[]} The flattened list of config objects.\n */\nfunction processConfigList(configList, configNames) {\n\treturn configList.flatMap(config => processExtends(config, configNames));\n}\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * Helper function to define a config array.\n * @param {ConfigWithExtendsArray} args The arguments to the function.\n * @returns {Config[]} The config array.\n * @throws {TypeError} If no arguments are provided or if an argument is not an object.\n */\nfunction defineConfig(...args) {\n\tconst configNames = new WeakMap();\n\tconst configs = [];\n\n\tif (args.length === 0) {\n\t\tthrow new TypeError(\"Expected one or more arguments.\");\n\t}\n\n\t// first flatten the list of configs and get the names\n\tfor (const { indexPath, value } of flatTraverse(args)) {\n\t\tif (typeof value !== \"object\" || value === null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Expected an object but received ${String(value)}.`,\n\t\t\t);\n\t\t}\n\n\t\tconst config = /** @type {ConfigWithExtends} */ (value);\n\n\t\t// save config name for easy reference later\n\t\tconfigNames.set(config, getConfigName(config, indexPath));\n\t\tconfigs.push(config);\n\t}\n\n\treturn processConfigList(configs, configNames);\n}\n\n/**\n * @fileoverview Global ignores helper function.\n * @author Nicholas C. Zakas\n */\n\n//-----------------------------------------------------------------------------\n// Type Definitions\n//-----------------------------------------------------------------------------\n\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\nlet globalIgnoreCount = 0;\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * Creates a global ignores config with the given patterns.\n * @param {string[]} ignorePatterns The ignore patterns.\n * @param {string} [name] The name of the global ignores config.\n * @returns {Config} The global ignores config.\n * @throws {TypeError} If ignorePatterns is not an array or if it is empty.\n */\nfunction globalIgnores(ignorePatterns, name) {\n\tif (!Array.isArray(ignorePatterns)) {\n\t\tthrow new TypeError(\"ignorePatterns must be an array\");\n\t}\n\n\tif (ignorePatterns.length === 0) {\n\t\tthrow new TypeError(\"ignorePatterns must contain at least one pattern\");\n\t}\n\n\tconst id = globalIgnoreCount++;\n\n\treturn {\n\t\tname: name || `globalIgnores ${id}`,\n\t\tignores: ignorePatterns,\n\t};\n}\n\nexports.defineConfig = defineConfig;\nexports.globalIgnores = globalIgnores;\n","/**\n * @fileoverview exports for config helpers\n * @author Nicholas C. Zakas\n */\n\n\"use strict\";\nconst { defineConfig, globalIgnores } = require(\"@eslint/config-helpers\");\n\nmodule.exports = {\n\tdefineConfig,\n\tglobalIgnores,\n};\n","// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport * as mdx from \"eslint-plugin-mdx\"\nimport reactPlugin from \"eslint-plugin-react\"\nimport {defineConfig, type Config} from \"eslint/config\"\n\nconst recommended: Config[] = defineConfig({\n ...mdx.flat,\n plugins: {\n ...mdx.flat.plugins,\n react: reactPlugin,\n },\n rules: {\n ...mdx.flat.rules,\n \"mdx/remark\": \"error\",\n \"no-unused-expressions\": \"off\",\n },\n})\n\nexport default recommended\n","// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport type {Config} from \"eslint/config\"\n\nimport recommended from \"./recommended.js\"\n\nconst mdxConfig: {configs: Record<\"recommended\", Config[]>} = {\n configs: {\n recommended,\n },\n}\n\nexport default mdxConfig\n"],"x_google_ignoreList":[0,1],"mappings":"sKA2BA,IAAM,EAAe,CACpB,MACA,UACA,UACA,i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,GAAU,WAAY,EAChC,MAAU,UACT,mCAAmC,OAAO,EAAM,CAAC,GACjD,CAGF,IAAM,EAA2C,EAGjD,EAAY,IAAI,EAAQ,cAAc,EAAQ,EAAU,CAAC,CACzD,EAAQ,KAAK,EAAO,CAGrB,OAAO,kBAAkB,EAAS,EAAY,CAiB/C,IAAI,EAAoB,EAaxB,SAAS,cAAc,EAAgB,EAAM,CAC5C,GAAI,CAAC,MAAM,QAAQ,EAAe,CACjC,MAAU,UAAU,kCAAkC,CAGvD,GAAI,EAAe,SAAW,EAC7B,MAAU,UAAU,mDAAmD,CAGxE,IAAM,EAAK,IAEX,MAAO,CACN,KAAM,GAAQ,iBAAiB,IAC/B,QAAS,EACT,CAGF,EAAQ,aAAe,aACvB,EAAQ,cAAgB,iBGpkBlB,EAAwD,CAC5D,QAAS,CACP,aDFE,yBDDN,GAAM,CAAE,eAAc,iBAAA,GAAA,CAEtB,EAAO,QAAU,CAChB,eACA,gBACA,MCJK,cAAqC,CACzC,GAAG,EAAI,KACP,QAAS,CACP,GAAG,EAAI,KAAK,QACZ,MAAO,EACR,CACD,MAAO,CACL,GAAG,EAAI,KAAK,MACZ,aAAc,QACd,wBAAyB,MAC1B,CACF,CAAC,CCRC,CACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../node_modules/.pnpm/@eslint+config-helpers@0.7.0/node_modules/@eslint/config-helpers/dist/cjs/index.cjs","../../../../node_modules/.pnpm/eslint@10.8.1_jiti@2.7.0/node_modules/eslint/lib/config-api.js","../src/recommended.ts","../src/index.ts"],"sourcesContent":["'use strict';\n\nvar fs = require('node:fs');\nvar path = require('node:path');\n\n/**\n * @fileoverview defineConfig helper\n * @author Nicholas C. Zakas\n */\n\n//-----------------------------------------------------------------------------\n// Type Definitions\n//-----------------------------------------------------------------------------\n\n/** @import * as $eslintcore from \"@eslint/core\"; */\n/** @typedef {$eslintcore.ConfigObject} ConfigObject */\n/** @typedef {$eslintcore.LegacyConfigObject} LegacyConfig */\n/** @typedef {$eslintcore.Plugin} Plugin */\n/** @typedef {$eslintcore.RuleConfig} RuleConfig */\n/** @import * as $typests from \"./types.ts\"; */\n/** @typedef {$typests.Config} Config */\n/** @typedef {$typests.ExtendsElement} ExtendsElement */\n/** @typedef {$typests.ExtensionConfigObject} ExtensionConfigObject */\n/** @typedef {$typests.SimpleExtendsElement} SimpleExtendsElement */\n/** @typedef {$typests.ConfigWithExtends} ConfigWithExtends */\n/** @typedef {$typests.InfiniteArray<ConfigObject>} InfiniteConfigArray */\n/** @typedef {$typests.ConfigWithExtendsArray} ConfigWithExtendsArray */\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\nconst eslintrcKeys = [\n\t\"env\",\n\t\"extends\",\n\t\"globals\",\n\t\"ignorePatterns\",\n\t\"noInlineConfig\",\n\t\"overrides\",\n\t\"parser\",\n\t\"parserOptions\",\n\t\"reportUnusedDisableDirectives\",\n\t\"root\",\n];\n\nconst allowedGlobalIgnoreKeys = new Set([\"basePath\", \"ignores\", \"name\"]);\n\n/**\n * Gets the name of a config object.\n * @param {ConfigObject} config The config object.\n * @param {string} indexPath The index path of the config object.\n * @return {string} The name of the config object.\n */\nfunction getConfigName(config, indexPath) {\n\tif (config.name) {\n\t\treturn config.name;\n\t}\n\n\treturn `UserConfig${indexPath}`;\n}\n\n/**\n * Gets the name of an extension.\n * @param {SimpleExtendsElement} extension The extension.\n * @param {string} indexPath The index of the extension.\n * @return {string} The name of the extension.\n */\nfunction getExtensionName(extension, indexPath) {\n\tif (typeof extension === \"string\") {\n\t\treturn extension;\n\t}\n\n\tif (extension.name) {\n\t\treturn extension.name;\n\t}\n\n\treturn `ExtendedConfig${indexPath}`;\n}\n\n/**\n * Determines if a config object is a legacy config.\n * @param {ConfigObject|LegacyConfig} config The config object to check.\n * @return {config is LegacyConfig} `true` if the config object is a legacy config.\n */\nfunction isLegacyConfig(config) {\n\t// eslintrc's plugins must be an array; while flat config's must be an object.\n\tif (Array.isArray(config.plugins)) {\n\t\treturn true;\n\t}\n\n\tfor (const key of eslintrcKeys) {\n\t\tif (key in config) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Determines if a config object is a global ignores config.\n * @param {ConfigObject} config The config object to check.\n * @return {boolean} `true` if the config object is a global ignores config.\n */\nfunction isGlobalIgnores(config) {\n\treturn Object.keys(config).every(key => allowedGlobalIgnoreKeys.has(key));\n}\n\n/**\n * Parses a plugin member ID (rule, processor, etc.) and returns\n * the namespace and member name.\n * @param {string} id The ID to parse.\n * @returns {{namespace:string, name:string}} The namespace and member name.\n */\nfunction getPluginMember(id) {\n\tconst firstSlashIndex = id.indexOf(\"/\");\n\n\tif (firstSlashIndex === -1) {\n\t\treturn { namespace: \"\", name: id };\n\t}\n\n\tlet namespace = id.slice(0, firstSlashIndex);\n\n\t/*\n\t * Special cases:\n\t * 1. The namespace is `@`, that means it's referring to the\n\t * core plugin so `@` is the full namespace.\n\t * 2. The namespace starts with `@`, that means it's referring to\n\t * an npm scoped package. That means the namespace is the scope\n\t * and the package name (i.e., `@eslint/core`).\n\t */\n\tif (namespace[0] === \"@\" && namespace !== \"@\") {\n\t\tconst secondSlashIndex = id.indexOf(\"/\", firstSlashIndex + 1);\n\t\tif (secondSlashIndex !== -1) {\n\t\t\tnamespace = id.slice(0, secondSlashIndex);\n\t\t\treturn { namespace, name: id.slice(secondSlashIndex + 1) };\n\t\t}\n\t}\n\n\tconst name = id.slice(firstSlashIndex + 1);\n\n\treturn { namespace, name };\n}\n\n/**\n * Normalizes the plugin config by replacing the namespace with the plugin namespace.\n * @param {string} userNamespace The namespace of the plugin.\n * @param {Plugin} plugin The plugin config object.\n * @param {ConfigObject} config The config object to normalize.\n * @return {ConfigObject} The normalized config object.\n */\nfunction normalizePluginConfig(userNamespace, plugin, config) {\n\tconst pluginNamespace = plugin.meta?.namespace;\n\n\t// don't do anything if the plugin doesn't have a namespace or rules\n\tif (\n\t\t!pluginNamespace ||\n\t\tpluginNamespace === userNamespace ||\n\t\t(!config.rules && !config.processor && !config.language)\n\t) {\n\t\treturn config;\n\t}\n\n\tconst result = { ...config };\n\n\t// update the rules\n\tif (result.rules) {\n\t\tconst ruleIds = Object.keys(result.rules);\n\n\t\t/** @type {Record<string,RuleConfig|undefined>} */\n\t\tconst newRules = {};\n\n\t\tfor (let i = 0; i < ruleIds.length; i++) {\n\t\t\tconst ruleId = ruleIds[i];\n\t\t\tconst { namespace: ruleNamespace, name: ruleName } =\n\t\t\t\tgetPluginMember(ruleId);\n\n\t\t\tif (ruleNamespace === pluginNamespace) {\n\t\t\t\tnewRules[`${userNamespace}/${ruleName}`] = result.rules[ruleId];\n\t\t\t} else {\n\t\t\t\tnewRules[ruleId] = result.rules[ruleId];\n\t\t\t}\n\t\t}\n\n\t\tresult.rules = newRules;\n\t}\n\n\t// update the processor\n\n\tif (typeof result.processor === \"string\") {\n\t\tconst { namespace: processorNamespace, name: processorName } =\n\t\t\tgetPluginMember(result.processor);\n\n\t\tif (processorNamespace) {\n\t\t\tif (processorNamespace === pluginNamespace) {\n\t\t\t\tresult.processor = `${userNamespace}/${processorName}`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// update the language\n\tif (typeof result.language === \"string\") {\n\t\tconst { namespace: languageNamespace, name: languageName } =\n\t\t\tgetPluginMember(result.language);\n\n\t\tif (languageNamespace === pluginNamespace) {\n\t\t\tresult.language = `${userNamespace}/${languageName}`;\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Deeply normalizes a plugin config, traversing recursively into an arrays.\n * @param {string} userPluginNamespace The namespace of the plugin.\n * @param {Plugin} plugin The plugin object.\n * @param {ConfigObject|LegacyConfig|(ConfigObject|LegacyConfig)[]} pluginConfig The plugin config to normalize.\n * @param {string} pluginConfigName The name of the plugin config.\n * @return {InfiniteConfigArray} The normalized plugin config.\n * @throws {TypeError} If the plugin config is a legacy config.\n */\nfunction deepNormalizePluginConfig(\n\tuserPluginNamespace,\n\tplugin,\n\tpluginConfig,\n\tpluginConfigName,\n) {\n\t// if it's an array then it's definitely a new config\n\tif (Array.isArray(pluginConfig)) {\n\t\treturn pluginConfig.map(pluginSubConfig =>\n\t\t\tdeepNormalizePluginConfig(\n\t\t\t\tuserPluginNamespace,\n\t\t\t\tplugin,\n\t\t\t\tpluginSubConfig,\n\t\t\t\tpluginConfigName,\n\t\t\t),\n\t\t);\n\t}\n\n\t// if it's a legacy config, throw an error\n\tif (isLegacyConfig(pluginConfig)) {\n\t\tthrow new TypeError(\n\t\t\t`Plugin config \"${pluginConfigName}\" is an eslintrc config and cannot be used in this context.`,\n\t\t);\n\t}\n\n\treturn normalizePluginConfig(userPluginNamespace, plugin, pluginConfig);\n}\n\n/**\n * Finds a plugin config by name in the given config.\n * @param {ConfigObject} config The config object.\n * @param {string} pluginConfigName The name of the plugin config.\n * @return {InfiniteConfigArray} The plugin config.\n * @throws {TypeError} If the plugin config is not found or is a legacy config.\n */\nfunction findPluginConfig(config, pluginConfigName) {\n\tconst { namespace: userPluginNamespace, name: configName } =\n\t\tgetPluginMember(pluginConfigName);\n\tconst plugin = config.plugins?.[userPluginNamespace];\n\n\tif (!plugin) {\n\t\tthrow new TypeError(`Plugin \"${userPluginNamespace}\" not found.`);\n\t}\n\n\tconst directConfig = plugin.configs?.[configName];\n\n\t// Prefer direct config, but fall back to flat config if available\n\tif (directConfig) {\n\t\t// Arrays are always flat configs, and non-legacy configs can be used directly\n\t\tif (Array.isArray(directConfig) || !isLegacyConfig(directConfig)) {\n\t\t\treturn deepNormalizePluginConfig(\n\t\t\t\tuserPluginNamespace,\n\t\t\t\tplugin,\n\t\t\t\tdirectConfig,\n\t\t\t\tpluginConfigName,\n\t\t\t);\n\t\t}\n\t}\n\n\t// If it's a legacy config, or the config does not exist => look for the flat version\n\tconst flatConfig = plugin.configs?.[`flat/${configName}`];\n\tif (\n\t\tflatConfig &&\n\t\t(Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))\n\t) {\n\t\treturn deepNormalizePluginConfig(\n\t\t\tuserPluginNamespace,\n\t\t\tplugin,\n\t\t\tflatConfig,\n\t\t\tpluginConfigName,\n\t\t);\n\t}\n\n\t// If we get here, then the config was either not found or is a legacy config\n\tconst message =\n\t\tdirectConfig || flatConfig\n\t\t\t? `Plugin config \"${configName}\" in plugin \"${userPluginNamespace}\" is an eslintrc config and cannot be used in this context.`\n\t\t\t: `Plugin config \"${configName}\" not found in plugin \"${userPluginNamespace}\".`;\n\tthrow new TypeError(message);\n}\n\n/**\n * Flattens an array while keeping track of the index path.\n * @param {any[]} configList The array to traverse.\n * @param {string} indexPath The index path of the value in a multidimensional array.\n * @return {IterableIterator<{indexPath:string, value:any}>} The flattened list of values.\n */\nfunction* flatTraverse(configList, indexPath = \"\") {\n\tfor (let i = 0; i < configList.length; i++) {\n\t\tconst newIndexPath = indexPath ? `${indexPath}[${i}]` : `[${i}]`;\n\n\t\t// if it's an array then traverse it as well\n\t\tif (Array.isArray(configList[i])) {\n\t\t\tyield* flatTraverse(configList[i], newIndexPath);\n\t\t\tcontinue;\n\t\t}\n\n\t\tyield { indexPath: newIndexPath, value: configList[i] };\n\t}\n}\n\n/**\n * Extends a list of config files by creating every combination of base and extension files.\n * @param {(string|string[])[]} [baseFiles] The base files.\n * @param {(string|string[])[]} [extensionFiles] The extension files.\n * @return {(string|string[])[]} The extended files.\n */\nfunction extendConfigFiles(baseFiles = [], extensionFiles = []) {\n\tif (!extensionFiles.length) {\n\t\treturn baseFiles.concat();\n\t}\n\n\tif (!baseFiles.length) {\n\t\treturn extensionFiles.concat();\n\t}\n\n\t/** @type {(string|string[])[]} */\n\tconst result = [];\n\n\tfor (const baseFile of baseFiles) {\n\t\tfor (const extensionFile of extensionFiles) {\n\t\t\t/*\n\t\t\t * Each entry can be a string or array of strings. The end result\n\t\t\t * needs to be an array of strings, so we need to be sure to include\n\t\t\t * all of the items when there's an array.\n\t\t\t */\n\n\t\t\tconst entry = [];\n\n\t\t\tif (Array.isArray(baseFile)) {\n\t\t\t\tentry.push(...baseFile);\n\t\t\t} else {\n\t\t\t\tentry.push(baseFile);\n\t\t\t}\n\n\t\t\tif (Array.isArray(extensionFile)) {\n\t\t\t\tentry.push(...extensionFile);\n\t\t\t} else {\n\t\t\t\tentry.push(extensionFile);\n\t\t\t}\n\n\t\t\tresult.push(entry);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Extends a config object with another config object.\n * @param {ConfigObject} baseConfig The base config object.\n * @param {string} baseConfigName The name of the base config object.\n * @param {ConfigObject} extension The extension config object.\n * @param {string} extensionName The index of the extension config object.\n * @return {ConfigObject} The extended config object.\n */\nfunction extendConfig(baseConfig, baseConfigName, extension, extensionName) {\n\tconst result = { ...extension };\n\n\t// for global ignores there is no further work to be done, we just keep everything\n\tif (!isGlobalIgnores(extension)) {\n\t\t// for files we need to create every combination of base and extension files\n\t\tif (baseConfig.files) {\n\t\t\tresult.files = extendConfigFiles(baseConfig.files, extension.files);\n\t\t}\n\n\t\t// for ignores we just concatenation the extension ignores onto the base ignores\n\t\tif (baseConfig.ignores) {\n\t\t\tresult.ignores = baseConfig.ignores.concat(extension.ignores ?? []);\n\t\t}\n\t}\n\n\tresult.name = `${baseConfigName} > ${extensionName}`;\n\n\tif (baseConfig.basePath) {\n\t\tresult.basePath = baseConfig.basePath;\n\t}\n\n\treturn result;\n}\n\n/**\n * Processes a list of extends elements.\n * @param {ConfigWithExtends} config The config object.\n * @param {WeakMap<ConfigObject, string>} configNames The map of config objects to their names.\n * @return {ConfigObject[]} The flattened list of config objects.\n * @throws {TypeError} If the `extends` property is not an array or if nested `extends` is found.\n */\nfunction processExtends(config, configNames) {\n\tif (!config.extends) {\n\t\treturn [config];\n\t}\n\n\tif (!Array.isArray(config.extends)) {\n\t\tthrow new TypeError(\"The `extends` property must be an array.\");\n\t}\n\n\tconst {\n\t\t/** @type {ConfigObject[]} */\n\t\textends: extendsList,\n\n\t\t/** @type {ConfigObject} */\n\t\t...configObject\n\t} = config;\n\n\tconst extensionNames = new WeakMap();\n\n\t// replace strings with the actual configs\n\tconst objectExtends = extendsList.map(extendsElement => {\n\t\tif (typeof extendsElement === \"string\") {\n\t\t\tconst pluginConfig = findPluginConfig(config, extendsElement);\n\n\t\t\t// assign names\n\t\t\tif (Array.isArray(pluginConfig)) {\n\t\t\t\tpluginConfig.forEach((pluginConfigElement, index) => {\n\t\t\t\t\textensionNames.set(\n\t\t\t\t\t\tpluginConfigElement,\n\t\t\t\t\t\t`${extendsElement}[${index}]`,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\textensionNames.set(pluginConfig, extendsElement);\n\t\t\t}\n\n\t\t\treturn pluginConfig;\n\t\t}\n\n\t\treturn /** @type {ConfigObject} */ (extendsElement);\n\t});\n\n\tconst result = [];\n\n\tfor (const { indexPath, value: extendsElement } of flatTraverse(\n\t\tobjectExtends,\n\t)) {\n\t\tconst extension = /** @type {ConfigObject} */ (extendsElement);\n\n\t\tif (\"basePath\" in extension) {\n\t\t\tthrow new TypeError(\"'basePath' in `extends` is not allowed.\");\n\t\t}\n\n\t\tif (\"extends\" in extension) {\n\t\t\tthrow new TypeError(\"Nested 'extends' is not allowed.\");\n\t\t}\n\n\t\tconst baseConfigName = /** @type {string} */ (configNames.get(config));\n\t\tconst extensionName =\n\t\t\textensionNames.get(extendsElement) ??\n\t\t\tgetExtensionName(extendsElement, indexPath);\n\n\t\tresult.push(\n\t\t\textendConfig(\n\t\t\t\tconfigObject,\n\t\t\t\tbaseConfigName,\n\t\t\t\textension,\n\t\t\t\textensionName,\n\t\t\t),\n\t\t);\n\t}\n\n\t/*\n\t * If the base config object has only `ignores` and `extends`, then\n\t * removing `extends` turns it into a global ignores, which is not what\n\t * we want. So we need to check if the base config object is a global ignores\n\t * and if so, we don't add it to the array.\n\t *\n\t * (The other option would be to add a `files` entry, but that would result\n\t * in a config that didn't actually do anything because there are no\n\t * other keys in the config.)\n\t */\n\tif (!isGlobalIgnores(configObject)) {\n\t\tresult.push(configObject);\n\t}\n\n\treturn result.flat();\n}\n\n/**\n * Processes a list of config objects and arrays.\n * @param {ConfigWithExtends[]} configList The list of config objects and arrays.\n * @param {WeakMap<ConfigObject, string>} configNames The map of config objects to their names.\n * @return {ConfigObject[]} The flattened list of config objects.\n */\nfunction processConfigList(configList, configNames) {\n\treturn configList.flatMap(config => processExtends(config, configNames));\n}\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * Helper function to define a config array.\n * @param {ConfigWithExtendsArray} args The arguments to the function.\n * @returns {ConfigObject[]} The config array.\n * @throws {TypeError} If no arguments are provided or if an argument is not an object.\n */\nfunction defineConfig(...args) {\n\tconst configNames = new WeakMap();\n\tconst configs = [];\n\n\tif (args.length === 0) {\n\t\tthrow new TypeError(\"Expected one or more arguments.\");\n\t}\n\n\t// first flatten the list of configs and get the names\n\tfor (const { indexPath, value } of flatTraverse(args)) {\n\t\tif (typeof value !== \"object\" || value === null) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Expected an object but received ${String(value)}.`,\n\t\t\t);\n\t\t}\n\n\t\tconst config = /** @type {ConfigWithExtends} */ (value);\n\n\t\t// save config name for easy reference later\n\t\tconfigNames.set(config, getConfigName(config, indexPath));\n\t\tconfigs.push(config);\n\t}\n\n\treturn processConfigList(configs, configNames);\n}\n\n/**\n * @fileoverview Global ignores helper function.\n * @author Nicholas C. Zakas\n */\n\n//-----------------------------------------------------------------------------\n// Type Definitions\n//-----------------------------------------------------------------------------\n\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\nlet globalIgnoreCount = 0;\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * Creates a global ignores config with the given patterns.\n * @param {string[]} ignorePatterns The ignore patterns.\n * @param {string} [name] The name of the global ignores config.\n * @returns {ConfigObject} The global ignores config.\n * @throws {TypeError} If ignorePatterns is not an array or if it is empty.\n */\nfunction globalIgnores(ignorePatterns, name) {\n\tif (!Array.isArray(ignorePatterns)) {\n\t\tthrow new TypeError(\"ignorePatterns must be an array\");\n\t}\n\n\tif (ignorePatterns.length === 0) {\n\t\tthrow new TypeError(\"ignorePatterns must contain at least one pattern\");\n\t}\n\n\tconst id = globalIgnoreCount++;\n\n\treturn {\n\t\tname: name || `globalIgnores ${id}`,\n\t\tignores: ignorePatterns,\n\t};\n}\n\n/**\n * @fileoverview Ignore file utilities for the config-helpers package.\n * This file was forked from the source code for the compat package.\n *\n * @author Nicholas C. Zakas\n * @author Kirk Waiblinger\n */\n\n\n//-----------------------------------------------------------------------------\n// Types\n//-----------------------------------------------------------------------------\n\n\n/**\n * @typedef {object} IncludeIgnoreFileOptionsObject\n * @property {boolean} [gitignoreResolution] Whether to interpret the contents of an ignore file relative to the config file or the ignore file.\n * - gitignoreResolution: false (default): Interprets ignore patterns relative to the config file\n * - gitignoreResolution: true: Interprets the ignore patterns in a file relative to the ignore file\n * @property {string} [name] The name to give the output config object(s).\n */\n\n/**\n * Options for `includeIgnoreFile()`. May be provided as an object or, for\n * legacy compatibility with `@eslint/compat`, as a string which is treated as\n * the `name` option.\n * @typedef {IncludeIgnoreFileOptionsObject | string} IncludeIgnoreFileOptions\n */\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * Converts an ESLint ignore pattern to a minimatch pattern.\n * @param {string} pattern The .eslintignore or .gitignore pattern to convert.\n * @returns {string} The converted pattern.\n */\nfunction convertIgnorePatternToMinimatch(pattern) {\n\tconst isNegated = pattern.startsWith(\"!\");\n\tconst negatedPrefix = isNegated ? \"!\" : \"\";\n\tconst patternToTest = (isNegated ? pattern.slice(1) : pattern).trimEnd();\n\n\t// special cases\n\tif ([\"\", \"**\", \"/**\", \"**/\"].includes(patternToTest)) {\n\t\treturn `${negatedPrefix}${patternToTest}`;\n\t}\n\n\tconst firstIndexOfSlash = patternToTest.indexOf(\"/\");\n\n\tconst matchEverywherePrefix =\n\t\tfirstIndexOfSlash < 0 || firstIndexOfSlash === patternToTest.length - 1\n\t\t\t? \"**/\"\n\t\t\t: \"\";\n\n\tconst patternWithoutLeadingSlash =\n\t\tfirstIndexOfSlash === 0 ? patternToTest.slice(1) : patternToTest;\n\n\t/*\n\t * Escape `{` and `(` because in gitignore patterns they are just\n\t * literal characters without any specific syntactic meaning,\n\t * while in minimatch patterns they can form brace expansion or extglob syntax.\n\t *\n\t * For example, gitignore pattern `src/{a,b}.js` ignores file `src/{a,b}.js`.\n\t * But, the same minimatch pattern `src/{a,b}.js` ignores files `src/a.js` and `src/b.js`.\n\t * Minimatch pattern `src/\\{a,b}.js` is equivalent to gitignore pattern `src/{a,b}.js`.\n\t */\n\tconst escapedPatternWithoutLeadingSlash =\n\t\tpatternWithoutLeadingSlash.replaceAll(\n\t\t\t// eslint-disable-next-line regexp/no-empty-lookarounds-assertion -- False positive\n\t\t\t/(?=((?:\\\\.|[^{(])*))\\1([{(])/guy,\n\t\t\t\"$1\\\\$2\",\n\t\t);\n\n\tconst matchInsideSuffix = patternToTest.endsWith(\"/**\") ? \"/*\" : \"\";\n\n\treturn `${negatedPrefix}${matchEverywherePrefix}${escapedPatternWithoutLeadingSlash}${matchInsideSuffix}`;\n}\n\n/**\n * @param {string} ignoreFilePath\n * @returns {string[]}\n */\nfunction ignoreFilePathToPatterns(ignoreFilePath) {\n\tconst ignoreFile = fs.readFileSync(ignoreFilePath, \"utf8\");\n\tconst lines = ignoreFile.split(/\\r?\\n/u);\n\n\treturn lines\n\t\t.map(line => line.trim())\n\t\t.filter(line => line && !line.startsWith(\"#\"))\n\t\t.map(convertIgnorePatternToMinimatch);\n}\n\n/**\n * Helper to parse and validate the options to `includeIgnoreFile()`\n *\n * @param {string | { gitignoreResolution?: unknown, name?: unknown } | undefined} options\n * @returns {{ gitignoreResolution: boolean, name: string }}\n */\nfunction parseOptions(options) {\n\t// legacy compatibility with @eslint/compat's `includeIgnoreFile`\n\tif (typeof options === \"string\") {\n\t\treturn { gitignoreResolution: false, name: options };\n\t}\n\n\tconst optionsObject = options ?? {};\n\tif (typeof optionsObject !== \"object\" || Array.isArray(optionsObject)) {\n\t\tthrow new TypeError(\n\t\t\t\"The options argument to `includeIgnoreFile()` should be an object or a string.\",\n\t\t);\n\t}\n\n\tconst gitignoreResolution = optionsObject.gitignoreResolution ?? false;\n\tif (typeof gitignoreResolution !== \"boolean\") {\n\t\tthrow new TypeError(\n\t\t\t\"The `gitignoreResolution` option must be specified a boolean or omitted\",\n\t\t);\n\t}\n\n\tconst name = optionsObject.name ?? `Imported .gitignore patterns`;\n\tif (typeof name !== \"string\") {\n\t\tthrow new TypeError(\n\t\t\t\"The `name` option must be specified as a string or omitted.\",\n\t\t);\n\t}\n\n\treturn { gitignoreResolution, name };\n}\n\n/**\n * @overload\n *\n * Reads ignore files and returns objects with the ignore patterns.\n *\n * @param {string[]} ignoreFilePathArg The paths of ignore files to include.\n * @param {IncludeIgnoreFileOptions} [options]\n * @returns {ConfigObject[]}\n */\n\n/**\n * @overload\n *\n * Reads an ignore file and returns an object with the ignore patterns.\n *\n * @param {string} ignoreFilePathArg The path of the ignore file to include.\n * @param {IncludeIgnoreFileOptions} [options]\n * @returns {ConfigObject}\n */\n\n/**\n * @overload\n *\n * Reads an ignore file(s) and returns an object(s) with the ignore patterns.\n *\n * @param {string[] | string} ignoreFilePathArg The path(s) of the ignore file(s) to include.\n * @param {IncludeIgnoreFileOptions} [options]\n * @returns {ConfigObject[] | ConfigObject}\n */\n\n/**\n * Reads an ignore file(s) and returns an object(s) with the ignore patterns.\n *\n * @param {string[] | string} ignoreFilePathArg The path(s) of the ignore file(s) to include.\n * @param {IncludeIgnoreFileOptions} [options]\n * @returns {ConfigObject[] | ConfigObject}\n */\nfunction includeIgnoreFile(ignoreFilePathArg, options) {\n\tconst returnSingleObject = !Array.isArray(ignoreFilePathArg);\n\tconst ignoreFilePaths = Array.isArray(ignoreFilePathArg)\n\t\t? ignoreFilePathArg\n\t\t: [ignoreFilePathArg];\n\tfor (const ignorePath of ignoreFilePaths) {\n\t\tif (typeof ignorePath !== \"string\") {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"The first argument to `includeIgnoreFile()` should be a string or array of strings\",\n\t\t\t);\n\t\t}\n\t\tif (!path.isAbsolute(ignorePath)) {\n\t\t\tthrow new Error(\n\t\t\t\t`The ignore file location must be an absolute path. Received ${ignorePath}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst { gitignoreResolution, name } = parseOptions(options);\n\n\tif (returnSingleObject) {\n\t\treturn {\n\t\t\tname,\n\t\t\tignores: ignoreFilePathToPatterns(ignoreFilePathArg),\n\t\t\t...(gitignoreResolution\n\t\t\t\t? { basePath: path.dirname(ignoreFilePathArg) }\n\t\t\t\t: {}),\n\t\t};\n\t}\n\n\treturn ignoreFilePaths.map((ignoreFilePath, i) => ({\n\t\tname: `${name} (${i})`,\n\t\tignores: ignoreFilePathToPatterns(ignoreFilePath),\n\t\t...(gitignoreResolution\n\t\t\t? { basePath: path.dirname(ignoreFilePath) }\n\t\t\t: {}),\n\t}));\n}\n\nexports.convertIgnorePatternToMinimatch = convertIgnorePatternToMinimatch;\nexports.defineConfig = defineConfig;\nexports.globalIgnores = globalIgnores;\nexports.includeIgnoreFile = includeIgnoreFile;\n","/**\n * @fileoverview exports for config helpers\n * @author Nicholas C. Zakas\n */\n\n\"use strict\";\n\nconst {\n\tdefineConfig,\n\tglobalIgnores,\n\tincludeIgnoreFile,\n} = require(\"@eslint/config-helpers\");\n\nmodule.exports = {\n\tdefineConfig,\n\tglobalIgnores,\n\tincludeIgnoreFile,\n};\n","// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport * as mdx from \"eslint-plugin-mdx\"\nimport reactPlugin from \"eslint-plugin-react\"\nimport {defineConfig, type Config} from \"eslint/config\"\n\nconst recommended: Config[] = defineConfig({\n ...mdx.flat,\n plugins: {\n ...mdx.flat.plugins,\n react: reactPlugin,\n },\n rules: {\n ...mdx.flat.rules,\n \"mdx/remark\": \"error\",\n \"no-unused-expressions\": \"off\",\n },\n})\n\nexport default recommended\n","// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport type {Config} from \"eslint/config\"\n\nimport recommended from \"./recommended.js\"\n\nconst mdxConfig: {configs: Record<\"recommended\", Config[]>} = {\n configs: {\n recommended,\n },\n}\n\nexport default mdxConfig\n"],"x_google_ignoreList":[0,1],"mappings":"gPAEA,IAAI,EAAA,EAAa,SAAS,EACtB,EAAA,EAAe,WAAW,EA6BxB,EAAe,CACpB,MACA,UACA,UACA,iBACA,iBACA,YACA,SACA,gBACA,gCACA,MACD,EAEM,EAA0B,IAAI,IAAI,CAAC,WAAY,UAAW,MAAM,CAAC,EAQvE,SAAS,cAAc,EAAQ,EAAW,CAKzC,OAJI,EAAO,KACH,EAAO,KAGR,aAAa,GACrB,CAQA,SAAS,iBAAiB,EAAW,EAAW,CAS/C,OARI,OAAO,GAAc,SACjB,EAGJ,EAAU,KACN,EAAU,KAGX,iBAAiB,GACzB,CAOA,SAAS,eAAe,EAAQ,CAE/B,GAAI,MAAM,QAAQ,EAAO,OAAO,EAC/B,MAAO,GAGR,IAAK,IAAM,KAAO,EACjB,GAAI,KAAO,EACV,MAAO,GAIT,MAAO,EACR,CAOA,SAAS,gBAAgB,EAAQ,CAChC,OAAO,OAAO,KAAK,CAAM,CAAC,CAAC,MAAM,GAAO,EAAwB,IAAI,CAAG,CAAC,CACzE,CAQA,SAAS,gBAAgB,EAAI,CAC5B,IAAM,EAAkB,EAAG,QAAQ,GAAG,EAEtC,GAAI,IAAoB,GACvB,MAAO,CAAE,UAAW,GAAI,KAAM,CAAG,EAGlC,IAAI,EAAY,EAAG,MAAM,EAAG,CAAe,EAU3C,GAAI,EAAU,KAAO,KAAO,IAAc,IAAK,CAC9C,IAAM,EAAmB,EAAG,QAAQ,IAAK,EAAkB,CAAC,EAC5D,GAAI,IAAqB,GAEx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,CAAiB,EACnD,GAAI,EACD,CAAE,SAAU,EAAK,QAAQ,CAAiB,CAAE,EAC5C,CAAC,CACL,EAGM,EAAgB,KAAK,EAAgB,KAAO,CAClD,KAAM,GAAG,EAAK,IAAI,EAAE,GACpB,QAAS,yBAAyB,CAAc,EAChD,GAAI,EACD,CAAE,SAAU,EAAK,QAAQ,CAAc,CAAE,EACzC,CAAC,CACL,EAAE,CACH,CAEA,EAAQ,gCAAkC,gCAC1C,EAAQ,aAAe,aACvB,EAAQ,cAAgB,cACxB,EAAQ,kBAAoB,qBGtxBtB,EAAwD,CAC5D,QAAS,CACP,aDFE,yBDAN,GAAM,CACL,eACA,gBACA,qBAAA,EAAA,EAGD,EAAO,QAAU,CAChB,eACA,gBACA,mBACD,KCV8B,CAAA,CAAA,aAAA,CAAa,CACzC,GAAG,EAAI,KACP,QAAS,CACP,GAAG,EAAI,KAAK,QACZ,MAAO,CACT,EACA,MAAO,CACL,GAAG,EAAI,KAAK,MACZ,aAAc,QACd,wBAAyB,KAC3B,CACF,CCTI,CACF,CACF"}
@@ -0,0 +1,2 @@
1
+ import{dirname as e,isAbsolute as t,join as n,parse as r,resolve as i}from"node:path";import{readFile as a}from"node:fs/promises";import{pathToFileURL as o}from"node:url";import{format as s}from"oxfmt";import{parseConfigFileTextToJson as c}from"typescript";var l=[`.oxfmtrc.json`,`.oxfmtrc.jsonc`,`oxfmt.config.ts`],u=new Map;async function loadOxfmtConfig(t){let n=getAbsolutePath(t),i=r(n).ext?e(n):n,a=u.get(i);if(a)return a;let o=findOxfmtConfig(i).catch(e=>{throw u.delete(i),e});return u.set(i,o),o}async function formatOxfmt(e,t,n){try{let r=await s(e,t,n);return r.errors.length>0?null:removeFinalEol(r.code)}catch{return null}}function getAbsolutePath(e){return e?t(e)?e:i(process.cwd(),e):process.cwd()}function getErrorMessage(e){return e instanceof Error?e.message:String(e)}async function findOxfmtConfig(t){let r=t;for(;;){for(let e of l){let t=await readOxfmtConfig(n(r,e),e);if(t)return t}let t=e(r);if(t===r)return{};r=t}}async function readOxfmtConfig(e,t){if(t===`oxfmt.config.ts`)return readTypeScriptConfig(e);let n=await readOptionalFile(e);return n===null?null:t.endsWith(`.jsonc`)?validateConfig(e,readJsoncConfig(e,n)):validateConfig(e,JSON.parse(n))}async function readTypeScriptConfig(e){if(await readOptionalFile(e)===null)return null;let t=o(e);return t.searchParams.set(`cache`,Date.now().toString()),validateConfig(e,(await import(t.href)).default)}function readJsoncConfig(e,t){let n=c(e,t);if(n.error){let e=n.error.messageText;throw Error(typeof e==`string`?e:e.messageText)}return n.config}function validateConfig(e,t){if(!isPlainConfig(t))throw Error(`${e} must define an object`);return t}async function readOptionalFile(e){try{return await a(e,`utf8`)}catch(e){if(isMissingFileError(e))return null;throw e}}function removeFinalEol(e){return e.replace(/\r?\n$/u,``)}function isPlainConfig(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function isMissingFileError(e){if(typeof e!=`object`||!e||!(`code`in e))return!1;let{code:t}=e;return t===`ENOENT`||t===`ENOTDIR`}export{loadOxfmtConfig as i,getAbsolutePath as n,getErrorMessage as r,formatOxfmt as t};
2
+ //# sourceMappingURL=oxfmt-utils-CiCHCX0x.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"oxfmt-utils-CCT1qOHc.js","names":[],"sources":["../src/oxfmt-utils.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport {readFile} from \"node:fs/promises\"\nimport {dirname, isAbsolute, join, parse, resolve} from \"node:path\"\nimport {pathToFileURL} from \"node:url\"\nimport {format as formatCode, type FormatConfig} from \"oxfmt\"\nimport {parseConfigFileTextToJson} from \"typescript\"\n\nconst CONFIG_FILENAMES = [\".oxfmtrc.json\", \".oxfmtrc.jsonc\", \"oxfmt.config.ts\"]\nconst configCache = new Map<string, Promise<FormatConfig>>()\n\nexport async function loadOxfmtConfig(\n filePath: string | undefined,\n): Promise<FormatConfig> {\n const basePath = getAbsolutePath(filePath)\n const startDir = parse(basePath).ext ? dirname(basePath) : basePath\n const cachedConfig = configCache.get(startDir)\n\n if (cachedConfig) {\n return cachedConfig\n }\n\n const configPromise = findOxfmtConfig(startDir).catch((error: unknown) => {\n configCache.delete(startDir)\n throw error\n })\n\n configCache.set(startDir, configPromise)\n\n return configPromise\n}\n\nexport async function formatOxfmt(\n filePath: string,\n value: string,\n config: FormatConfig,\n): Promise<null | string> {\n try {\n const result = await formatCode(filePath, value, config)\n\n if (result.errors.length > 0) {\n return null\n }\n\n return removeFinalEol(result.code)\n } catch {\n return null\n }\n}\n\nexport function getAbsolutePath(filePath: string | undefined): string {\n if (!filePath) {\n return process.cwd()\n }\n\n return isAbsolute(filePath) ? filePath : resolve(process.cwd(), filePath)\n}\n\nexport function getErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message\n }\n\n return String(error)\n}\n\nasync function findOxfmtConfig(startDir: string): Promise<FormatConfig> {\n let currentDir = startDir\n\n while (true) {\n for (const configFilename of CONFIG_FILENAMES) {\n const configPath = join(currentDir, configFilename)\n const config = await readOxfmtConfig(configPath, configFilename)\n\n if (config) {\n return config\n }\n }\n\n const parentDir = dirname(currentDir)\n\n if (parentDir === currentDir) {\n return {}\n }\n\n currentDir = parentDir\n }\n}\n\nasync function readOxfmtConfig(\n configPath: string,\n configFilename: string,\n): Promise<FormatConfig | null> {\n if (configFilename === \"oxfmt.config.ts\") {\n return readTypeScriptConfig(configPath)\n }\n\n const source = await readOptionalFile(configPath)\n\n if (source === null) {\n return null\n }\n\n if (configFilename.endsWith(\".jsonc\")) {\n return validateConfig(configPath, readJsoncConfig(configPath, source))\n }\n\n return validateConfig(configPath, JSON.parse(source))\n}\n\nasync function readTypeScriptConfig(\n configPath: string,\n): Promise<FormatConfig | null> {\n const source = await readOptionalFile(configPath)\n\n if (source === null) {\n return null\n }\n\n const url = pathToFileURL(configPath)\n url.searchParams.set(\"cache\", Date.now().toString())\n\n const module = (await import(url.href)) as {default?: unknown}\n\n return validateConfig(configPath, module.default)\n}\n\nfunction readJsoncConfig(configPath: string, source: string): unknown {\n const result = parseConfigFileTextToJson(configPath, source)\n\n if (result.error) {\n throw new Error(String(result.error.messageText as string))\n }\n\n return result.config\n}\n\nfunction validateConfig(configPath: string, config: unknown): FormatConfig {\n if (!isPlainConfig(config)) {\n throw new Error(`${configPath} must define an object`)\n }\n\n return config as FormatConfig\n}\n\nasync function readOptionalFile(path: string): Promise<null | string> {\n try {\n return await readFile(path, \"utf8\")\n } catch (error) {\n if (isMissingFileError(error)) {\n return null\n }\n\n throw error\n }\n}\n\nfunction removeFinalEol(value: string): string {\n return value.replace(/\\r?\\n$/u, \"\")\n}\n\nfunction isPlainConfig(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nfunction isMissingFileError(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error)) {\n return false\n }\n\n const {code} = error\n\n return code === \"ENOENT\" || code === \"ENOTDIR\"\n}\n"],"mappings":"iQASA,IAAM,EAAmB,CAAC,gBAAiB,iBAAkB,kBAAkB,CACzE,EAAc,IAAI,IAExB,eAAsB,gBACpB,EACuB,CACvB,IAAM,EAAW,gBAAgB,EAAS,CACpC,EAAW,EAAM,EAAS,CAAC,IAAM,EAAQ,EAAS,CAAG,EACrD,EAAe,EAAY,IAAI,EAAS,CAE9C,GAAI,EACF,OAAO,EAGT,IAAM,EAAgB,gBAAgB,EAAS,CAAC,MAAO,GAAmB,CAExE,MADA,EAAY,OAAO,EAAS,CACtB,GACN,CAIF,OAFA,EAAY,IAAI,EAAU,EAAc,CAEjC,EAGT,eAAsB,YACpB,EACA,EACA,EACwB,CACxB,GAAI,CACF,IAAM,EAAS,MAAM,EAAW,EAAU,EAAO,EAAO,CAMxD,OAJI,EAAO,OAAO,OAAS,EAClB,KAGF,eAAe,EAAO,KAAK,MAC5B,CACN,OAAO,MAIX,SAAgB,gBAAgB,EAAsC,CA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AAO,MAAM,EAAS,EAAM,OAAO,OAC5B,EAAO,CACd,GAAI,mBAAmB,EAAM,CAC3B,OAAO,KAGT,MAAM,GAIV,SAAS,eAAe,EAAuB,CAC7C,OAAO,EAAM,QAAQ,UAAW,GAAG,CAGrC,SAAS,cAAc,EAAkD,CACvE,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,EAAM,CAG7E,SAAS,mBAAmB,EAAyB,CACnD,GAAI,OAAO,GAAU,WAAY,GAAkB,EAAE,SAAU,GAC7D,MAAO,GAGT,GAAM,CAAC,QAAQ,EAEf,OAAO,IAAS,UAAY,IAAS"}
1
+ {"version":3,"file":"oxfmt-utils-CiCHCX0x.js","names":[],"sources":["../src/oxfmt-utils.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport {readFile} from \"node:fs/promises\"\nimport {dirname, isAbsolute, join, parse, resolve} from \"node:path\"\nimport {pathToFileURL} from \"node:url\"\nimport {format as formatCode, type FormatConfig} from \"oxfmt\"\nimport {parseConfigFileTextToJson} from \"typescript\"\n\nconst CONFIG_FILENAMES = [\".oxfmtrc.json\", \".oxfmtrc.jsonc\", \"oxfmt.config.ts\"]\nconst configCache = new Map<string, Promise<FormatConfig>>()\n\nexport async function loadOxfmtConfig(\n filePath: string | undefined,\n): Promise<FormatConfig> {\n const basePath = getAbsolutePath(filePath)\n const startDir = parse(basePath).ext ? dirname(basePath) : basePath\n const cachedConfig = configCache.get(startDir)\n\n if (cachedConfig) {\n return cachedConfig\n }\n\n const configPromise = findOxfmtConfig(startDir).catch((error: unknown) => {\n configCache.delete(startDir)\n throw error\n })\n\n configCache.set(startDir, configPromise)\n\n return configPromise\n}\n\nexport async function formatOxfmt(\n filePath: string,\n value: string,\n config: FormatConfig,\n): Promise<null | string> {\n try {\n const result = await formatCode(filePath, value, config)\n\n if (result.errors.length > 0) {\n return null\n }\n\n return removeFinalEol(result.code)\n } catch {\n return null\n }\n}\n\nexport function getAbsolutePath(filePath: string | undefined): string {\n if (!filePath) {\n return process.cwd()\n }\n\n return isAbsolute(filePath) ? filePath : resolve(process.cwd(), filePath)\n}\n\nexport function getErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message\n }\n\n return String(error)\n}\n\nasync function findOxfmtConfig(startDir: string): Promise<FormatConfig> {\n let currentDir = startDir\n\n while (true) {\n for (const configFilename of CONFIG_FILENAMES) {\n const configPath = join(currentDir, configFilename)\n const config = await readOxfmtConfig(configPath, configFilename)\n\n if (config) {\n return config\n }\n }\n\n const parentDir = dirname(currentDir)\n\n if (parentDir === currentDir) {\n return {}\n }\n\n currentDir = parentDir\n }\n}\n\nasync function readOxfmtConfig(\n configPath: string,\n configFilename: string,\n): Promise<FormatConfig | null> {\n if (configFilename === \"oxfmt.config.ts\") {\n return readTypeScriptConfig(configPath)\n }\n\n const source = await readOptionalFile(configPath)\n\n if (source === null) {\n return null\n }\n\n if (configFilename.endsWith(\".jsonc\")) {\n return validateConfig(configPath, readJsoncConfig(configPath, source))\n }\n\n return validateConfig(configPath, JSON.parse(source))\n}\n\nasync function readTypeScriptConfig(\n configPath: string,\n): Promise<FormatConfig | null> {\n const source = await readOptionalFile(configPath)\n\n if (source === null) {\n return null\n }\n\n const url = pathToFileURL(configPath)\n url.searchParams.set(\"cache\", Date.now().toString())\n\n const module = (await import(url.href)) as {default?: unknown}\n\n return validateConfig(configPath, module.default)\n}\n\nfunction readJsoncConfig(configPath: string, source: string): unknown {\n const result = parseConfigFileTextToJson(configPath, source)\n\n if (result.error) {\n const message = result.error.messageText\n throw new Error(typeof message === \"string\" ? message : message.messageText)\n }\n\n return result.config\n}\n\nfunction validateConfig(configPath: string, config: unknown): FormatConfig {\n if (!isPlainConfig(config)) {\n throw new Error(`${configPath} must define an object`)\n }\n\n return config\n}\n\nasync function readOptionalFile(path: string): Promise<null | string> {\n try {\n return await readFile(path, \"utf8\")\n } catch (error) {\n if (isMissingFileError(error)) {\n return null\n }\n\n throw error\n }\n}\n\nfunction removeFinalEol(value: string): string {\n return value.replace(/\\r?\\n$/u, \"\")\n}\n\nfunction isPlainConfig(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nfunction isMissingFileError(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error)) {\n return false\n }\n\n const {code} = error\n\n return code === \"ENOENT\" || code === \"ENOTDIR\"\n}\n"],"mappings":"iQASA,IAAM,EAAmB,CAAC,gBAAiB,iBAAkB,iBAAiB,EACxE,EAAc,IAAI,IAExB,eAAsB,gBACpB,EACuB,CACvB,IAAM,EAAW,gBAAgB,CAAQ,EACnC,EAAW,EAAM,CAAQ,CAAC,CAAC,IAAM,EAAQ,CAAQ,EAAI,EACrD,EAAe,EAAY,IAAI,CAAQ,EAE7C,GAAI,EACF,OAAO,EAGT,IAAM,EAAgB,gBAAgB,CAAQ,CAAC,CAAC,MAAO,GAAmB,CAExE,MADA,EAAY,OAAO,CAAQ,EACrB,CACR,CAAC,EAID,OAFA,EAAY,IAAI,EAAU,CAAa,EAEhC,CACT,CAEA,eAAsB,YACpB,EACA,EACA,EACwB,CACxB,GAAI,CACF,IAAM,EAAS,MAAM,EAAW,EAAU,EAAO,CAAM,EAMvD,OAJI,EAAO,OAAO,OAAS,EAClB,KAGF,eAAe,EAAO,IAAI,CACnC,MAAQ,CACN,OAAO,IACT,CACF,CAEA,SAAgB,gBAAgB,EAAsC,CAKpE,OAJK,EAIE,EAAW,CAAQ,EAAI,EAAW,EAAQ,QAAQ,IAAI,EAAG,CAAQ,EAH/D,QAAQ,IAAI,CAIvB,CAEA,SAAgB,gBAAgB,EAAwB,CAKtD,OAJI,aAAiB,MACZ,EAAM,QAGR,OAAO,CAAK,CACrB,CAEA,eAAe,gBAAgB,EAAyC,CACtE,IAAI,EAAa,EAEjB,OAAa,CACX,IAAK,IAAM,KAAkB,EAAkB,CAE7C,IAAM,EAAS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SAAS,cAAc,EAAkD,CACvE,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CAEA,SAAS,mBAAmB,EAAyB,CACnD,GAAI,OAAO,GAAU,WAAY,GAAkB,EAAE,SAAU,GAC7D,MAAO,GAGT,GAAM,CAAC,QAAQ,EAEf,OAAO,IAAS,UAAY,IAAS,SACvC"}
@@ -1,3 +1,3 @@
1
- import{i as e,n as t,r as n,t as r}from"./oxfmt-utils-CCT1qOHc.js";var i=new Map([[`javascript`,`.js`],[`javascriptreact`,`.jsx`],[`js`,`.js`],[`jsx`,`.jsx`],[`ts`,`.ts`],[`tsx`,`.tsx`],[`typescript`,`.ts`],[`typescriptreact`,`.tsx`]]);function remarkLintCodeFormat(){return async function(t,i){let a;try{a=await e(i.path)}catch(e){i.message(`Unable to load oxfmt config: ${n(e)}`,{column:1,line:1},`remark-lint:code-format`);return}let o=[];visit(t,`code`,e=>{typeof e.value==`string`&&o.push(e)});for(let[e,t]of o.entries()){let n=getExtension(t.lang);if(!n)continue;let o=getBlockFilePath(i.path,e,n);if(isStandaloneJsxSnippet(n,t.value))continue;let s=await r(o,t.value,a);s!==null&&s!==t.value&&(i.message(`Format code block with oxfmt`,t,`remark-lint:code-format`),t.value=s)}}}function getBlockFilePath(e,n,r){return`${t(e)}.${n}${r}`}function getExtension(e){if(!e)return null;let[t=``]=e.trim().split(/\s+/u);return i.get(t.toLowerCase())??null}function isStandaloneJsxSnippet(e,t){return(e===`.jsx`||e===`.tsx`)&&/^<(?:>|\/?[A-Za-z][\w.:/-]*(?:[\s>/]|$))/u.test(trimLeadingComments(t))}function trimLeadingComments(e){let t=e.trimStart();for(;;){if(t.startsWith(`//`)){let e=t.indexOf(`
1
+ import{i as e,n as t,r as n,t as r}from"./oxfmt-utils-CiCHCX0x.js";var i=new Map([[`javascript`,`.js`],[`javascriptreact`,`.jsx`],[`js`,`.js`],[`jsx`,`.jsx`],[`ts`,`.ts`],[`tsx`,`.tsx`],[`typescript`,`.ts`],[`typescriptreact`,`.tsx`]]);function remarkLintCodeFormat(){return async function(t,i){let a;try{a=await e(i.path)}catch(e){i.message(`Unable to load oxfmt config: ${n(e)}`,{column:1,line:1},`remark-lint:code-format`);return}let o=[];visit(t,`code`,e=>{typeof e.value==`string`&&o.push(e)});for(let[e,t]of o.entries()){let n=getExtension(t.lang);if(!n)continue;let o=getBlockFilePath(i.path,e,n);if(isStandaloneJsxSnippet(n,t.value))continue;let s=await r(o,t.value,a);s!==null&&s!==t.value&&(i.message(`Format code block with oxfmt`,t,`remark-lint:code-format`),t.value=s)}}}function getBlockFilePath(e,n,r){return`${t(e)}.${n}${r}`}function getExtension(e){if(!e)return null;let[t=``]=e.trim().split(/\s+/u);return i.get(t.toLowerCase())??null}function isStandaloneJsxSnippet(e,t){return(e===`.jsx`||e===`.tsx`)&&/^<(?:>|\/?[A-Za-z][\w.:/-]*(?:[\s>/]|$))/u.test(trimLeadingComments(t))}function trimLeadingComments(e){let t=e.trimStart();for(;;){if(t.startsWith(`//`)){let e=t.indexOf(`
2
2
  `);if(e===-1)return``;t=t.slice(e+1).trimStart();continue}if(t.startsWith(`/*`)){let e=t.indexOf(`*/`);if(e===-1)return t;t=t.slice(e+2).trimStart();continue}return t}}function visit(e,t,n){if(e.type===t&&n(e),Array.isArray(e.children))for(let r of e.children)visit(r,t,n)}export{remarkLintCodeFormat as default};
3
3
  //# sourceMappingURL=remark-lint-code-format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"remark-lint-code-format.js","names":[],"sources":["../src/remark-lint-code-format.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport {\n formatOxfmt,\n getAbsolutePath,\n getErrorMessage,\n loadOxfmtConfig,\n} from \"./oxfmt-utils.js\"\nimport type {RemarkNode, RemarkTransformer} from \"./remark-types.js\"\n\ninterface CodeNode extends RemarkNode {\n lang?: string | null\n value: string\n}\n\nconst LANGUAGE_EXTENSIONS = new Map([\n [\"javascript\", \".js\"],\n [\"javascriptreact\", \".jsx\"],\n [\"js\", \".js\"],\n [\"jsx\", \".jsx\"],\n [\"ts\", \".ts\"],\n [\"tsx\", \".tsx\"],\n [\"typescript\", \".ts\"],\n [\"typescriptreact\", \".tsx\"],\n])\n\nexport default function remarkLintCodeFormat(): RemarkTransformer {\n return async function transform(tree, file) {\n let oxfmtConfig\n\n try {\n oxfmtConfig = await loadOxfmtConfig(file.path)\n } catch (error) {\n file.message(\n `Unable to load oxfmt config: ${getErrorMessage(error)}`,\n {column: 1, line: 1},\n \"remark-lint:code-format\",\n )\n return\n }\n\n const codeNodes: CodeNode[] = []\n visit<CodeNode>(tree, \"code\", (node) => {\n if (typeof node.value === \"string\") {\n codeNodes.push(node)\n }\n })\n\n for (const [index, node] of codeNodes.entries()) {\n const extension = getExtension(node.lang)\n\n if (!extension) {\n continue\n }\n\n const blockFilePath = getBlockFilePath(file.path, index, extension)\n\n if (isStandaloneJsxSnippet(extension, node.value)) {\n // Fenced TSX examples are not always complete TSX programs. Many docs\n // use them for JSX fragments, where Oxfmt would add ASI semicolons or\n // reflow comments if we wrapped the snippet. Real MDX JSX nodes are\n // handled separately by remark-lint-mdx-jsx-format.\n continue\n }\n\n const formatted = await formatOxfmt(\n blockFilePath,\n node.value,\n oxfmtConfig,\n )\n\n if (formatted === null) {\n continue\n }\n\n if (formatted !== node.value) {\n file.message(\n \"Format code block with oxfmt\",\n node,\n \"remark-lint:code-format\",\n )\n node.value = formatted\n }\n }\n }\n}\n\nfunction getBlockFilePath(\n filePath: string | undefined,\n index: number,\n extension: string,\n): string {\n return `${getAbsolutePath(filePath)}.${index}${extension}`\n}\n\nfunction getExtension(language: string | null | undefined): null | string {\n if (!language) {\n return null\n }\n\n const [name = \"\"] = language.trim().split(/\\s+/u)\n\n return LANGUAGE_EXTENSIONS.get(name.toLowerCase()) ?? null\n}\n\nfunction isStandaloneJsxSnippet(extension: string, value: string): boolean {\n return (\n (extension === \".jsx\" || extension === \".tsx\") &&\n /^<(?:>|\\/?[A-Za-z][\\w.:/-]*(?:[\\s>/]|$))/u.test(trimLeadingComments(value))\n )\n}\n\nfunction trimLeadingComments(value: string): string {\n let source = value.trimStart()\n\n while (true) {\n if (source.startsWith(\"//\")) {\n const nextLineIndex = source.indexOf(\"\\n\")\n\n if (nextLineIndex === -1) {\n return \"\"\n }\n\n source = source.slice(nextLineIndex + 1).trimStart()\n continue\n }\n\n if (source.startsWith(\"/*\")) {\n const commentEndIndex = source.indexOf(\"*/\")\n\n if (commentEndIndex === -1) {\n return source\n }\n\n source = source.slice(commentEndIndex + 2).trimStart()\n continue\n }\n\n return source\n }\n}\n\nfunction visit<T extends RemarkNode>(\n node: RemarkNode,\n type: string,\n callback: (node: T) => void,\n): void {\n if (node.type === type) {\n callback(node as T)\n }\n\n if (!Array.isArray(node.children)) {\n return\n }\n\n for (const child of node.children) {\n visit(child, type, callback)\n }\n}\n"],"mappings":"mEAgBA,IAAM,EAAsB,IAAI,IAAI,CAClC,CAAC,aAAc,MAAM,CACrB,CAAC,kBAAmB,OAAO,CAC3B,CAAC,KAAM,MAAM,CACb,CAAC,MAAO,OAAO,CACf,CAAC,KAAM,MAAM,CACb,CAAC,MAAO,OAAO,CACf,CAAC,aAAc,MAAM,CACrB,CAAC,kBAAmB,OAAO,CAC5B,CAAC,CAEF,SAAwB,sBAA0C,CAChE,OAAO,eAAyB,EAAM,EAAM,CAC1C,IAAI,EAEJ,GAAI,CACF,EAAc,MAAM,EAAgB,EAAK,KAAK,OACvC,EAAO,CACd,EAAK,QACH,gCAAgC,EAAgB,EAAM,GACtD,CAAC,OAAQ,EAAG,KAAM,EAAE,CACpB,0BACD,CACD,OAGF,IAAM,EAAwB,EAAE,CAChC,MAAgB,EAAM,OAAS,GAAS,CAClC,OAAO,EAAK,OAAU,UACxB,EAAU,KAAK,EAAK,EAEtB,CAEF,IAAK,GAAM,CAAC,EAAO,KAAS,EAAU,SAAS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
1
+ {"version":3,"file":"remark-lint-code-format.js","names":[],"sources":["../src/remark-lint-code-format.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport {\n formatOxfmt,\n getAbsolutePath,\n getErrorMessage,\n loadOxfmtConfig,\n} from \"./oxfmt-utils.js\"\nimport type {RemarkNode, RemarkTransformer} from \"./remark-types.js\"\n\ninterface CodeNode extends RemarkNode {\n lang?: string | null\n value: string\n}\n\nconst LANGUAGE_EXTENSIONS = new Map([\n [\"javascript\", \".js\"],\n [\"javascriptreact\", \".jsx\"],\n [\"js\", \".js\"],\n [\"jsx\", \".jsx\"],\n [\"ts\", \".ts\"],\n [\"tsx\", \".tsx\"],\n [\"typescript\", \".ts\"],\n [\"typescriptreact\", \".tsx\"],\n])\n\nexport default function remarkLintCodeFormat(): RemarkTransformer {\n return async function transform(tree, file) {\n let oxfmtConfig\n\n try {\n oxfmtConfig = await loadOxfmtConfig(file.path)\n } catch (error) {\n file.message(\n `Unable to load oxfmt config: ${getErrorMessage(error)}`,\n {column: 1, line: 1},\n \"remark-lint:code-format\",\n )\n return\n }\n\n const codeNodes: CodeNode[] = []\n visit<CodeNode>(tree, \"code\", (node) => {\n if (typeof node.value === \"string\") {\n codeNodes.push(node)\n }\n })\n\n for (const [index, node] of codeNodes.entries()) {\n const extension = getExtension(node.lang)\n\n if (!extension) {\n continue\n }\n\n const blockFilePath = getBlockFilePath(file.path, index, extension)\n\n if (isStandaloneJsxSnippet(extension, node.value)) {\n // Fenced TSX examples are not always complete TSX programs. Many docs\n // use them for JSX fragments, where Oxfmt would add ASI semicolons or\n // reflow comments if we wrapped the snippet. Real MDX JSX nodes are\n // handled separately by remark-lint-mdx-jsx-format.\n continue\n }\n\n const formatted = await formatOxfmt(\n blockFilePath,\n node.value,\n oxfmtConfig,\n )\n\n if (formatted === null) {\n continue\n }\n\n if (formatted !== node.value) {\n file.message(\n \"Format code block with oxfmt\",\n node,\n \"remark-lint:code-format\",\n )\n node.value = formatted\n }\n }\n }\n}\n\nfunction getBlockFilePath(\n filePath: string | undefined,\n index: number,\n extension: string,\n): string {\n return `${getAbsolutePath(filePath)}.${index}${extension}`\n}\n\nfunction getExtension(language: string | null | undefined): null | string {\n if (!language) {\n return null\n }\n\n const [name = \"\"] = language.trim().split(/\\s+/u)\n\n return LANGUAGE_EXTENSIONS.get(name.toLowerCase()) ?? null\n}\n\nfunction isStandaloneJsxSnippet(extension: string, value: string): boolean {\n return (\n (extension === \".jsx\" || extension === \".tsx\") &&\n /^<(?:>|\\/?[A-Za-z][\\w.:/-]*(?:[\\s>/]|$))/u.test(trimLeadingComments(value))\n )\n}\n\nfunction trimLeadingComments(value: string): string {\n let source = value.trimStart()\n\n while (true) {\n if (source.startsWith(\"//\")) {\n const nextLineIndex = source.indexOf(\"\\n\")\n\n if (nextLineIndex === -1) {\n return \"\"\n }\n\n source = source.slice(nextLineIndex + 1).trimStart()\n continue\n }\n\n if (source.startsWith(\"/*\")) {\n const commentEndIndex = source.indexOf(\"*/\")\n\n if (commentEndIndex === -1) {\n return source\n }\n\n source = source.slice(commentEndIndex + 2).trimStart()\n continue\n }\n\n return source\n }\n}\n\nfunction visit<T extends RemarkNode>(\n node: RemarkNode,\n type: string,\n callback: (node: T) => void,\n): void {\n if (node.type === type) {\n callback(node as T)\n }\n\n if (!Array.isArray(node.children)) {\n return\n }\n\n for (const child of node.children) {\n visit(child, type, callback)\n }\n}\n"],"mappings":"mEAgBA,IAAM,EAAsB,IAAI,IAAI,CAClC,CAAC,aAAc,KAAK,EACpB,CAAC,kBAAmB,MAAM,EAC1B,CAAC,KAAM,KAAK,EACZ,CAAC,MAAO,MAAM,EACd,CAAC,KAAM,KAAK,EACZ,CAAC,MAAO,MAAM,EACd,CAAC,aAAc,KAAK,EACpB,CAAC,kBAAmB,MAAM,CAC5B,CAAC,EAED,SAAwB,sBAA0C,CAChE,OAAO,eAAyB,EAAM,EAAM,CAC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M,EAAgB,CAAC,CAAC,CAAC,UAAU,EACnD,QACF,CAEA,GAAI,EAAO,WAAW,IAAI,EAAG,CAC3B,IAAM,EAAkB,EAAO,QAAQ,IAAI,EAE3C,GAAI,IAAoB,GACtB,OAAO,EAGT,EAAS,EAAO,MAAM,EAAkB,CAAC,CAAC,CAAC,UAAU,EACrD,QACF,CAEA,OAAO,CACT,CACF,CAEA,SAAS,MACP,EACA,EACA,EACM,CACN,GAAI,EAAK,OAAS,GAChB,EAAS,CAAS,EAGf,MAAM,QAAQ,EAAK,QAAQ,EAIhC,IAAK,IAAM,KAAS,EAAK,SACvB,MAAM,EAAO,EAAM,CAAQ,CAE/B"}
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,r as n,t as r}from"./oxfmt-utils-CCT1qOHc.js";function remarkLintMdxJsxFormat(){return async function(t,r){let i=getFileValue(r);if(!i)return;let a;try{a=await e(r.path)}catch(e){r.message(`Unable to load oxfmt config: ${n(e)}`,{column:1,line:1},`remark-lint:mdx-jsx-format`),await replaceMdxJsxFlowElements(t,i,r.path,null,r);return}await replaceMdxJsxFlowElements(t,i,r.path,a,r)}}async function replaceMdxJsxFlowElements(e,t,n,r,i){if(!Array.isArray(e.children))return;let a=[];for(let o of e.children){if(o.type===`mdxJsxFlowElement`){let e=getSourceSlice(t,o);if(e===null){a.push(o);continue}let s=r===null||hasChildren(o)?e:await formatMdxJsxBlock(n,e,r);s!==e&&i.message(`Format MDX JSX block`,o,`remark-lint:mdx-jsx-format`),a.push({type:`html`,value:s});continue}await replaceMdxJsxFlowElements(o,t,n,r,i),a.push(o)}e.children=a}async function formatMdxJsxBlock(e,t,n){let i=await r(getBlockFilePath(e),wrapMdxJsxBlock(t),n);return i===null?t:unwrapMdxJsxBlock(i)??t}function wrapMdxJsxBlock(e){return`const __mdx = (
1
+ import{i as e,n as t,r as n,t as r}from"./oxfmt-utils-CiCHCX0x.js";function remarkLintMdxJsxFormat(){return async function(t,r){let i=getFileValue(r);if(!i)return;let a;try{a=await e(r.path)}catch(e){r.message(`Unable to load oxfmt config: ${n(e)}`,{column:1,line:1},`remark-lint:mdx-jsx-format`),await replaceMdxJsxFlowElements(t,i,r.path,null,r);return}await replaceMdxJsxFlowElements(t,i,r.path,a,r)}}async function replaceMdxJsxFlowElements(e,t,n,r,i){if(!Array.isArray(e.children))return;let a=[];for(let o of e.children){if(o.type===`mdxJsxFlowElement`){let e=getSourceSlice(t,o);if(e===null){a.push(o);continue}let s=r===null||hasChildren(o)?e:await formatMdxJsxBlock(n,e,r);s!==e&&i.message(`Format MDX JSX block`,o,`remark-lint:mdx-jsx-format`),a.push({type:`html`,value:s});continue}await replaceMdxJsxFlowElements(o,t,n,r,i),a.push(o)}e.children=a}async function formatMdxJsxBlock(e,t,n){let i=await r(getBlockFilePath(e),wrapMdxJsxBlock(t),n);return i===null?t:unwrapMdxJsxBlock(i)??t}function wrapMdxJsxBlock(e){return`const __mdx = (
2
2
  <>
3
3
  ${e}
4
4
  </>
@@ -1 +1 @@
1
- {"version":3,"file":"remark-lint-mdx-jsx-format.js","names":[],"sources":["../src/remark-lint-mdx-jsx-format.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport type {FormatConfig} from \"oxfmt\"\n\nimport {\n formatOxfmt,\n getAbsolutePath,\n getErrorMessage,\n loadOxfmtConfig,\n} from \"./oxfmt-utils.js\"\nimport type {RemarkFile, RemarkNode, RemarkTransformer} from \"./remark-types.js\"\n\nexport default function remarkLintMdxJsxFormat(): RemarkTransformer {\n return async function transform(tree, file) {\n const source = getFileValue(file)\n\n if (!source) {\n return\n }\n\n let oxfmtConfig\n\n try {\n oxfmtConfig = await loadOxfmtConfig(file.path)\n } catch (error) {\n file.message(\n `Unable to load oxfmt config: ${getErrorMessage(error)}`,\n {column: 1, line: 1},\n \"remark-lint:mdx-jsx-format\",\n )\n await replaceMdxJsxFlowElements(tree, source, file.path, null, file)\n return\n }\n\n await replaceMdxJsxFlowElements(tree, source, file.path, oxfmtConfig, file)\n }\n}\n\nasync function replaceMdxJsxFlowElements(\n node: RemarkNode,\n source: string,\n filePath: string | undefined,\n config: FormatConfig | null,\n file: RemarkFile,\n): Promise<void> {\n if (!Array.isArray(node.children)) {\n return\n }\n\n const children: RemarkNode[] = []\n\n for (const child of node.children) {\n if (child.type === \"mdxJsxFlowElement\") {\n const raw = getSourceSlice(source, child)\n\n if (raw === null) {\n children.push(child)\n continue\n }\n\n const formatted =\n config === null || hasChildren(child)\n ? raw\n : await formatMdxJsxBlock(filePath, raw, config)\n\n if (formatted !== raw) {\n file.message(\n \"Format MDX JSX block\",\n child,\n \"remark-lint:mdx-jsx-format\",\n )\n }\n\n children.push({\n type: \"html\",\n value: formatted,\n })\n continue\n }\n\n await replaceMdxJsxFlowElements(child, source, filePath, config, file)\n children.push(child)\n }\n\n node.children = children\n}\n\nasync function formatMdxJsxBlock(\n filePath: string | undefined,\n value: string,\n config: FormatConfig,\n): Promise<string> {\n const formatted = await formatOxfmt(\n getBlockFilePath(filePath),\n wrapMdxJsxBlock(value),\n config,\n )\n\n if (formatted === null) {\n return value\n }\n\n return unwrapMdxJsxBlock(formatted) ?? value\n}\n\nfunction wrapMdxJsxBlock(value: string): string {\n return `const __mdx = (\n <>\n${value}\n </>\n)\n`\n}\n\nfunction unwrapMdxJsxBlock(value: string): null | string {\n const lines = value.split(/\\r?\\n/u)\n const openIndex = lines.findIndex((line) => line.trim() === \"<>\")\n const closeIndex = lines.findIndex(\n (line, index) => index > openIndex && line.trim() === \"</>\",\n )\n\n if (openIndex === -1 || closeIndex === -1 || closeIndex <= openIndex + 1) {\n return null\n }\n\n return lines\n .slice(openIndex + 1, closeIndex)\n .map((line) => (line.startsWith(\" \") ? line.slice(4) : line))\n .join(\"\\n\")\n}\n\nfunction getSourceSlice(source: string, node: RemarkNode): null | string {\n const start = node.position?.start?.offset\n const end = node.position?.end?.offset\n\n if (typeof start !== \"number\" || typeof end !== \"number\") {\n return null\n }\n\n return source.slice(start, end)\n}\n\nfunction getFileValue(file: RemarkFile): string {\n return (file.value ?? \"\") as string\n}\n\nfunction getBlockFilePath(filePath: string | undefined): string {\n return `${getAbsolutePath(filePath)}.jsx.tsx`\n}\n\nfunction hasChildren(node: RemarkNode): boolean {\n return Array.isArray(node.children) && node.children.length > 0\n}\n"],"mappings":"mEAaA,SAAwB,wBAA4C,CAClE,OAAO,eAAyB,EAAM,EAAM,CAC1C,IAAM,EAAS,aAAa,EAAK,CAEjC,GAAI,CAAC,EACH,OAGF,IAAI,EAEJ,GAAI,CACF,EAAc,MAAM,EAAgB,EAAK,KAAK,OACvC,EAAO,CACd,EAAK,QACH,gCAAgC,EAAgB,EAAM,GACtD,CAAC,OAAQ,EAAG,KAAM,EAAE,CACpB,6BACD,CACD,MAAM,0BAA0B,EAAM,EAAQ,EAAK,KAAM,KAAM,EAAK,CACpE,OAGF,MAAM,0BAA0B,EAAM,EAAQ,EAAK,KAAM,EAAa,EAAK,EAI/E,eAAe,0BACb,EACA,EACA,EACA,EACA,EACe,CACf,GAAI,CAAC,MAAM,QAAQ,EAAK,SAAS,CAC/B,OAGF,IAAM,EAAyB,EAAE,CAEjC,IAAK,IAAM,KAAS,EAAK,SAAU,CACjC,GAAI,EAAM,OAAS,oBAAqB,CACtC,IAAM,EAAM,eAAe,EAAQ,EAAM,CAEzC,GAAI,IAAQ,KAAM,CAChB,EAAS,KAAK,EAAM,CACpB,SAGF,IAAM,EACJ,IAAW,MAAQ,YAAY,EAAM,CACjC,EACA,MAAM,kBAAkB,EAAU,EAAK,EAAO,CAEhD,IAAc,GAChB,EAAK,QACH,uBACA,EACA,6BACD,CAGH,EAAS,KAAK,CACZ,KAAM,OACN,MAAO,EACR,CAAC,CACF,SAGF,MAAM,0BAA0B,EAAO,EAAQ,EAAU,EAAQ,EAAK,CACtE,EAAS,KAAK,EAAM,CAGtB,EAAK,SAAW,EAGlB,eAAe,kBACb,EACA,EACA,EACiB,CACjB,IAAM,EAAY,MAAM,EACtB,iBAAiB,EAAS,CAC1B,gBAAgB,EAAM,CACtB,EACD,CAMD,OAJI,IAAc,KACT,EAGF,kBAAkB,EAAU,EAAI,EAGzC,SAAS,gBAAgB,EAAuB,CAC9C,MAAO;;EAEP,EAAM;;;EAMR,SAAS,kBAAkB,EAA8B,CACvD,IAAM,EAAQ,EAAM,MAAM,SAAS,CAC7B,EAAY,EAAM,UAAW,GAAS,EAAK,MAAM,GAAK,KAAK,CAC3D,EAAa,EAAM,WACtB,EAAM,IAAU,EAAQ,GAAa,EAAK,MAAM,GAAK,MACvD,CAMD,OAJI,IAAc,IAAM,IAAe,IAAM,GAAc,EAAY,EAC9D,KAGF,EACJ,MAAM,EAAY,EAAG,EAAW,CAChC,IAAK,GAAU,EAAK,WAAW,OAAO,CAAG,EAAK,MAAM,EAAE,CAAG,EAAM,CAC/D,KAAK;EAAK,CAGf,SAAS,eAAe,EAAgB,EAAiC,CACvE,IAAM,EAAQ,EAAK,UAAU,OAAO,OAC9B,EAAM,EAAK,UAAU,KAAK,OAMhC,OAJI,OAAO,GAAU,UAAY,OAAO,GAAQ,SACvC,KAGF,EAAO,MAAM,EAAO,EAAI,CAGjC,SAAS,aAAa,EAA0B,CAC9C,OAAQ,EAAK,OAAS,GAGxB,SAAS,iBAAiB,EAAsC,CAC9D,MAAO,GAAG,EAAgB,EAAS,CAAC,UAGtC,SAAS,YAAY,EAA2B,CAC9C,OAAO,MAAM,QAAQ,EAAK,SAAS,EAAI,EAAK,SAAS,OAAS"}
1
+ {"version":3,"file":"remark-lint-mdx-jsx-format.js","names":[],"sources":["../src/remark-lint-mdx-jsx-format.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport type {FormatConfig} from \"oxfmt\"\n\nimport {\n formatOxfmt,\n getAbsolutePath,\n getErrorMessage,\n loadOxfmtConfig,\n} from \"./oxfmt-utils.js\"\nimport type {RemarkFile, RemarkNode, RemarkTransformer} from \"./remark-types.js\"\n\nexport default function remarkLintMdxJsxFormat(): RemarkTransformer {\n return async function transform(tree, file) {\n const source = getFileValue(file)\n\n if (!source) {\n return\n }\n\n let oxfmtConfig\n\n try {\n oxfmtConfig = await loadOxfmtConfig(file.path)\n } catch (error) {\n file.message(\n `Unable to load oxfmt config: ${getErrorMessage(error)}`,\n {column: 1, line: 1},\n \"remark-lint:mdx-jsx-format\",\n )\n await replaceMdxJsxFlowElements(tree, source, file.path, null, file)\n return\n }\n\n await replaceMdxJsxFlowElements(tree, source, file.path, oxfmtConfig, file)\n }\n}\n\nasync function replaceMdxJsxFlowElements(\n node: RemarkNode,\n source: string,\n filePath: string | undefined,\n config: FormatConfig | null,\n file: RemarkFile,\n): Promise<void> {\n if (!Array.isArray(node.children)) {\n return\n }\n\n const children: RemarkNode[] = []\n\n for (const child of node.children) {\n if (child.type === \"mdxJsxFlowElement\") {\n const raw = getSourceSlice(source, child)\n\n if (raw === null) {\n children.push(child)\n continue\n }\n\n const formatted =\n config === null || hasChildren(child)\n ? raw\n : await formatMdxJsxBlock(filePath, raw, config)\n\n if (formatted !== raw) {\n file.message(\n \"Format MDX JSX block\",\n child,\n \"remark-lint:mdx-jsx-format\",\n )\n }\n\n children.push({\n type: \"html\",\n value: formatted,\n })\n continue\n }\n\n await replaceMdxJsxFlowElements(child, source, filePath, config, file)\n children.push(child)\n }\n\n node.children = children\n}\n\nasync function formatMdxJsxBlock(\n filePath: string | undefined,\n value: string,\n config: FormatConfig,\n): Promise<string> {\n const formatted = await formatOxfmt(\n getBlockFilePath(filePath),\n wrapMdxJsxBlock(value),\n config,\n )\n\n if (formatted === null) {\n return value\n }\n\n return unwrapMdxJsxBlock(formatted) ?? value\n}\n\nfunction wrapMdxJsxBlock(value: string): string {\n return `const __mdx = (\n <>\n${value}\n </>\n)\n`\n}\n\nfunction unwrapMdxJsxBlock(value: string): null | string {\n const lines = value.split(/\\r?\\n/u)\n const openIndex = lines.findIndex((line) => line.trim() === \"<>\")\n const closeIndex = lines.findIndex(\n (line, index) => index > openIndex && line.trim() === \"</>\",\n )\n\n if (openIndex === -1 || closeIndex === -1 || closeIndex <= openIndex + 1) {\n return null\n }\n\n return lines\n .slice(openIndex + 1, closeIndex)\n .map((line) => (line.startsWith(\" \") ? line.slice(4) : line))\n .join(\"\\n\")\n}\n\nfunction getSourceSlice(source: string, node: RemarkNode): null | string {\n const start = node.position?.start?.offset\n const end = node.position?.end?.offset\n\n if (typeof start !== \"number\" || typeof end !== \"number\") {\n return null\n }\n\n return source.slice(start, end)\n}\n\nfunction getFileValue(file: RemarkFile): string {\n return (file.value ?? \"\") as string\n}\n\nfunction getBlockFilePath(filePath: string | undefined): string {\n return `${getAbsolutePath(filePath)}.jsx.tsx`\n}\n\nfunction hasChildren(node: RemarkNode): boolean {\n return Array.isArray(node.children) && node.children.length > 0\n}\n"],"mappings":"mEAaA,SAAwB,wBAA4C,CAClE,OAAO,eAAyB,EAAM,EAAM,CAC1C,IAAM,EAAS,aAAa,CAAI,EAEhC,GAAI,CAAC,EACH,OAGF,IAAI,EAEJ,GAAI,CACF,EAAc,MAAM,EAAgB,EAAK,IAAI,CAC/C,OAAS,EAAO,CACd,EAAK,QACH,gCAAgC,EAAgB,CAAK,IACrD,CAAC,OAAQ,EAAG,KAAM,CAAC,EACnB,4BACF,EACA,MAAM,0BAA0B,EAAM,EAAQ,EAAK,KAAM,KAAM,CAAI,EACnE,MACF,CAEA,MAAM,0BAA0B,EAAM,EAAQ,EAAK,KAAM,EAAa,CAAI,CAC5E,CACF,CAEA,eAAe,0BACb,EACA,EACA,EACA,EACA,EACe,CACf,GAAI,CAAC,MAAM,QAAQ,EAAK,QAAQ,EAC9B,OAGF,IAAM,EAAyB,CAAC,EAEhC,IAAK,IAAM,KAAS,EAAK,SAAU,CACjC,GAAI,EAAM,OAAS,oBAAqB,CACtC,IAAM,EAAM,eAAe,EAAQ,CAAK,EAExC,GAAI,IAAQ,KAAM,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C,CAC9D,MAAO,GAAG,EAAgB,CAAQ,EAAE,SACtC,CAEA,SAAS,YAAY,EAA2B,CAC9C,OAAO,MAAM,QAAQ,EAAK,QAAQ,GAAK,EAAK,SAAS,OAAS,CAChE"}
@@ -1 +1 @@
1
- {"version":3,"file":"remark-preserve-alert-markers.js","names":[],"sources":["../src/remark-preserve-alert-markers.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport type {Processor} from \"unified\"\n\ninterface MarkdownExtension {\n handlers?: {\n text?: MarkdownHandler\n }\n}\n\ninterface MarkdownInfo {\n after?: string\n before?: string\n}\n\ninterface MarkdownNode {\n type: string\n value: string\n}\n\ninterface MarkdownParent {\n children?: MarkdownNode[]\n type: string\n}\n\ninterface MarkdownState {\n safe: (value: string, info: MarkdownInfo) => string\n stack: string[]\n}\n\ninterface MarkdownProcessorData {\n toMarkdownExtensions?: MarkdownExtension[]\n}\n\ntype MarkdownHandler = (\n node: MarkdownNode,\n parent: MarkdownParent | undefined,\n state: MarkdownState,\n info: MarkdownInfo,\n) => string\n\nconst ALERT_MARKER_PATTERN =\n /^\\\\?\\[!(?:note|tip|success|warning|caution)(?:\\/[^\\]\\n]+)?\\]/iu\n\nexport default function remarkPreserveAlertMarkers(this: Processor): void {\n const extensions = getToMarkdownExtensions(this)\n\n // mdx/remark fixes reserialize the whole file. Register with the markdown\n // stringifier so alert markers keep the syntax consumed by the docs runtime.\n const data = this.data() as MarkdownProcessorData\n data.toMarkdownExtensions = [\n ...extensions,\n {\n handlers: {\n text: preserveAlertMarkerText,\n },\n },\n ]\n}\n\nfunction preserveAlertMarkerText(\n node: MarkdownNode,\n parent: MarkdownParent | undefined,\n state: MarkdownState,\n info: MarkdownInfo,\n): string {\n const value = state.safe(node.value, info)\n\n if (!isAlertMarkerText(node, parent, state)) {\n return value\n }\n\n return value.replace(/^\\\\(?=\\[!)/u, \"\")\n}\n\nfunction isAlertMarkerText(\n node: MarkdownNode,\n parent: MarkdownParent | undefined,\n state: MarkdownState,\n): boolean {\n return (\n parent?.type === \"paragraph\" &&\n parent.children?.[0] === node &&\n state.stack.includes(\"blockquote\") &&\n ALERT_MARKER_PATTERN.test(node.value)\n )\n}\n\nfunction getToMarkdownExtensions(processor: Processor): MarkdownExtension[] {\n const {toMarkdownExtensions} = processor.data() as MarkdownProcessorData\n\n return Array.isArray(toMarkdownExtensions) ? toMarkdownExtensions : []\n}\n"],"mappings":"AA0CA,IAAM,EACJ,iEAEF,SAAwB,4BAAkD,CACxE,IAAM,EAAa,wBAAwB,KAAK,CAI1C,EAAO,KAAK,MAAM,CACxB,EAAK,qBAAuB,CAC1B,GAAG,EACH,CACE,SAAU,CACR,KAAM,wBACP,CACF,CACF,CAGH,SAAS,wBACP,EACA,EACA,EACA,EACQ,CACR,IAAM,EAAQ,EAAM,KAAK,EAAK,MAAO,EAAK,CAM1C,OAJK,kBAAkB,EAAM,EAAQ,EAAM,CAIpC,EAAM,QAAQ,cAAe,GAAG,CAH9B,EAMX,SAAS,kBACP,EACA,EACA,EACS,CACT,OACE,GAAQ,OAAS,aACjB,EAAO,WAAW,KAAO,GACzB,EAAM,MAAM,SAAS,aAAa,EAClC,EAAqB,KAAK,EAAK,MAAM,CAIzC,SAAS,wBAAwB,EAA2C,CAC1E,GAAM,CAAC,wBAAwB,EAAU,MAAM,CAE/C,OAAO,MAAM,QAAQ,EAAqB,CAAG,EAAuB,EAAE"}
1
+ {"version":3,"file":"remark-preserve-alert-markers.js","names":[],"sources":["../src/remark-preserve-alert-markers.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport type {Processor} from \"unified\"\n\ninterface MarkdownExtension {\n handlers?: {\n text?: MarkdownHandler\n }\n}\n\ninterface MarkdownInfo {\n after?: string\n before?: string\n}\n\ninterface MarkdownNode {\n type: string\n value: string\n}\n\ninterface MarkdownParent {\n children?: MarkdownNode[]\n type: string\n}\n\ninterface MarkdownState {\n safe: (value: string, info: MarkdownInfo) => string\n stack: string[]\n}\n\ninterface MarkdownProcessorData {\n toMarkdownExtensions?: MarkdownExtension[]\n}\n\ntype MarkdownHandler = (\n node: MarkdownNode,\n parent: MarkdownParent | undefined,\n state: MarkdownState,\n info: MarkdownInfo,\n) => string\n\nconst ALERT_MARKER_PATTERN =\n /^\\\\?\\[!(?:note|tip|success|warning|caution)(?:\\/[^\\]\\n]+)?\\]/iu\n\nexport default function remarkPreserveAlertMarkers(this: Processor): void {\n const extensions = getToMarkdownExtensions(this)\n\n // mdx/remark fixes reserialize the whole file. Register with the markdown\n // stringifier so alert markers keep the syntax consumed by the docs runtime.\n const data = this.data() as MarkdownProcessorData\n data.toMarkdownExtensions = [\n ...extensions,\n {\n handlers: {\n text: preserveAlertMarkerText,\n },\n },\n ]\n}\n\nfunction preserveAlertMarkerText(\n node: MarkdownNode,\n parent: MarkdownParent | undefined,\n state: MarkdownState,\n info: MarkdownInfo,\n): string {\n const value = state.safe(node.value, info)\n\n if (!isAlertMarkerText(node, parent, state)) {\n return value\n }\n\n return value.replace(/^\\\\(?=\\[!)/u, \"\")\n}\n\nfunction isAlertMarkerText(\n node: MarkdownNode,\n parent: MarkdownParent | undefined,\n state: MarkdownState,\n): boolean {\n return (\n parent?.type === \"paragraph\" &&\n parent.children?.[0] === node &&\n state.stack.includes(\"blockquote\") &&\n ALERT_MARKER_PATTERN.test(node.value)\n )\n}\n\nfunction getToMarkdownExtensions(processor: Processor): MarkdownExtension[] {\n const {toMarkdownExtensions} = processor.data() as MarkdownProcessorData\n\n return Array.isArray(toMarkdownExtensions) ? toMarkdownExtensions : []\n}\n"],"mappings":"AA0CA,IAAM,EACJ,iEAEF,SAAwB,4BAAkD,CACxE,IAAM,EAAa,wBAAwB,IAAI,EAIzC,EAAO,KAAK,KAAK,EACvB,EAAK,qBAAuB,CAC1B,GAAG,EACH,CACE,SAAU,CACR,KAAM,uBACR,CACF,CACF,CACF,CAEA,SAAS,wBACP,EACA,EACA,EACA,EACQ,CACR,IAAM,EAAQ,EAAM,KAAK,EAAK,MAAO,CAAI,EAMzC,OAJK,kBAAkB,EAAM,EAAQ,CAAK,EAInC,EAAM,QAAQ,cAAe,EAAE,EAH7B,CAIX,CAEA,SAAS,kBACP,EACA,EACA,EACS,CACT,OACE,GAAQ,OAAS,aACjB,EAAO,WAAW,KAAO,GACzB,EAAM,MAAM,SAAS,YAAY,GACjC,EAAqB,KAAK,EAAK,KAAK,CAExC,CAEA,SAAS,wBAAwB,EAA2C,CAC1E,GAAM,CAAC,wBAAwB,EAAU,KAAK,EAE9C,OAAO,MAAM,QAAQ,CAAoB,EAAI,EAAuB,CAAC,CACvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"remarkrc.js","names":[],"sources":["../src/remarkrc.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport remarkLintCodeFormat from \"./remark-lint-code-format.js\"\nimport remarkLintMdxJsxFormat from \"./remark-lint-mdx-jsx-format.js\"\nimport remarkPreserveAlertMarkers from \"./remark-preserve-alert-markers.js\"\n\nconst remarkConfig: any = {\n plugins: [\n \"remark-frontmatter\",\n \"remark-lint-fenced-code-flag\",\n \"remark-lint-final-newline\",\n \"remark-lint-heading-increment\",\n \"remark-lint-list-item-content-indent\",\n [\"remark-lint-list-item-indent\", \"one\"],\n [\"remark-lint-maximum-heading-length\", {size: 80}],\n \"remark-lint-no-consecutive-blank-lines\",\n \"remark-lint-no-duplicate-headings-in-section\",\n [\"remark-lint-no-heading-punctuation\", \",.:;\"],\n [\"remark-lint-unordered-list-marker-style\", \"-\"],\n remarkLintCodeFormat,\n remarkLintMdxJsxFormat,\n remarkPreserveAlertMarkers,\n ],\n settings: {\n bullet: \"-\",\n rule: \"-\",\n },\n}\n\nexport default remarkConfig\n"],"mappings":"6IAOA,IAAM,EAAoB,CACxB,QAAS,CACP,qBACA,+BACA,4BACA,gCACA,uCACA,CAAC,+BAAgC,MAAM,CACvC,CAAC,qCAAsC,CAAC,KAAM,GAAG,CAAC,CAClD,yCACA,+CACA,CAAC,qCAAsC,OAAO,CAC9C,CAAC,0CAA2C,IAAI,CAChD,EACA,EACA,EACD,CACD,SAAU,CACR,OAAQ,IACR,KAAM,IACP,CACF"}
1
+ {"version":3,"file":"remarkrc.js","names":[],"sources":["../src/remarkrc.ts"],"sourcesContent":["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport remarkLintCodeFormat from \"./remark-lint-code-format.js\"\nimport remarkLintMdxJsxFormat from \"./remark-lint-mdx-jsx-format.js\"\nimport remarkPreserveAlertMarkers from \"./remark-preserve-alert-markers.js\"\n\nconst remarkConfig: any = {\n plugins: [\n \"remark-frontmatter\",\n \"remark-lint-fenced-code-flag\",\n \"remark-lint-final-newline\",\n \"remark-lint-heading-increment\",\n \"remark-lint-list-item-content-indent\",\n [\"remark-lint-list-item-indent\", \"one\"],\n [\"remark-lint-maximum-heading-length\", {size: 80}],\n \"remark-lint-no-consecutive-blank-lines\",\n \"remark-lint-no-duplicate-headings-in-section\",\n [\"remark-lint-no-heading-punctuation\", \",.:;\"],\n [\"remark-lint-unordered-list-marker-style\", \"-\"],\n remarkLintCodeFormat,\n remarkLintMdxJsxFormat,\n remarkPreserveAlertMarkers,\n ],\n settings: {\n bullet: \"-\",\n rule: \"-\",\n },\n}\n\nexport default remarkConfig\n"],"mappings":"6IAOA,IAAM,EAAoB,CACxB,QAAS,CACP,qBACA,+BACA,4BACA,gCACA,uCACA,CAAC,+BAAgC,KAAK,EACtC,CAAC,qCAAsC,CAAC,KAAM,EAAE,CAAC,EACjD,yCACA,+CACA,CAAC,qCAAsC,MAAM,EAC7C,CAAC,0CAA2C,GAAG,EAC/C,EACA,EACA,CACF,EACA,SAAU,CACR,OAAQ,IACR,KAAM,GACR,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qualcomm-ui/eslint-config-mdx",
3
- "version": "3.0.3",
3
+ "version": "4.0.0",
4
4
  "description": "QUI ESLint config for consistent MDX code",
5
5
  "keywords": [
6
6
  "config",
@@ -67,8 +67,8 @@
67
67
  "remark-lint-no-duplicate-headings-in-section": ">=4.0.1",
68
68
  "remark-lint-no-heading-punctuation": ">=4.0.1",
69
69
  "remark-lint-unordered-list-marker-style": ">=4.0.1",
70
- "typescript": ">=5.9.3",
71
- "typescript-eslint": ">=8.31.1",
70
+ "typescript": ">=6.0.3",
71
+ "typescript-eslint": ">=8.67.0",
72
72
  "unified": ">=11"
73
73
  }
74
74
  }
@@ -1,2 +0,0 @@
1
- import{readFile as e}from"node:fs/promises";import{dirname as t,isAbsolute as n,join as r,parse as i,resolve as a}from"node:path";import{pathToFileURL as o}from"node:url";import{format as s}from"oxfmt";import{parseConfigFileTextToJson as c}from"typescript";var l=[`.oxfmtrc.json`,`.oxfmtrc.jsonc`,`oxfmt.config.ts`],u=new Map;async function loadOxfmtConfig(e){let n=getAbsolutePath(e),r=i(n).ext?t(n):n,a=u.get(r);if(a)return a;let o=findOxfmtConfig(r).catch(e=>{throw u.delete(r),e});return u.set(r,o),o}async function formatOxfmt(e,t,n){try{let r=await s(e,t,n);return r.errors.length>0?null:removeFinalEol(r.code)}catch{return null}}function getAbsolutePath(e){return e?n(e)?e:a(process.cwd(),e):process.cwd()}function getErrorMessage(e){return e instanceof Error?e.message:String(e)}async function findOxfmtConfig(e){let n=e;for(;;){for(let e of l){let t=await readOxfmtConfig(r(n,e),e);if(t)return t}let e=t(n);if(e===n)return{};n=e}}async function readOxfmtConfig(e,t){if(t===`oxfmt.config.ts`)return readTypeScriptConfig(e);let n=await readOptionalFile(e);return n===null?null:t.endsWith(`.jsonc`)?validateConfig(e,readJsoncConfig(e,n)):validateConfig(e,JSON.parse(n))}async function readTypeScriptConfig(e){if(await readOptionalFile(e)===null)return null;let t=o(e);return t.searchParams.set(`cache`,Date.now().toString()),validateConfig(e,(await import(t.href)).default)}function readJsoncConfig(e,t){let n=c(e,t);if(n.error)throw Error(String(n.error.messageText));return n.config}function validateConfig(e,t){if(!isPlainConfig(t))throw Error(`${e} must define an object`);return t}async function readOptionalFile(t){try{return await e(t,`utf8`)}catch(e){if(isMissingFileError(e))return null;throw e}}function removeFinalEol(e){return e.replace(/\r?\n$/u,``)}function isPlainConfig(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function isMissingFileError(e){if(typeof e!=`object`||!e||!(`code`in e))return!1;let{code:t}=e;return t===`ENOENT`||t===`ENOTDIR`}export{loadOxfmtConfig as i,getAbsolutePath as n,getErrorMessage as r,formatOxfmt as t};
2
- //# sourceMappingURL=oxfmt-utils-CCT1qOHc.js.map