@qualcomm-ui/eslint-config-mdx 3.0.1 → 3.0.3
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.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -29
- package/dist/index.js.map +1 -7
- package/dist/oxfmt-utils-CCT1qOHc.js +2 -0
- package/dist/oxfmt-utils-CCT1qOHc.js.map +1 -0
- package/dist/recommended.d.ts +2 -1
- package/dist/recommended.d.ts.map +1 -1
- package/dist/remark-lint-code-format.js +3 -230
- package/dist/remark-lint-code-format.js.map +1 -7
- package/dist/remark-lint-mdx-jsx-format.js +5 -223
- package/dist/remark-lint-mdx-jsx-format.js.map +1 -7
- package/dist/remark-preserve-alert-markers.js +2 -32
- package/dist/remark-preserve-alert-markers.js.map +1 -7
- package/dist/remarkrc.d.ts +1 -10
- package/dist/remarkrc.d.ts.map +1 -1
- package/dist/remarkrc.js +2 -385
- package/dist/remarkrc.js.map +1 -7
- package/package.json +12 -9
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,eAAe,CAAA;AAIzC,QAAA,MAAM,SAAS,EAAE;IAAC,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAAA;CAIzD,CAAA;AAED,eAAe,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import * as mdx from "eslint-plugin-mdx";
|
|
4
|
-
import reactPlugin from "eslint-plugin-react";
|
|
5
|
-
var recommended = defineConfig({
|
|
6
|
-
...mdx.flat,
|
|
7
|
-
plugins: {
|
|
8
|
-
...mdx.flat.plugins,
|
|
9
|
-
react: reactPlugin
|
|
10
|
-
},
|
|
11
|
-
rules: {
|
|
12
|
-
...mdx.flat.rules,
|
|
13
|
-
"mdx/remark": "error",
|
|
14
|
-
"no-unused-expressions": "off"
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
var recommended_default = recommended;
|
|
18
|
-
|
|
19
|
-
// src/index.ts
|
|
20
|
-
var mdxConfig = {
|
|
21
|
-
configs: {
|
|
22
|
-
recommended: recommended_default
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
var index_default = mdxConfig;
|
|
26
|
-
export {
|
|
27
|
-
index_default as default
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
|
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};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/recommended.ts", "../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n// SPDX-License-Identifier: BSD-3-Clause-Clear\n\nimport {defineConfig} from \"eslint/config\"\nimport * as mdx from \"eslint-plugin-mdx\"\nimport reactPlugin from \"eslint-plugin-react\"\n\nconst recommended = 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 recommended from \"./recommended.js\"\n\nconst mdxConfig = {\n configs: {\n recommended,\n },\n}\n\nexport default mdxConfig\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAQ,oBAAmB;AAC3B,YAAY,SAAS;AACrB,OAAO,iBAAiB;AAExB,IAAM,cAAc,aAAa;AAAA,EAC/B,GAAO;AAAA,EACP,SAAS;AAAA,IACP,GAAO,SAAK;AAAA,IACZ,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,GAAO,SAAK;AAAA,IACZ,cAAc;AAAA,IACd,yBAAyB;AAAA,EAC3B;AACF,CAAC;AAED,IAAO,sBAAQ;;;ACff,IAAM,YAAY;AAAA,EAChB,SAAS;AAAA,IACP;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
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,iBACA,iBACA,YACA,SACA,gBACA,gCACA,OACA,CAEK,EAA0B,IAAI,IAAI,CAAC,WAAY,UAAW,OAAO,CAAC,CAQxE,SAAS,cAAc,EAAQ,EAAW,CAKzC,OAJI,EAAO,KACH,EAAO,KAGR,aAAa,IASrB,SAAS,iBAAiB,EAAW,EAAW,CAS/C,OARI,OAAO,GAAc,SACjB,EAGJ,EAAU,KACN,EAAU,KAG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I,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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +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,CAKpE,OAJK,EAIE,EAAW,EAAS,CAAG,EAAW,EAAQ,QAAQ,KAAK,CAAE,EAAS,CAHhE,QAAQ,KAAK,CAMxB,SAAgB,gBAAgB,EAAwB,CAKtD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,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"}
|
package/dist/recommended.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../src/recommended.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../src/recommended.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,KAAK,MAAM,EAAC,MAAM,eAAe,CAAA;AAEvD,QAAA,MAAM,WAAW,EAAE,MAAM,EAWvB,CAAA;AAEF,eAAe,WAAW,CAAA"}
|
|
@@ -1,230 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
import { format as formatCode } from "oxfmt";
|
|
6
|
-
import { parseConfigFileTextToJson } from "typescript";
|
|
7
|
-
var CONFIG_FILENAMES = [".oxfmtrc.json", ".oxfmtrc.jsonc", "oxfmt.config.ts"];
|
|
8
|
-
var configCache = /* @__PURE__ */ new Map();
|
|
9
|
-
async function loadOxfmtConfig(filePath) {
|
|
10
|
-
const basePath = getAbsolutePath(filePath);
|
|
11
|
-
const startDir = parse(basePath).ext ? dirname(basePath) : basePath;
|
|
12
|
-
const cachedConfig = configCache.get(startDir);
|
|
13
|
-
if (cachedConfig) {
|
|
14
|
-
return cachedConfig;
|
|
15
|
-
}
|
|
16
|
-
const configPromise = findOxfmtConfig(startDir).catch((error) => {
|
|
17
|
-
configCache.delete(startDir);
|
|
18
|
-
throw error;
|
|
19
|
-
});
|
|
20
|
-
configCache.set(startDir, configPromise);
|
|
21
|
-
return configPromise;
|
|
22
|
-
}
|
|
23
|
-
async function formatOxfmt(filePath, value, config) {
|
|
24
|
-
try {
|
|
25
|
-
const result = await formatCode(filePath, value, config);
|
|
26
|
-
if (result.errors.length > 0) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
return removeFinalEol(result.code);
|
|
30
|
-
} catch {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function getAbsolutePath(filePath) {
|
|
35
|
-
if (!filePath) {
|
|
36
|
-
return process.cwd();
|
|
37
|
-
}
|
|
38
|
-
return isAbsolute(filePath) ? filePath : resolve(process.cwd(), filePath);
|
|
39
|
-
}
|
|
40
|
-
function getErrorMessage(error) {
|
|
41
|
-
if (error instanceof Error) {
|
|
42
|
-
return error.message;
|
|
43
|
-
}
|
|
44
|
-
return String(error);
|
|
45
|
-
}
|
|
46
|
-
async function findOxfmtConfig(startDir) {
|
|
47
|
-
let currentDir = startDir;
|
|
48
|
-
while (true) {
|
|
49
|
-
for (const configFilename of CONFIG_FILENAMES) {
|
|
50
|
-
const configPath = join(currentDir, configFilename);
|
|
51
|
-
const config = await readOxfmtConfig(configPath, configFilename);
|
|
52
|
-
if (config) {
|
|
53
|
-
return config;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const parentDir = dirname(currentDir);
|
|
57
|
-
if (parentDir === currentDir) {
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
currentDir = parentDir;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async function readOxfmtConfig(configPath, configFilename) {
|
|
64
|
-
if (configFilename === "oxfmt.config.ts") {
|
|
65
|
-
return readTypeScriptConfig(configPath);
|
|
66
|
-
}
|
|
67
|
-
const source = await readOptionalFile(configPath);
|
|
68
|
-
if (source === null) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
if (configFilename.endsWith(".jsonc")) {
|
|
72
|
-
return validateConfig(configPath, readJsoncConfig(configPath, source));
|
|
73
|
-
}
|
|
74
|
-
return validateConfig(configPath, JSON.parse(source));
|
|
75
|
-
}
|
|
76
|
-
async function readTypeScriptConfig(configPath) {
|
|
77
|
-
const source = await readOptionalFile(configPath);
|
|
78
|
-
if (source === null) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
const url = pathToFileURL(configPath);
|
|
82
|
-
url.searchParams.set("cache", Date.now().toString());
|
|
83
|
-
const module = await import(url.href);
|
|
84
|
-
return validateConfig(configPath, module.default);
|
|
85
|
-
}
|
|
86
|
-
function readJsoncConfig(configPath, source) {
|
|
87
|
-
const result = parseConfigFileTextToJson(configPath, source);
|
|
88
|
-
if (result.error) {
|
|
89
|
-
throw new Error(String(result.error.messageText));
|
|
90
|
-
}
|
|
91
|
-
return result.config;
|
|
92
|
-
}
|
|
93
|
-
function validateConfig(configPath, config) {
|
|
94
|
-
if (!isPlainConfig(config)) {
|
|
95
|
-
throw new Error(`${configPath} must define an object`);
|
|
96
|
-
}
|
|
97
|
-
return config;
|
|
98
|
-
}
|
|
99
|
-
async function readOptionalFile(path) {
|
|
100
|
-
try {
|
|
101
|
-
return await readFile(path, "utf8");
|
|
102
|
-
} catch (error) {
|
|
103
|
-
if (isMissingFileError(error)) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function removeFinalEol(value) {
|
|
110
|
-
return value.replace(/\r?\n$/u, "");
|
|
111
|
-
}
|
|
112
|
-
function isPlainConfig(value) {
|
|
113
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
114
|
-
}
|
|
115
|
-
function isMissingFileError(error) {
|
|
116
|
-
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
const { code } = error;
|
|
120
|
-
return code === "ENOENT" || code === "ENOTDIR";
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// src/remark-lint-code-format.ts
|
|
124
|
-
var LANGUAGE_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
125
|
-
["javascript", ".js"],
|
|
126
|
-
["javascriptreact", ".jsx"],
|
|
127
|
-
["js", ".js"],
|
|
128
|
-
["jsx", ".jsx"],
|
|
129
|
-
["ts", ".ts"],
|
|
130
|
-
["tsx", ".tsx"],
|
|
131
|
-
["typescript", ".ts"],
|
|
132
|
-
["typescriptreact", ".tsx"]
|
|
133
|
-
]);
|
|
134
|
-
function remarkLintCodeFormat() {
|
|
135
|
-
return async function transform(tree, file) {
|
|
136
|
-
let oxfmtConfig;
|
|
137
|
-
try {
|
|
138
|
-
oxfmtConfig = await loadOxfmtConfig(file.path);
|
|
139
|
-
} catch (error) {
|
|
140
|
-
file.message(
|
|
141
|
-
`Unable to load oxfmt config: ${getErrorMessage(error)}`,
|
|
142
|
-
{ column: 1, line: 1 },
|
|
143
|
-
"remark-lint:code-format"
|
|
144
|
-
);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const codeNodes = [];
|
|
148
|
-
visit(tree, "code", (node) => {
|
|
149
|
-
if (typeof node.value === "string") {
|
|
150
|
-
codeNodes.push(node);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
for (const [index, node] of codeNodes.entries()) {
|
|
154
|
-
const extension = getExtension(node.lang);
|
|
155
|
-
if (!extension) {
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
const blockFilePath = getBlockFilePath(file.path, index, extension);
|
|
159
|
-
if (isStandaloneJsxSnippet(extension, node.value)) {
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
const formatted = await formatOxfmt(
|
|
163
|
-
blockFilePath,
|
|
164
|
-
node.value,
|
|
165
|
-
oxfmtConfig
|
|
166
|
-
);
|
|
167
|
-
if (formatted === null) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (formatted !== node.value) {
|
|
171
|
-
file.message(
|
|
172
|
-
"Format code block with oxfmt",
|
|
173
|
-
node,
|
|
174
|
-
"remark-lint:code-format"
|
|
175
|
-
);
|
|
176
|
-
node.value = formatted;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function getBlockFilePath(filePath, index, extension) {
|
|
182
|
-
return `${getAbsolutePath(filePath)}.${index}${extension}`;
|
|
183
|
-
}
|
|
184
|
-
function getExtension(language) {
|
|
185
|
-
if (!language) {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
const [name = ""] = language.trim().split(/\s+/u);
|
|
189
|
-
return LANGUAGE_EXTENSIONS.get(name.toLowerCase()) ?? null;
|
|
190
|
-
}
|
|
191
|
-
function isStandaloneJsxSnippet(extension, value) {
|
|
192
|
-
return (extension === ".jsx" || extension === ".tsx") && /^<(?:>|\/?[A-Za-z][\w.:/-]*(?:[\s>/]|$))/u.test(trimLeadingComments(value));
|
|
193
|
-
}
|
|
194
|
-
function trimLeadingComments(value) {
|
|
195
|
-
let source = value.trimStart();
|
|
196
|
-
while (true) {
|
|
197
|
-
if (source.startsWith("//")) {
|
|
198
|
-
const nextLineIndex = source.indexOf("\n");
|
|
199
|
-
if (nextLineIndex === -1) {
|
|
200
|
-
return "";
|
|
201
|
-
}
|
|
202
|
-
source = source.slice(nextLineIndex + 1).trimStart();
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
if (source.startsWith("/*")) {
|
|
206
|
-
const commentEndIndex = source.indexOf("*/");
|
|
207
|
-
if (commentEndIndex === -1) {
|
|
208
|
-
return source;
|
|
209
|
-
}
|
|
210
|
-
source = source.slice(commentEndIndex + 2).trimStart();
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
return source;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function visit(node, type, callback) {
|
|
217
|
-
if (node.type === type) {
|
|
218
|
-
callback(node);
|
|
219
|
-
}
|
|
220
|
-
if (!Array.isArray(node.children)) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
for (const child of node.children) {
|
|
224
|
-
visit(child, type, callback);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
export {
|
|
228
|
-
remarkLintCodeFormat as default
|
|
229
|
-
};
|
|
230
|
-
//# sourceMappingURL=remark-lint-code-format.js.map
|
|
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(`
|
|
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
|
+
//# sourceMappingURL=remark-lint-code-format.js.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/oxfmt-utils.ts", "../src/remark-lint-code-format.ts"],
|
|
4
|
-
"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", "// 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"],
|
|
5
|
-
"mappings": ";AAGA,SAAQ,gBAAe;AACvB,SAAQ,SAAS,YAAY,MAAM,OAAO,eAAc;AACxD,SAAQ,qBAAoB;AAC5B,SAAQ,UAAU,kBAAoC;AACtD,SAAQ,iCAAgC;AAExC,IAAM,mBAAmB,CAAC,iBAAiB,kBAAkB,iBAAiB;AAC9E,IAAM,cAAc,oBAAI,IAAmC;AAE3D,eAAsB,gBACpB,UACuB;AACvB,QAAM,WAAW,gBAAgB,QAAQ;AACzC,QAAM,WAAW,MAAM,QAAQ,EAAE,MAAM,QAAQ,QAAQ,IAAI;AAC3D,QAAM,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AAQ;AAAA,EAC7B;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
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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