@lexical/eslint-plugin 0.51.1-nightly.20260925.0 → 0.52.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.
@@ -655,10 +655,10 @@ const rulesOfLexical = {
655
655
  * @__NO_SIDE_EFFECTS__
656
656
  */
657
657
  function createMeta() {
658
- // The build replaces "0.51.1-nightly.20260925.0+dev.esm" with a literal such as
658
+ // The build replaces "0.52.0+dev.esm" with a literal such as
659
659
  // '0.50.0+prod.esm'; the build metadata is dropped so that `meta.version`
660
660
  // is the package version, as it was when it was read from package.json.
661
- const version = "0.51.1-nightly.20260925.0+dev.esm";
661
+ const version = "0.52.0+dev.esm";
662
662
  // Not one string literal: the www build rewrites the quoted npm names of
663
663
  // the packages to their www module names (scripts/build.mjs), and
664
664
  // `meta.name` is the npm name there too.
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- const e=new Set(["createDOM","updateDOM","exportDOM","$decorateDOM"]),t={create(t){let n=0;function o(t){return("MethodDefinition"===t.type||"Property"===t.type)&&"Identifier"===t.key.type&&e.has(t.key.name)}function r(e){o(e)&&n++}function i(e){o(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:r,"MethodDefinition:exit":i,Property:r,"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"}};function n(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function o(...e){const t=[],o=[];for(const r of e.flat(1))r&&("string"==typeof r?o.push(/^[(^]/.test(r)?r:`^${n(r)}$`):r&&r instanceof RegExp?r.flags?t.push(e=>r.test(e)):o.push(r.source):"function"==typeof r&&t.push(r));const r=o.map(e=>`(?:${e})`).join("|");if(r){const e=new RegExp(r);t.push(t=>e.test(t))}return e=>{if(e){if("Identifier"!==e.type)throw new Error(`Expecting Identifier, not ${e.type}`);for(const n of t)if(n(e.name,e))return!0}return!1}}function r(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}const i={isDollarFunction:[/^\$[a-z_]/],isIgnoredFunction:[],isLexicalProvider:["parseEditorState","read","registerCommand","registerNodeTransform","update"],isSafeDollarFunction:[/^\$is[A-Z_]/]};function s(e){if(e)return"Identifier"===e.type?e:"MemberExpression"!==e.type||e.computed?void 0:s(e.property)}function a(e,t){const n=Array.isArray(e.options)?e.options[0]:void 0;return n&&t in n?n[t]:void 0}const c={oneOf:[{type:"string"},{contains:{type:"string"},type:"array"}]},l={create(e){const t=function(e){return e.sourceCode?e.sourceCode:e.getSourceCode()}(e),n=function(e){const t={};for(const n in i){const r=n;t[r]=o(i[r],a(e,r))}return t}(e),c=new Set,l=new Set,u=[],p=e=>c.add(e),d=e=>c.delete(e),f=e=>{const t=s(function(e){const t=function(e){return"FunctionDeclaration"===e.type||"FunctionExpression"===e.type&&e.id?e.id:"FunctionExpression"===e.type||"ArrowFunctionExpression"===e.type?r(e):void 0}(e);if(t)return t;const n=e.parent;return null!=n&&"CallExpression"===n.type&&n.arguments[0]===e&&function(e){return e&&"Identifier"===e.type&&/^use([A-Z]|$)/.test(e.name)}(s(n.callee))?r(n):void 0}(e));u.push({name:t,node:e}),(n.isDollarFunction(t)||n.isIgnoredFunction(t)||n.isLexicalProvider(t))&&p(e)},m=e=>{u.pop(),d(e)};return{ArrowFunctionExpression:f,"ArrowFunctionExpression:exit":m,CallExpression:o=>{if((()=>{if(c.size>0)return!0;const e=u[u.length-1];return e&&null!=e.node.parent&&"Property"===e.node.parent.type})())return;const r=s(o.callee);if(n.isLexicalProvider(r)||n.isSafeDollarFunction(r))return void p(o);if(!n.isDollarFunction(r))return;const i=(()=>{const e=u[u.length-1];return e?e.name:void 0})();if(!i||l.has(i))return;l.add(i);const a=function(e,t){const n=e.scopeManager;for(let e=t;e;e=e.parent){const o=n.getDeclaredVariables(e).find(e=>e.identifiers.includes(t));if(o)return o;const r=n.acquire(e);if(r)return r.set.get(t.name)||(r.upper?r.upper.set.get(t.name):void 0)}}(t,i),d=function(e,t){const n=(o=e.name,/^[a-z]/.test(o)?"$"+o:/^[A-Z][a-z]/.test(o)?"$"+o.slice(0,1).toLowerCase()+o.slice(1):`$_${o}`);var o;if(t)for(let e=t.scope;e;e=e.upper)if(e.set.has(n))return n+"_";return n}(i,a),f=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}}(a),m={callee:t.getText(o.callee),caller:t.getText(i),suggestName:d},x=e=>{const t=new Set,n=[],o=o=>{t.has(o)||(t.add(o),n.push(e.replaceText(o,d)))};if(o(i),f&&n.push(e.insertTextAfter(f,function({caller:e,suggestName:t}){return`\n/** @deprecated renamed to {@link ${t}} by @lexical/eslint-plugin rules-of-lexical */\nexport const ${e} = ${t};`}(m))),a)for(const e of a.references)o(e.identifier);return n};e.report({data:m,fix:x,messageId:"rulesOfLexicalReport",node:i,suggest:[{data:m,fix:x,messageId:"rulesOfLexicalSuggestion"}]})},"CallExpression:exit":d,ClassBody:p,"ClassBody:exit":d,FunctionDeclaration:f,"FunctionDeclaration:exit":m,FunctionExpression:f,"FunctionExpression:exit":m}},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:c,isIgnoredFunction:c,isLexicalProvider:c,isSafeDollarFunction:c},type:"object"}],type:"suggestion"}};function u(){return{name:["@lexical","eslint-plugin"].join("/"),version:"0.51.1-nightly.20260925.0+prod.esm".replace(/\+.*$/,"")}}function p(e,t){const n={configs:{},meta:e,rules:t},o={plugins:{"@lexical":n},rules:{"@lexical/rules-of-lexical":"warn"}},r={all:o,"flat/all":o,"flat/recommended":o,recommended:o};return n.configs=r,r}const d=/* @__PURE__ */u(),f={"no-document-in-dom-methods":t,"rules-of-lexical":l},m=/* @__PURE__ */p(d,f),x={configs:m,meta:d,rules:f};export{m as configs,x as default,d as meta,f as rules};
9
+ const e=new Set(["createDOM","updateDOM","exportDOM","$decorateDOM"]),t={create(t){let n=0;function o(t){return("MethodDefinition"===t.type||"Property"===t.type)&&"Identifier"===t.key.type&&e.has(t.key.name)}function r(e){o(e)&&n++}function i(e){o(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:r,"MethodDefinition:exit":i,Property:r,"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"}};function n(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function o(...e){const t=[],o=[];for(const r of e.flat(1))r&&("string"==typeof r?o.push(/^[(^]/.test(r)?r:`^${n(r)}$`):r&&r instanceof RegExp?r.flags?t.push(e=>r.test(e)):o.push(r.source):"function"==typeof r&&t.push(r));const r=o.map(e=>`(?:${e})`).join("|");if(r){const e=new RegExp(r);t.push(t=>e.test(t))}return e=>{if(e){if("Identifier"!==e.type)throw new Error(`Expecting Identifier, not ${e.type}`);for(const n of t)if(n(e.name,e))return!0}return!1}}function r(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}const i={isDollarFunction:[/^\$[a-z_]/],isIgnoredFunction:[],isLexicalProvider:["parseEditorState","read","registerCommand","registerNodeTransform","update"],isSafeDollarFunction:[/^\$is[A-Z_]/]};function s(e){if(e)return"Identifier"===e.type?e:"MemberExpression"!==e.type||e.computed?void 0:s(e.property)}function a(e,t){const n=Array.isArray(e.options)?e.options[0]:void 0;return n&&t in n?n[t]:void 0}const c={oneOf:[{type:"string"},{contains:{type:"string"},type:"array"}]},l={create(e){const t=function(e){return e.sourceCode?e.sourceCode:e.getSourceCode()}(e),n=function(e){const t={};for(const n in i){const r=n;t[r]=o(i[r],a(e,r))}return t}(e),c=new Set,l=new Set,u=[],p=e=>c.add(e),d=e=>c.delete(e),f=e=>{const t=s(function(e){const t=function(e){return"FunctionDeclaration"===e.type||"FunctionExpression"===e.type&&e.id?e.id:"FunctionExpression"===e.type||"ArrowFunctionExpression"===e.type?r(e):void 0}(e);if(t)return t;const n=e.parent;return null!=n&&"CallExpression"===n.type&&n.arguments[0]===e&&function(e){return e&&"Identifier"===e.type&&/^use([A-Z]|$)/.test(e.name)}(s(n.callee))?r(n):void 0}(e));u.push({name:t,node:e}),(n.isDollarFunction(t)||n.isIgnoredFunction(t)||n.isLexicalProvider(t))&&p(e)},m=e=>{u.pop(),d(e)};return{ArrowFunctionExpression:f,"ArrowFunctionExpression:exit":m,CallExpression:o=>{if((()=>{if(c.size>0)return!0;const e=u[u.length-1];return e&&null!=e.node.parent&&"Property"===e.node.parent.type})())return;const r=s(o.callee);if(n.isLexicalProvider(r)||n.isSafeDollarFunction(r))return void p(o);if(!n.isDollarFunction(r))return;const i=(()=>{const e=u[u.length-1];return e?e.name:void 0})();if(!i||l.has(i))return;l.add(i);const a=function(e,t){const n=e.scopeManager;for(let e=t;e;e=e.parent){const o=n.getDeclaredVariables(e).find(e=>e.identifiers.includes(t));if(o)return o;const r=n.acquire(e);if(r)return r.set.get(t.name)||(r.upper?r.upper.set.get(t.name):void 0)}}(t,i),d=function(e,t){const n=(o=e.name,/^[a-z]/.test(o)?"$"+o:/^[A-Z][a-z]/.test(o)?"$"+o.slice(0,1).toLowerCase()+o.slice(1):`$_${o}`);var o;if(t)for(let e=t.scope;e;e=e.upper)if(e.set.has(n))return n+"_";return n}(i,a),f=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}}(a),m={callee:t.getText(o.callee),caller:t.getText(i),suggestName:d},x=e=>{const t=new Set,n=[],o=o=>{t.has(o)||(t.add(o),n.push(e.replaceText(o,d)))};if(o(i),f&&n.push(e.insertTextAfter(f,function({caller:e,suggestName:t}){return`\n/** @deprecated renamed to {@link ${t}} by @lexical/eslint-plugin rules-of-lexical */\nexport const ${e} = ${t};`}(m))),a)for(const e of a.references)o(e.identifier);return n};e.report({data:m,fix:x,messageId:"rulesOfLexicalReport",node:i,suggest:[{data:m,fix:x,messageId:"rulesOfLexicalSuggestion"}]})},"CallExpression:exit":d,ClassBody:p,"ClassBody:exit":d,FunctionDeclaration:f,"FunctionDeclaration:exit":m,FunctionExpression:f,"FunctionExpression:exit":m}},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:c,isIgnoredFunction:c,isLexicalProvider:c,isSafeDollarFunction:c},type:"object"}],type:"suggestion"}};function u(){return{name:["@lexical","eslint-plugin"].join("/"),version:"0.52.0+prod.esm".replace(/\+.*$/,"")}}function p(e,t){const n={configs:{},meta:e,rules:t},o={plugins:{"@lexical":n},rules:{"@lexical/rules-of-lexical":"warn"}},r={all:o,"flat/all":o,"flat/recommended":o,recommended:o};return n.configs=r,r}const d=/* @__PURE__ */u(),f={"no-document-in-dom-methods":t,"rules-of-lexical":l},m=/* @__PURE__ */p(d,f),x={configs:m,meta:d,rules:f};export{m as configs,x as default,d as meta,f as rules};
package/dist/version.d.ts CHANGED
@@ -11,4 +11,4 @@
11
11
  * version by scripts/updateVersion.mjs (`pnpm run update-version`); the
12
12
  * published build replaces `process.env.LEXICAL_VERSION` instead.
13
13
  */
14
- export const SOURCE_VERSION: "0.51.1-nightly.20260925.0+source";
14
+ export const SOURCE_VERSION: "0.52.0+source";
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "lexical",
9
9
  "editor"
10
10
  ],
11
- "version": "0.51.1-nightly.20260925.0",
11
+ "version": "0.52.0",
12
12
  "license": "MIT",
13
13
  "repository": {
14
14
  "type": "git",
package/src/version.js CHANGED
@@ -14,4 +14,4 @@
14
14
  * version by scripts/updateVersion.mjs (`pnpm run update-version`); the
15
15
  * published build replaces `process.env.LEXICAL_VERSION` instead.
16
16
  */
17
- export const SOURCE_VERSION = '0.51.1-nightly.20260925.0+source';
17
+ export const SOURCE_VERSION = '0.52.0+source';