@lexical/eslint-plugin 0.47.1-nightly.20260715.0 → 0.48.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.
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(var o in r)"default"===o||o in e||(e[o]=r[o])}return e}function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,r={name:"@lexical/eslint-plugin",version:"0.
|
|
9
|
+
"use strict";function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(var o in r)"default"===o||o in e||(e[o]=r[o])}return e}function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,r={name:"@lexical/eslint-plugin",version:"0.48.0"},o={};function i(){if(n)return o;n=1;const e=new Set(["createDOM","updateDOM","exportDOM","$decorateDOM"]);return o.noDocumentInDomMethods={create(t){let n=0;function r(t){return("MethodDefinition"===t.type||"Property"===t.type)&&"Identifier"===t.key.type&&e.has(t.key.name)}function o(e){r(e)&&n++}function i(e){r(e)&&n--}return{MemberExpression(e){n>0&&"Identifier"===e.object.type&&"document"===e.object.name&&t.report({fix:t=>t.replaceText(e.object,"$getDocument()"),messageId:"noDocumentInDomMethods",node:e.object})},MethodDefinition:o,"MethodDefinition:exit":i,Property:o,"Property:exit":i}},meta:{docs:{description:"Disallow bare `document` global inside createDOM/updateDOM/exportDOM/$decorateDOM (class methods and object properties) and provide an autofix to $getDocument()",recommended:!0,url:"https://lexical.dev/docs/concepts/shadow-dom"},fixable:"code",messages:{noDocumentInDomMethods:"Use $getDocument() instead of `document` inside DOM methods for Shadow DOM / iframe safety. Note: autofix replaces the identifier but does not add the import."},schema:[],type:"problem"}},o}var s,a,c={},l={},u={};function d(){return s||(s=1,u.getParentAssignmentName=function(e){const t=e.parent;if(null!=t)return"VariableDeclarator"===t.type&&t.init===e?t.id:"AssignmentExpression"===t.type&&t.right===e&&"="===t.operator?t.left:void 0}),u}function f(){if(a)return l;a=1;const{getParentAssignmentName:e}=/*@__PURE__*/d();return l.getFunctionName=function(t){return"FunctionDeclaration"===t.type||"FunctionExpression"===t.type&&t.id?t.id:"FunctionExpression"===t.type||"ArrowFunctionExpression"===t.type?e(t):void 0},l}var p,m,g,x,y={};function h(){if(p)return y;function e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return p=1,y.buildMatcher=function(...t){const n=[],r=[];for(const o of t.flat(1))o&&("string"==typeof o?r.push(/^[(^]/.test(o)?o:`^${e(o)}$`):o&&o instanceof RegExp?o.flags?n.push(e=>o.test(e)):r.push(o.source):"function"==typeof o&&n.push(o));const o=r.map(e=>`(?:${e})`).join("|");if(o){const e=new RegExp(o);n.push(t=>e.test(t))}return e=>{if(e){if("Identifier"!==e.type)throw new Error(`Expecting Identifier, not ${e.type}`);for(const t of n)if(t(e.name,e))return!0}return!1}},y}function D(){if(m)return c;m=1;const{getFunctionName:e}=/*@__PURE__*/f(),{getParentAssignmentName:t}=/*@__PURE__*/d(),{buildMatcher:n}=/*@__PURE__*/h();const r={isDollarFunction:[/^\$[a-z_]/],isIgnoredFunction:[],isLexicalProvider:["parseEditorState","read","registerCommand","registerNodeTransform","update"],isSafeDollarFunction:[/^\$is[A-Z_]/]};function o(e){if(e)return"Identifier"===e.type?e:"MemberExpression"!==e.type||e.computed?void 0:o(e.property)}function i(e,t){const n=Array.isArray(e.options)?e.options[0]:void 0;return n&&t in n?n[t]:void 0}const s={oneOf:[{type:"string"},{contains:{type:"string"},type:"array"}]};return c.rulesOfLexical={create(s){const a=function(e){return e.sourceCode?e.sourceCode:e.getSourceCode()}(s),c=function(e){const t={};for(const o in r){const s=o;t[s]=n(r[s],i(e,s))}return t}(s),l=new Set,u=new Set,d=[],f=e=>l.add(e),p=e=>l.delete(e),m=n=>{const r=o(function(n){const r=e(n);if(r)return r;const i=n.parent;if(null!=i&&"CallExpression"===i.type&&i.arguments[0]===n&&function(e){return e&&"Identifier"===e.type&&/^use([A-Z]|$)/.test(e.name)}(o(i.callee)))return t(i)}(n));d.push({name:r,node:n}),(c.isDollarFunction(r)||c.isIgnoredFunction(r)||c.isLexicalProvider(r))&&f(n)},g=e=>{d.pop(),p(e)};return{ArrowFunctionExpression:m,"ArrowFunctionExpression:exit":g,CallExpression:e=>{if((()=>{if(l.size>0)return!0;const e=d[d.length-1];return e&&null!=e.node.parent&&"Property"===e.node.parent.type})())return;const t=o(e.callee);if(c.isLexicalProvider(t)||c.isSafeDollarFunction(t))return void f(e);if(!c.isDollarFunction(t))return;const n=(()=>{const e=d[d.length-1];return e?e.name:void 0})();if(!n||u.has(n))return;u.add(n);const r=function(e,t){const n=e.scopeManager;for(let e=t;e;e=e.parent){const r=n.getDeclaredVariables(e).find(e=>e.identifiers.includes(t));if(r)return r;const o=n.acquire(e);if(o)return o.set.get(t.name)||(o.upper?o.upper.set.get(t.name):void 0)}}(a,n),i=function(e,t){const n=function(e){return/^[a-z]/.test(e)?"$"+e:/^[A-Z][a-z]/.test(e)?"$"+e.slice(0,1).toLowerCase()+e.slice(1):`$_${e}`}(e.name);if(t)for(let e=t.scope;e;e=e.upper)if(e.set.has(n))return n+"_";return n}(n,r),p=function(e){if(e&&1===e.defs.length){const t=e.defs[0].node.parent;if(null!=t&&"ExportNamedDeclaration"===t.type)return t;if(null!=t&&"VariableDeclaration"===t.type&&null!=t.parent&&"ExportNamedDeclaration"===t.parent.type)return t.parent}}(r),m={callee:a.getText(e.callee),caller:a.getText(n),suggestName:i},g=e=>{const t=new Set,o=[],s=n=>{t.has(n)||(t.add(n),o.push(e.replaceText(n,i)))};if(s(n),p&&o.push(e.insertTextAfter(p,function({caller:e,suggestName:t}){return`\n/** @deprecated renamed to {@link ${t}} by @lexical/eslint-plugin rules-of-lexical */\nexport const ${e} = ${t};`}(m))),r)for(const e of r.references)s(e.identifier);return o};s.report({data:m,fix:g,messageId:"rulesOfLexicalReport",node:n,suggest:[{data:m,fix:g,messageId:"rulesOfLexicalSuggestion"}]})},"CallExpression:exit":p,ClassBody:f,"ClassBody:exit":p,FunctionDeclaration:m,"FunctionDeclaration:exit":g,FunctionExpression:m,"FunctionExpression:exit":g}},meta:{docs:{description:"enforces the Rules of Lexical",recommended:!0,url:"https://lexical.dev/docs/packages/lexical-eslint-plugin"},fixable:"code",hasSuggestions:!0,messages:{rulesOfLexicalReport:"{{ callee }} called from {{ caller }}, without $ prefix or read/update context",rulesOfLexicalSuggestion:"Rename {{ caller }} to {{ suggestName }}"},schema:[{additionalProperties:!1,properties:{isDollarFunction:s,isIgnoredFunction:s,isLexicalProvider:s,isSafeDollarFunction:s},type:"object"}],type:"suggestion"}},c}function v(){if(x)return g;x=1;const{name:e,version:t}=r,{noDocumentInDomMethods:n}=/*@__PURE__*/i(),{rulesOfLexical:o}=/*@__PURE__*/D(),s={plugins:["@lexical"],rules:{"@lexical/rules-of-lexical":"warn"}},a={configs:{all:s,"flat/all":null,"flat/recommended":null,"legacy-all":s,"legacy-recommended":s,recommended:s},meta:{name:e,version:t},rules:{"no-document-in-dom-methods":n,"rules-of-lexical":o}},c={plugins:{"@lexical":a},rules:{"@lexical/rules-of-lexical":"warn"}};return a.configs["flat/all"]=c,a.configs["flat/recommended"]=c,g=a}var M=/*@__PURE__*/v();const F=/*#__PURE__*/e({__proto__:null,default:/*@__PURE__*/t(M)},[M]);module.exports=F;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(var o in r)"default"===o||o in e||(e[o]=r[o])}return e}function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,r={name:"@lexical/eslint-plugin",version:"0.
|
|
9
|
+
function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(var o in r)"default"===o||o in e||(e[o]=r[o])}return e}function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,r={name:"@lexical/eslint-plugin",version:"0.48.0"},o={};function i(){if(n)return o;n=1;const e=new Set(["createDOM","updateDOM","exportDOM","$decorateDOM"]);return o.noDocumentInDomMethods={create(t){let n=0;function r(t){return("MethodDefinition"===t.type||"Property"===t.type)&&"Identifier"===t.key.type&&e.has(t.key.name)}function o(e){r(e)&&n++}function i(e){r(e)&&n--}return{MemberExpression(e){n>0&&"Identifier"===e.object.type&&"document"===e.object.name&&t.report({fix:t=>t.replaceText(e.object,"$getDocument()"),messageId:"noDocumentInDomMethods",node:e.object})},MethodDefinition:o,"MethodDefinition:exit":i,Property:o,"Property:exit":i}},meta:{docs:{description:"Disallow bare `document` global inside createDOM/updateDOM/exportDOM/$decorateDOM (class methods and object properties) and provide an autofix to $getDocument()",recommended:!0,url:"https://lexical.dev/docs/concepts/shadow-dom"},fixable:"code",messages:{noDocumentInDomMethods:"Use $getDocument() instead of `document` inside DOM methods for Shadow DOM / iframe safety. Note: autofix replaces the identifier but does not add the import."},schema:[],type:"problem"}},o}var s,a,c={},l={},u={};function d(){return s||(s=1,u.getParentAssignmentName=function(e){const t=e.parent;if(null!=t)return"VariableDeclarator"===t.type&&t.init===e?t.id:"AssignmentExpression"===t.type&&t.right===e&&"="===t.operator?t.left:void 0}),u}function f(){if(a)return l;a=1;const{getParentAssignmentName:e}=/*@__PURE__*/d();return l.getFunctionName=function(t){return"FunctionDeclaration"===t.type||"FunctionExpression"===t.type&&t.id?t.id:"FunctionExpression"===t.type||"ArrowFunctionExpression"===t.type?e(t):void 0},l}var p,m,g,x,y={};function h(){if(p)return y;function e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return p=1,y.buildMatcher=function(...t){const n=[],r=[];for(const o of t.flat(1))o&&("string"==typeof o?r.push(/^[(^]/.test(o)?o:`^${e(o)}$`):o&&o instanceof RegExp?o.flags?n.push(e=>o.test(e)):r.push(o.source):"function"==typeof o&&n.push(o));const o=r.map(e=>`(?:${e})`).join("|");if(o){const e=new RegExp(o);n.push(t=>e.test(t))}return e=>{if(e){if("Identifier"!==e.type)throw new Error(`Expecting Identifier, not ${e.type}`);for(const t of n)if(t(e.name,e))return!0}return!1}},y}function D(){if(m)return c;m=1;const{getFunctionName:e}=/*@__PURE__*/f(),{getParentAssignmentName:t}=/*@__PURE__*/d(),{buildMatcher:n}=/*@__PURE__*/h();const r={isDollarFunction:[/^\$[a-z_]/],isIgnoredFunction:[],isLexicalProvider:["parseEditorState","read","registerCommand","registerNodeTransform","update"],isSafeDollarFunction:[/^\$is[A-Z_]/]};function o(e){if(e)return"Identifier"===e.type?e:"MemberExpression"!==e.type||e.computed?void 0:o(e.property)}function i(e,t){const n=Array.isArray(e.options)?e.options[0]:void 0;return n&&t in n?n[t]:void 0}const s={oneOf:[{type:"string"},{contains:{type:"string"},type:"array"}]};return c.rulesOfLexical={create(s){const a=function(e){return e.sourceCode?e.sourceCode:e.getSourceCode()}(s),c=function(e){const t={};for(const o in r){const s=o;t[s]=n(r[s],i(e,s))}return t}(s),l=new Set,u=new Set,d=[],f=e=>l.add(e),p=e=>l.delete(e),m=n=>{const r=o(function(n){const r=e(n);if(r)return r;const i=n.parent;if(null!=i&&"CallExpression"===i.type&&i.arguments[0]===n&&function(e){return e&&"Identifier"===e.type&&/^use([A-Z]|$)/.test(e.name)}(o(i.callee)))return t(i)}(n));d.push({name:r,node:n}),(c.isDollarFunction(r)||c.isIgnoredFunction(r)||c.isLexicalProvider(r))&&f(n)},g=e=>{d.pop(),p(e)};return{ArrowFunctionExpression:m,"ArrowFunctionExpression:exit":g,CallExpression:e=>{if((()=>{if(l.size>0)return!0;const e=d[d.length-1];return e&&null!=e.node.parent&&"Property"===e.node.parent.type})())return;const t=o(e.callee);if(c.isLexicalProvider(t)||c.isSafeDollarFunction(t))return void f(e);if(!c.isDollarFunction(t))return;const n=(()=>{const e=d[d.length-1];return e?e.name:void 0})();if(!n||u.has(n))return;u.add(n);const r=function(e,t){const n=e.scopeManager;for(let e=t;e;e=e.parent){const r=n.getDeclaredVariables(e).find(e=>e.identifiers.includes(t));if(r)return r;const o=n.acquire(e);if(o)return o.set.get(t.name)||(o.upper?o.upper.set.get(t.name):void 0)}}(a,n),i=function(e,t){const n=function(e){return/^[a-z]/.test(e)?"$"+e:/^[A-Z][a-z]/.test(e)?"$"+e.slice(0,1).toLowerCase()+e.slice(1):`$_${e}`}(e.name);if(t)for(let e=t.scope;e;e=e.upper)if(e.set.has(n))return n+"_";return n}(n,r),p=function(e){if(e&&1===e.defs.length){const t=e.defs[0].node.parent;if(null!=t&&"ExportNamedDeclaration"===t.type)return t;if(null!=t&&"VariableDeclaration"===t.type&&null!=t.parent&&"ExportNamedDeclaration"===t.parent.type)return t.parent}}(r),m={callee:a.getText(e.callee),caller:a.getText(n),suggestName:i},g=e=>{const t=new Set,o=[],s=n=>{t.has(n)||(t.add(n),o.push(e.replaceText(n,i)))};if(s(n),p&&o.push(e.insertTextAfter(p,function({caller:e,suggestName:t}){return`\n/** @deprecated renamed to {@link ${t}} by @lexical/eslint-plugin rules-of-lexical */\nexport const ${e} = ${t};`}(m))),r)for(const e of r.references)s(e.identifier);return o};s.report({data:m,fix:g,messageId:"rulesOfLexicalReport",node:n,suggest:[{data:m,fix:g,messageId:"rulesOfLexicalSuggestion"}]})},"CallExpression:exit":p,ClassBody:f,"ClassBody:exit":p,FunctionDeclaration:m,"FunctionDeclaration:exit":g,FunctionExpression:m,"FunctionExpression:exit":g}},meta:{docs:{description:"enforces the Rules of Lexical",recommended:!0,url:"https://lexical.dev/docs/packages/lexical-eslint-plugin"},fixable:"code",hasSuggestions:!0,messages:{rulesOfLexicalReport:"{{ callee }} called from {{ caller }}, without $ prefix or read/update context",rulesOfLexicalSuggestion:"Rename {{ caller }} to {{ suggestName }}"},schema:[{additionalProperties:!1,properties:{isDollarFunction:s,isIgnoredFunction:s,isLexicalProvider:s,isSafeDollarFunction:s},type:"object"}],type:"suggestion"}},c}function v(){if(x)return g;x=1;const{name:e,version:t}=r,{noDocumentInDomMethods:n}=/*@__PURE__*/i(),{rulesOfLexical:o}=/*@__PURE__*/D(),s={plugins:["@lexical"],rules:{"@lexical/rules-of-lexical":"warn"}},a={configs:{all:s,"flat/all":null,"flat/recommended":null,"legacy-all":s,"legacy-recommended":s,recommended:s},meta:{name:e,version:t},rules:{"no-document-in-dom-methods":n,"rules-of-lexical":o}},c={plugins:{"@lexical":a},rules:{"@lexical/rules-of-lexical":"warn"}};return a.configs["flat/all"]=c,a.configs["flat/recommended"]=c,g=a}var M=/*@__PURE__*/v();const F=/*#__PURE__*/e({__proto__:null,default:/*@__PURE__*/t(M)},[M]);export{F as default};
|