eslint-cli-bundle 1.0.4 → 1.0.5
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/api.d.ts +1473 -0
- package/dist/api.js +5 -0
- package/dist/eslint.js +13 -281
- package/dist/legacy-eslint-DYfSFaC6.js +269 -0
- package/dist/types-CRoZH7Is.d.ts +1336 -0
- package/package.json +7 -2
- /package/dist/{jiti-xhrF4nV-.js → jiti-DyCiGFB9.js} +0 -0
- /package/dist/{src-D7slgxDU.js → src-FNB-unmu.js} +0 -0
package/dist/api.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r as e,t}from"./chunk-qnHZjHhP.js";import{_ as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,s as f,t as p,u as m,x as h}from"./legacy-eslint-DYfSFaC6.js";var g=t(((e,t)=>{function n(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`||typeof e==`object`&&e.constructor===Object||Array.isArray(e)}function r(e,t=new Set){if(!n(e))return!1;if(typeof e==`object`&&e){if(t.has(e))return!1;for(let i in e)if(Object.hasOwn(e,i)&&(!n(e[i])||typeof e[i]==`object`&&e[i]!==null&&!r(e[i],new Set([...t,e]))))return!1}return!0}t.exports={isSerializable:r}})),_=t(((t,u)=>{let p=e(`node:assert`),_=e(`node:util`),v=e(`node:path`),y=l(),b=h(),{Config:x}=m(),{Linter:S,SourceCodeFixer:C}=d(),{interpolate:w,getPlaceholderMatcher:T}=f(),ee=s(),{FlatConfigArray:te}=c(),{defaultConfig:E,defaultRuleTesterConfig:D}=o(),O=r()({strictDefaults:!0}),k=Symbol.for(`eslint.RuleTester.parser`),{ConfigArraySymbol:A}=i(),{isSerializable:ne}=g(),re=a(),{SourceCode:j}=n(),ie={rules:{}},M={rules:{}},N=[`name`,`code`,`filename`,`options`,`before`,`after`,`errors`,`output`,`only`],P=new Set([`message`,`messageId`,`data`,`type`,`line`,`column`,`endLine`,`endColumn`,`suggestions`]),F=`[${[...P].map(e=>`'${e}'`).join(`, `)}]`,I=new Set([`desc`,`messageId`,`data`,`output`]),L=`[${[...I].map(e=>`'${e}'`).join(`, `)}]`,R=new Set([`name`,`errors`,`output`]),z=[`applyInlineConfig`,`applyLanguageOptions`,`finalize`],B=new Map(z.map(e=>[e,new WeakSet])),V=Function.call.bind(Object.hasOwnProperty);function H(e){if(typeof e==`object`&&e){if(Array.isArray(e))return e.map(H);let t={};for(let n in e)n!==`parent`&&V(e,n)&&(t[n]=H(e[n]));return t}return e}function U(e,t=new Set){if(typeof e==`object`&&e){if(t.has(e))return;if(t.add(e),Array.isArray(e))e.forEach(e=>{U(e,t)});else for(let n in e)n!==`parent`&&V(e,n)&&U(e[n],t);Object.freeze(e)}}function W(e){return typeof e==`string`?e.replace(/[\u0000-\u0009\u000b-\u001a]/gu,e=>`\\u${e.codePointAt(0).toString(16).padStart(4,`0`)}`):``}function G(e,t){Object.defineProperties(t,{start:{get(){throw Error(`Use ${e}.range[0] instead of ${e}.start`)},configurable:!0,enumerable:!1},end:{get(){throw Error(`Use ${e}.range[1] instead of ${e}.end`)},configurable:!0,enumerable:!1}})}function K(e,t){b.traverse(e,{visitorKeys:t,enter:G.bind(null,`node`)}),e.tokens.forEach(G.bind(null,`token`)),e.comments.forEach(G.bind(null,`token`))}function ae(e){return typeof e.parseForESLint==`function`?{[k]:e,parseForESLint(...t){let n=e.parseForESLint(...t);return K(n.ast,n.visitorKeys),n}}:{[k]:e,parse(...t){let n=e.parse(...t);return K(n),n}}}function oe(e,t){let n=t[e];return function(...t){let r=B.get(e);if(!r.has(this))return r.add(this),n.apply(this,t);throw Error(`\`SourceCode#${e}()\` cannot be called inside a rule.`)}}function q(e){let t=T();return Array.from(e.matchAll(t),([,e])=>e.trim())}function J(e,t,n={}){let r=q(e);if(r.length===0)return[];let i=q(t),a=Object.keys(n);return r.filter(e=>i.includes(e)&&!a.includes(e))}let Y="\n - If the rule has options, set `meta.schema` to an array or non-empty object to enable options validation.\n - If the rule doesn't have options, omit `meta.schema` to enforce that no options can be passed to the rule.\n - You can also set `meta.schema` to `false` to opt-out of options validation (not recommended).\n\n https://eslint.org/docs/latest/extend/custom-rules#options-schemas\n",X=Symbol(`describe`),Z=Symbol(`it`),Q=Symbol(`itOnly`);function se(e,t){try{return t.call(this)}catch(e){throw e instanceof p.AssertionError&&(e.message+=` (${_.inspect(e.actual)} ${e.operator} ${_.inspect(e.expected)})`),e}}function ce(e,t){return t.call(this)}var $=class{constructor(e={}){this.testerConfig=[M,e,{rules:{"rule-tester/validate-ast":`error`}}],this.linter=new S({configType:`flat`})}static setDefaultConfig(e){if(typeof e!=`object`||!e)throw TypeError(`RuleTester.setDefaultConfig: config must be an object`);M=e,M.rules=M.rules||{}}static getDefaultConfig(){return M}static resetDefaultConfig(){M={rules:{...ie.rules}}}static get describe(){return this[X]||(typeof describe==`function`?describe:ce)}static set describe(e){this[X]=e}static get it(){return this[Z]||(typeof it==`function`?it:se)}static set it(e){this[Z]=e}static only(e){return typeof e==`string`?{code:e,only:!0}:{...e,only:!0}}static get itOnly(){if(typeof this[Q]==`function`)return this[Q];if(typeof this[Z]==`function`&&typeof this[Z].only==`function`)return Function.bind.call(this[Z].only,this[Z]);if(typeof it==`function`&&typeof it.only==`function`)return Function.bind.call(it.only,it);throw typeof this[X]==`function`||typeof this[Z]==`function`?Error("Set `RuleTester.itOnly` to use `only` with a custom test framework.\nSee https://eslint.org/docs/latest/integrate/nodejs-api#customizing-ruletester for more."):typeof it==`function`?Error("The current test framework does not support exclusive tests with `only`."):Error("To use `only`, use RuleTester with a test framework that provides `it.only()` like Mocha.")}static set itOnly(e){this[Q]=e}run(e,t,n){let r=this.testerConfig,i=[`valid`,`invalid`],a=[],o=this.linter,s=`rule-to-test/${e}`,c=new Set,l=new Set;if(!t||typeof t!=`object`||typeof t.create!=`function`)throw TypeError("Rule must be an object with a `create` method");if(!n||typeof n!=`object`)throw TypeError(`Test Scenarios for rule ${e} : Could not find test scenario object`);if(i.forEach(e=>{n[e]||a.push(`Could not find any ${e} test scenarios`)}),a.length>0)throw Error([`Test Scenarios for rule ${e} is invalid:`].concat(a).join(`
|
|
2
|
+
`));let u=[{plugins:{"@":{parsers:{...E[0].plugins[`@`].parsers},rules:E[0].plugins[`@`].rules,languages:E[0].plugins[`@`].languages},"rule-to-test":{rules:{[e]:Object.assign({},t,{create(e){return U(e.options),U(e.settings),U(e.parserOptions),t.create(e)}})}}},language:E[0].language},...D];function d(e,t){typeof e==`object`&&V(e,t)&&(p.strictEqual(typeof e[t],`function`,`Optional test case property '${t}' must be a function`),e[t]())}function f(n){let i={baseConfig:u};n.filename&&(i.basePath=v.parse(n.filename).root||void 0);let a=new te(r,i);a[A.finalizeConfig]=function(...e){let t=Object.getPrototypeOf(this)[A.finalizeConfig].apply(this,e);return t.language===re&&(t.languageOptions.parser=ae(t.languageOptions.parser)),t};let c,l,d,f,m;if(typeof n==`string`)c=n;else{c=n.code;let e={...n};for(let t of N)delete e[t];a.push(e)}V(n,`only`)&&p.ok(typeof n.only==`boolean`,`Optional test case property 'only' must be a boolean`),V(n,`filename`)&&(p.ok(typeof n.filename==`string`,`Optional test case property 'filename' must be a string`),l=n.filename);let h=1;V(n,`options`)&&(p(Array.isArray(n.options),`options must be an array`),h=[1,...n.options]),a.push({rules:{[s]:h}});let g;try{g=x.getRuleOptionsSchema(t)}catch(e){throw e.message+=Y,e}if(g&&Object.keys(g).length===0)throw Error(`\`schema: {}\` is a no-op${Y}`);if(a.push({plugins:{"rule-tester":{rules:{"validate-ast":{create(){return{Program(e){f=H(e)},"Program:exit"(e){m=e}}}}}}}}),g){if(O.validateSchema(g),O.errors){let t=O.errors.map(e=>`\t${e.dataPath[0]===`.`?e.dataPath.slice(1):e.dataPath}: ${e.message}`).join(`
|
|
3
|
+
`);throw Error([`Schema for rule ${e} is invalid:`,t])}try{O.compile(g)}catch(t){throw Error(`Schema for rule ${e} is invalid: ${t.message}`,{cause:t})}}try{a.normalizeSync(),a.getConfig(`test.js`)}catch(e){throw e.message=`ESLint configuration in rule-tester is invalid: ${e.message}`,e}let{applyLanguageOptions:_,applyInlineConfig:y,finalize:b}=j.prototype,S;try{z.forEach(e=>{j.prototype[e]=oe(e,j.prototype)}),S=o.verify(c,a,l)}finally{j.prototype.applyInlineConfig=y,j.prototype.applyLanguageOptions=_,j.prototype.finalize=b}let w=S.find(e=>e.fatal);if(p(!w,`A fatal parsing error occurred: ${w&&w.message}`),S.some(e=>e.fix)){d=C.applyFixes(c,S).output;let e=o.verify(d,a,l).find(e=>e.fatal);p(!e,[`A fatal parsing error occurred in autofix.`,`Error: ${e&&e.message}`,`Autofix output:`,d].join(`
|
|
4
|
+
`))}else d=c;return{messages:S,output:d,beforeAST:f,afterAST:H(m),configs:a,filename:l}}function m(e,t){y(e,t)||p.fail(`Rule should not modify AST.`)}function h(e,t){if(!ne(e))return;let n=typeof e==`string`?{code:e}:e,r=ee(n,{replacer(e,t){return n!==this||!R.has(e)?t:void 0}});p(!t.has(r),`detected duplicate test case`),t.add(r)}function g(e){let t=typeof e==`object`?e.code:e;p.ok(typeof t==`string`,`Test case must specify a string value for 'code'`),e.name&&p.ok(typeof e.name==`string`,`Optional test case property 'name' must be a string`),h(e,c);let n=f(e),r=n.messages;p.strictEqual(r.length,0,_.format(`Should have no errors but had %d: %s`,r.length,_.inspect(r))),m(n.beforeAST,n.afterAST)}function b(e,t){t instanceof RegExp?p.ok(t.test(e),`Expected '${e}' to match ${t}`):p.strictEqual(e,t)}function S(n){p.ok(typeof n.code==`string`,`Test case must specify a string value for 'code'`),n.name&&p.ok(typeof n.name==`string`,`Optional test case property 'name' must be a string`),p.ok(n.errors||n.errors===0,`Did not specify errors for an invalid test of ${e}`),Array.isArray(n.errors)&&n.errors.length===0&&p.fail(`Invalid cases must have at least one error`),h(n,l);let r=V(t,`meta`)&&V(t.meta,`messages`),i=r?`[${Object.keys(t.meta.messages).map(e=>`'${e}'`).join(`, `)}]`:null,a=f(n),c=a.messages;for(let e of c)if(V(e,`suggestions`)){let t=new Map;for(let n=0;n<e.suggestions.length;n+=1){let r=e.suggestions[n].desc,i=t.get(r);p.ok(!t.has(r),`Suggestion message '${r}' reported from suggestion ${n} was previously reported by suggestion ${i}. Suggestion messages should be unique within an error.`),t.set(r,n)}}if(typeof n.errors==`number`)n.errors===0&&p.fail(`Invalid cases must have 'error' value greater than 0`),p.strictEqual(c.length,n.errors,_.format(`Should have %d error%s but had %d: %s`,n.errors,n.errors===1?``:`s`,c.length,_.inspect(c)));else{p.strictEqual(c.length,n.errors.length,_.format(`Should have %d error%s but had %d: %s`,n.errors.length,n.errors.length===1?``:`s`,c.length,_.inspect(c)));let e=c.some(e=>e.ruleId===s);for(let s=0,l=n.errors.length;s<l;s++){let l=n.errors[s],u=c[s];if(p(e,`Error rule name should be the same as the name of the rule being tested`),typeof l==`string`||l instanceof RegExp)b(u.message,l),p.ok(u.suggestions===void 0,`Error at index ${s} has suggestions. Please convert the test error into an object and specify 'suggestions' property on it to test suggestions.`);else if(typeof l==`object`&&l){if(Object.keys(l).forEach(e=>{p.ok(P.has(e),`Invalid error property name '${e}'. Expected one of ${F}.`)}),V(l,`message`))p.ok(!V(l,`messageId`),`Error should not specify both 'message' and a 'messageId'.`),p.ok(!V(l,`data`),`Error should not specify both 'data' and 'message'.`),b(u.message,l.message);else if(V(l,`messageId`)){p.ok(r,`Error can not use 'messageId' if rule under test doesn't define 'meta.messages'.`),V(t.meta.messages,l.messageId)||p(!1,`Invalid messageId '${l.messageId}'. Expected one of ${i}.`),p.strictEqual(u.messageId,l.messageId,`messageId '${u.messageId}' does not match expected messageId '${l.messageId}'.`);let e=J(u.message,t.meta.messages[u.messageId],l.data);if(p.ok(e.length===0,`The reported message has ${e.length>1?`unsubstituted placeholders: ${e.map(e=>`'${e}'`).join(`, `)}`:`an unsubstituted placeholder '${e[0]}'`}. Please provide the missing ${e.length>1?`values`:`value`} via the 'data' property in the context.report() call.`),V(l,`data`)){let e=t.meta.messages[l.messageId],n=w(e,l.data);p.strictEqual(u.message,n,`Hydrated message "${n}" does not match "${u.message}"`)}}else p.fail(`Test error must specify either a 'messageId' or 'message'.`);l.type&&p.strictEqual(u.nodeType,l.type,`Error type should be ${l.type}, found ${u.nodeType}`);let e={},c={};if(V(l,`line`)&&(e.line=u.line,c.line=l.line),V(l,`column`)&&(e.column=u.column,c.column=l.column),V(l,`endLine`)&&(e.endLine=u.endLine,c.endLine=l.endLine),V(l,`endColumn`)&&(e.endColumn=u.endColumn,c.endColumn=l.endColumn),Object.keys(c).length>0&&p.deepStrictEqual(e,c,`Actual error location does not match expected error location.`),p.ok(!u.suggestions||V(l,`suggestions`),`Error at index ${s} has suggestions. Please specify 'suggestions' property on the test error object.`),V(l,`suggestions`)){let e=Array.isArray(l.suggestions)?l.suggestions.length>0:!!l.suggestions,s=u.suggestions!==void 0;!s&&e?p.ok(!l.suggestions,`Error should have suggestions on error with message: "${u.message}"`):s&&(p.ok(e,`Error should have no suggestions on error with message: "${u.message}"`),typeof l.suggestions==`number`?p.strictEqual(u.suggestions.length,l.suggestions,`Error should have ${l.suggestions} suggestions. Instead found ${u.suggestions.length} suggestions`):Array.isArray(l.suggestions)?(p.strictEqual(u.suggestions.length,l.suggestions.length,`Error should have ${l.suggestions.length} suggestions. Instead found ${u.suggestions.length} suggestions`),l.suggestions.forEach((e,s)=>{p.ok(typeof e==`object`&&!!e,`Test suggestion in 'suggestions' array must be an object.`),Object.keys(e).forEach(e=>{p.ok(I.has(e),`Invalid suggestion property name '${e}'. Expected one of ${L}.`)});let c=u.suggestions[s],l=`Error Suggestion at index ${s}:`;if(V(e,`desc`))p.ok(!V(e,`data`),`${l} Test should not specify both 'desc' and 'data'.`),p.ok(!V(e,`messageId`),`${l} Test should not specify both 'desc' and 'messageId'.`),p.strictEqual(c.desc,e.desc,`${l} desc should be "${e.desc}" but got "${c.desc}" instead.`);else if(V(e,`messageId`)){p.ok(r,`${l} Test can not use 'messageId' if rule under test doesn't define 'meta.messages'.`),p.ok(V(t.meta.messages,e.messageId),`${l} Test has invalid messageId '${e.messageId}', the rule under test allows only one of ${i}.`),p.strictEqual(c.messageId,e.messageId,`${l} messageId should be '${e.messageId}' but got '${c.messageId}' instead.`);let n=J(c.desc,t.meta.messages[e.messageId],e.data);if(p.ok(n.length===0,`The message of the suggestion has ${n.length>1?`unsubstituted placeholders: ${n.map(e=>`'${e}'`).join(`, `)}`:`an unsubstituted placeholder '${n[0]}'`}. Please provide the missing ${n.length>1?`values`:`value`} via the 'data' property for the suggestion in the context.report() call.`),V(e,`data`)){let n=t.meta.messages[e.messageId],r=w(n,e.data);p.strictEqual(c.desc,r,`${l} Hydrated test desc "${r}" does not match received desc "${c.desc}".`)}}else V(e,`data`)?p.fail(`${l} Test must specify 'messageId' if 'data' is used.`):p.fail(`${l} Test must specify either 'messageId' or 'desc'.`);p.ok(V(e,`output`),`${l} The "output" property is required.`);let d=C.applyFixes(n.code,[c]).output,f=o.verify(d,a.configs,a.filename).find(e=>e.fatal);p(!f,[`A fatal parsing error occurred in suggestion fix.`,`Error: ${f&&f.message}`,`Suggestion output:`,d].join(`
|
|
5
|
+
`)),p.strictEqual(d,e.output,`Expected the applied suggestion fix to match the test suggestion output for suggestion at index: ${s} on error with message: "${u.message}"`),p.notStrictEqual(e.output,n.code,`The output of a suggestion should differ from the original source code for suggestion at index: ${s} on error with message: "${u.message}"`)})):p.fail(`Test error object property 'suggestions' should be an array or a number`))}}else p.fail(`Error should be a string, object, or RegExp, but found (${_.inspect(u)})`)}}V(n,`output`)?n.output===null?p.strictEqual(a.output,n.code,`Expected no autofixes to be suggested`):(p.strictEqual(a.output,n.output,`Output is incorrect.`),p.notStrictEqual(n.code,n.output,`Test property 'output' matches 'code'. If no autofix is expected, then omit the 'output' property or set it to null.`)):p.strictEqual(a.output,n.code,`The rule fixed the code. Please add 'output' property.`),m(a.beforeAST,a.afterAST)}this.constructor.describe(e,()=>{n.valid.length>0&&this.constructor.describe(`valid`,()=>{n.valid.forEach(e=>{this.constructor[e.only?`itOnly`:`it`](W(typeof e==`object`?e.name||e.code:e),()=>{try{d(e,`before`),g(e)}finally{d(e,`after`)}})})}),n.invalid.length>0&&this.constructor.describe(`invalid`,()=>{n.invalid.forEach(e=>{this.constructor[e.only?`itOnly`:`it`](W(e.name||e.code),()=>{try{d(e,`before`),S(e)}finally{d(e,`after`)}})})})})}};$[X]=$[Z]=$[Q]=null,u.exports=$})),v=t(((e,t)=>{t.exports={RuleTester:_()}})),y=t(((e,t)=>{let{ESLint:r,shouldUseFlatConfig:i}=u(),{LegacyESLint:a}=p(),{Linter:o}=d(),{RuleTester:s}=v(),{SourceCode:c}=n();async function l({useFlatConfig:e}={}){return e??await i()?r:a}t.exports={Linter:o,loadESLint:l,ESLint:r,RuleTester:s,SourceCode:c}}))(),b=y.ESLint,x=y.Linter,S=y.RuleTester,C=y.SourceCode,w=y.loadESLint;export{b as ESLint,x as Linter,S as RuleTester,C as SourceCode,w as loadESLint};
|