@lexical/eslint-plugin 0.51.0 → 0.51.1-nightly.20260918.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.0+dev.esm" with a literal such as
|
|
658
|
+
// The build replaces "0.51.1-nightly.20260918.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.0+dev.esm";
|
|
661
|
+
const version = "0.51.1-nightly.20260918.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){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;if(null!=n&&"CallExpression"===n.type&&n.arguments[0]===e){if(function(e){return e&&"Identifier"===e.type&&/^use([A-Z]|$)/.test(e.name)}(s(n.callee)))return r(n)}}function c(e,t){const n=Array.isArray(e.options)?e.options[0]:void 0;return n&&t in n?n[t]:void 0}const l={oneOf:[{type:"string"},{contains:{type:"string"},type:"array"}]},u={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],c(e,r))}return t}(e),r=new Set,l=new Set,u=[],p=e=>r.add(e),d=e=>r.delete(e),f=e=>{const t=s(a(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(r.size>0)return!0;const e=u[u.length-1];return e&&null!=e.node.parent&&"Property"===e.node.parent.type})())return;const i=s(o.callee);if(n.isLexicalProvider(i)||n.isSafeDollarFunction(i))return void p(o);if(!n.isDollarFunction(i))return;const a=(()=>{const e=u[u.length-1];return e?e.name:void 0})();if(!a||l.has(a))return;l.add(a);const c=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,a),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}(a,c),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}}(c),m={callee:t.getText(o.callee),caller:t.getText(a),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(a),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))),c)for(const e of c.references)o(e.identifier);return n};e.report({data:m,fix:x,messageId:"rulesOfLexicalReport",node:a,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:l,isIgnoredFunction:l,isLexicalProvider:l,isSafeDollarFunction:l},type:"object"}],type:"suggestion"}};function p(){return{name:["@lexical","eslint-plugin"].join("/"),version:"0.51.0+prod.esm".replace(/\+.*$/,"")}}function d(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 f=/* @__PURE__ */p(),m={"no-document-in-dom-methods":t,"rules-of-lexical":u},x=/* @__PURE__ */d(f,m),g={configs:x,meta:f,rules:m};export{x as configs,g as default,f as meta,m 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){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;if(null!=n&&"CallExpression"===n.type&&n.arguments[0]===e){if(function(e){return e&&"Identifier"===e.type&&/^use([A-Z]|$)/.test(e.name)}(s(n.callee)))return r(n)}}function c(e,t){const n=Array.isArray(e.options)?e.options[0]:void 0;return n&&t in n?n[t]:void 0}const l={oneOf:[{type:"string"},{contains:{type:"string"},type:"array"}]},u={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],c(e,r))}return t}(e),r=new Set,l=new Set,u=[],p=e=>r.add(e),d=e=>r.delete(e),f=e=>{const t=s(a(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(r.size>0)return!0;const e=u[u.length-1];return e&&null!=e.node.parent&&"Property"===e.node.parent.type})())return;const i=s(o.callee);if(n.isLexicalProvider(i)||n.isSafeDollarFunction(i))return void p(o);if(!n.isDollarFunction(i))return;const a=(()=>{const e=u[u.length-1];return e?e.name:void 0})();if(!a||l.has(a))return;l.add(a);const c=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,a),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}(a,c),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}}(c),m={callee:t.getText(o.callee),caller:t.getText(a),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(a),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))),c)for(const e of c.references)o(e.identifier);return n};e.report({data:m,fix:x,messageId:"rulesOfLexicalReport",node:a,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:l,isIgnoredFunction:l,isLexicalProvider:l,isSafeDollarFunction:l},type:"object"}],type:"suggestion"}};function p(){return{name:["@lexical","eslint-plugin"].join("/"),version:"0.51.1-nightly.20260918.0+prod.esm".replace(/\+.*$/,"")}}function d(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 f=/* @__PURE__ */p(),m={"no-document-in-dom-methods":t,"rules-of-lexical":u},x=/* @__PURE__ */d(f,m),g={configs:x,meta:f,rules:m};export{x as configs,g as default,f as meta,m as rules};
|
package/dist/version.d.ts
CHANGED
package/package.json
CHANGED
package/src/version.js
CHANGED