@lexical/eslint-plugin 0.45.1-dev.0 → 0.45.1-nightly.20260531.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,n){for(var t=0;t<n.length;t++){var r=n[t];if("string"!=typeof r&&!Array.isArray(r))for(var i in r)"default"===i||i in e||(e[i]=r[i])}return e}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,r,i={name:"@lexical/eslint-plugin",version:"0.45.1-
|
|
9
|
+
"use strict";function e(e,n){for(var t=0;t<n.length;t++){var r=n[t];if("string"!=typeof r&&!Array.isArray(r))for(var i in r)"default"===i||i in e||(e[i]=r[i])}return e}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,r,i={name:"@lexical/eslint-plugin",version:"0.45.1-nightly.20260531.0"},o={},s={},a={};function l(){return t||(t=1,a.getParentAssignmentName=function(e){const n=e.parent;if(null!=n)return"VariableDeclarator"===n.type&&n.init===e?n.id:"AssignmentExpression"===n.type&&n.right===e&&"="===n.operator?n.left:void 0}),a}function c(){if(r)return s;r=1;const{getParentAssignmentName:e}=l();return s.getFunctionName=function(n){return"FunctionDeclaration"===n.type||"FunctionExpression"===n.type&&n.id?n.id:"FunctionExpression"===n.type||"ArrowFunctionExpression"===n.type?e(n):void 0},s}var u,f,p,d,g={};function x(){if(u)return g;function e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return u=1,g.buildMatcher=function(...n){const t=[],r=[];for(const i of n.flat(1))i&&("string"==typeof i?r.push(/^[(^]/.test(i)?i:`^${e(i)}$`):i&&i instanceof RegExp?i.flags?t.push(e=>i.test(e)):r.push(i.source):"function"==typeof i&&t.push(i));const i=r.map(e=>`(?:${e})`).join("|");if(i){const e=new RegExp(i);t.push(n=>e.test(n))}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}},g}function m(){if(f)return o;f=1;const{getFunctionName:e}=c(),{getParentAssignmentName:n}=l(),{buildMatcher:t}=x();const r={isDollarFunction:[/^\$[a-z_]/],isIgnoredFunction:[],isLexicalProvider:["parseEditorState","read","registerCommand","registerNodeTransform","update"],isSafeDollarFunction:[/^\$is[A-Z_]/]};function i(e){if(e)return"Identifier"===e.type?e:"MemberExpression"!==e.type||e.computed?void 0:i(e.property)}function s(e,n){const t=Array.isArray(e.options)?e.options[0]:void 0;return t&&n in t?t[n]:void 0}const a={oneOf:[{type:"string"},{contains:{type:"string"},type:"array"}]};return o.rulesOfLexical={create(o){const a=function(e){return e.sourceCode?e.sourceCode:e.getSourceCode()}(o),l=function(e){const n={};for(const i in r){const o=i;n[o]=t(r[o],s(e,o))}return n}(o),c=new Set,u=new Set,f=[],p=e=>c.add(e),d=e=>c.delete(e),g=t=>{const r=i(function(t){const r=e(t);if(r)return r;const o=t.parent;if(null!=o&&"CallExpression"===o.type&&o.arguments[0]===t&&function(e){return e&&"Identifier"===e.type&&/^use([A-Z]|$)/.test(e.name)}(i(o.callee)))return n(o)}(t));f.push({name:r,node:t}),(l.isDollarFunction(r)||l.isIgnoredFunction(r)||l.isLexicalProvider(r))&&p(t)},x=e=>{f.pop(),d(e)};return{ArrowFunctionExpression:g,"ArrowFunctionExpression:exit":x,CallExpression:e=>{if((()=>{if(c.size>0)return!0;const e=f[f.length-1];return e&&null!=e.node.parent&&"Property"===e.node.parent.type})())return;const n=i(e.callee);if(l.isLexicalProvider(n)||l.isSafeDollarFunction(n))return void p(e);if(!l.isDollarFunction(n))return;const t=(()=>{const e=f[f.length-1];return e?e.name:void 0})();if(!t||u.has(t))return;u.add(t);const r=function(e,n){const t=e.scopeManager;for(let e=n;e;e=e.parent){const r=t.getDeclaredVariables(e).find(e=>e.identifiers.includes(n));if(r)return r;const i=t.acquire(e);if(i)return i.set.get(n.name)||(i.upper?i.upper.set.get(n.name):void 0)}}(a,t),s=function(e,n){const t=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(n)for(let e=n.scope;e;e=e.upper)if(e.set.has(t))return t+"_";return t}(t,r),d=function(e){if(e&&1===e.defs.length){const n=e.defs[0].node.parent;if(null!=n&&"ExportNamedDeclaration"===n.type)return n;if(null!=n&&"VariableDeclaration"===n.type&&null!=n.parent&&"ExportNamedDeclaration"===n.parent.type)return n.parent}}(r),g={callee:a.getText(e.callee),caller:a.getText(t),suggestName:s},x=e=>{const n=new Set,i=[],o=t=>{n.has(t)||(n.add(t),i.push(e.replaceText(t,s)))};if(o(t),d&&i.push(e.insertTextAfter(d,function({caller:e,suggestName:n}){return`\n/** @deprecated renamed to {@link ${n}} by @lexical/eslint-plugin rules-of-lexical */\nexport const ${e} = ${n};`}(g))),r)for(const e of r.references)o(e.identifier);return i};o.report({data:g,fix:x,messageId:"rulesOfLexicalReport",node:t,suggest:[{data:g,fix:x,messageId:"rulesOfLexicalSuggestion"}]})},"CallExpression:exit":d,ClassBody:p,"ClassBody:exit":d,FunctionDeclaration:g,"FunctionDeclaration:exit":x,FunctionExpression:g,"FunctionExpression:exit":x}},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:a,isIgnoredFunction:a,isLexicalProvider:a,isSafeDollarFunction:a},type:"object"}],type:"suggestion"}},o}function y(){if(d)return p;d=1;const{name:e,version:n}=i,{rulesOfLexical:t}=m(),r={plugins:["@lexical"],rules:{"@lexical/rules-of-lexical":"warn"}},o={configs:{all:r,"flat/all":null,"flat/recommended":null,"legacy-all":r,"legacy-recommended":r,recommended:r},meta:{name:e,version:n},rules:{"rules-of-lexical":t}},s={plugins:{"@lexical":o},rules:{"@lexical/rules-of-lexical":"warn"}};return o.configs["flat/all"]=s,o.configs["flat/recommended"]=s,p=o}var h=y();const v=e({__proto__:null,default:n(h)},[h]);module.exports=v;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
function e(e,n){for(var t=0;t<n.length;t++){var r=n[t];if("string"!=typeof r&&!Array.isArray(r))for(var i in r)"default"===i||i in e||(e[i]=r[i])}return e}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,r,i={name:"@lexical/eslint-plugin",version:"0.45.1-
|
|
9
|
+
function e(e,n){for(var t=0;t<n.length;t++){var r=n[t];if("string"!=typeof r&&!Array.isArray(r))for(var i in r)"default"===i||i in e||(e[i]=r[i])}return e}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,r,i={name:"@lexical/eslint-plugin",version:"0.45.1-nightly.20260531.0"},o={},s={},a={};function l(){return t||(t=1,a.getParentAssignmentName=function(e){const n=e.parent;if(null!=n)return"VariableDeclarator"===n.type&&n.init===e?n.id:"AssignmentExpression"===n.type&&n.right===e&&"="===n.operator?n.left:void 0}),a}function c(){if(r)return s;r=1;const{getParentAssignmentName:e}=l();return s.getFunctionName=function(n){return"FunctionDeclaration"===n.type||"FunctionExpression"===n.type&&n.id?n.id:"FunctionExpression"===n.type||"ArrowFunctionExpression"===n.type?e(n):void 0},s}var u,f,p,d,g={};function x(){if(u)return g;function e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return u=1,g.buildMatcher=function(...n){const t=[],r=[];for(const i of n.flat(1))i&&("string"==typeof i?r.push(/^[(^]/.test(i)?i:`^${e(i)}$`):i&&i instanceof RegExp?i.flags?t.push(e=>i.test(e)):r.push(i.source):"function"==typeof i&&t.push(i));const i=r.map(e=>`(?:${e})`).join("|");if(i){const e=new RegExp(i);t.push(n=>e.test(n))}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}},g}function m(){if(f)return o;f=1;const{getFunctionName:e}=c(),{getParentAssignmentName:n}=l(),{buildMatcher:t}=x();const r={isDollarFunction:[/^\$[a-z_]/],isIgnoredFunction:[],isLexicalProvider:["parseEditorState","read","registerCommand","registerNodeTransform","update"],isSafeDollarFunction:[/^\$is[A-Z_]/]};function i(e){if(e)return"Identifier"===e.type?e:"MemberExpression"!==e.type||e.computed?void 0:i(e.property)}function s(e,n){const t=Array.isArray(e.options)?e.options[0]:void 0;return t&&n in t?t[n]:void 0}const a={oneOf:[{type:"string"},{contains:{type:"string"},type:"array"}]};return o.rulesOfLexical={create(o){const a=function(e){return e.sourceCode?e.sourceCode:e.getSourceCode()}(o),l=function(e){const n={};for(const i in r){const o=i;n[o]=t(r[o],s(e,o))}return n}(o),c=new Set,u=new Set,f=[],p=e=>c.add(e),d=e=>c.delete(e),g=t=>{const r=i(function(t){const r=e(t);if(r)return r;const o=t.parent;if(null!=o&&"CallExpression"===o.type&&o.arguments[0]===t&&function(e){return e&&"Identifier"===e.type&&/^use([A-Z]|$)/.test(e.name)}(i(o.callee)))return n(o)}(t));f.push({name:r,node:t}),(l.isDollarFunction(r)||l.isIgnoredFunction(r)||l.isLexicalProvider(r))&&p(t)},x=e=>{f.pop(),d(e)};return{ArrowFunctionExpression:g,"ArrowFunctionExpression:exit":x,CallExpression:e=>{if((()=>{if(c.size>0)return!0;const e=f[f.length-1];return e&&null!=e.node.parent&&"Property"===e.node.parent.type})())return;const n=i(e.callee);if(l.isLexicalProvider(n)||l.isSafeDollarFunction(n))return void p(e);if(!l.isDollarFunction(n))return;const t=(()=>{const e=f[f.length-1];return e?e.name:void 0})();if(!t||u.has(t))return;u.add(t);const r=function(e,n){const t=e.scopeManager;for(let e=n;e;e=e.parent){const r=t.getDeclaredVariables(e).find(e=>e.identifiers.includes(n));if(r)return r;const i=t.acquire(e);if(i)return i.set.get(n.name)||(i.upper?i.upper.set.get(n.name):void 0)}}(a,t),s=function(e,n){const t=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(n)for(let e=n.scope;e;e=e.upper)if(e.set.has(t))return t+"_";return t}(t,r),d=function(e){if(e&&1===e.defs.length){const n=e.defs[0].node.parent;if(null!=n&&"ExportNamedDeclaration"===n.type)return n;if(null!=n&&"VariableDeclaration"===n.type&&null!=n.parent&&"ExportNamedDeclaration"===n.parent.type)return n.parent}}(r),g={callee:a.getText(e.callee),caller:a.getText(t),suggestName:s},x=e=>{const n=new Set,i=[],o=t=>{n.has(t)||(n.add(t),i.push(e.replaceText(t,s)))};if(o(t),d&&i.push(e.insertTextAfter(d,function({caller:e,suggestName:n}){return`\n/** @deprecated renamed to {@link ${n}} by @lexical/eslint-plugin rules-of-lexical */\nexport const ${e} = ${n};`}(g))),r)for(const e of r.references)o(e.identifier);return i};o.report({data:g,fix:x,messageId:"rulesOfLexicalReport",node:t,suggest:[{data:g,fix:x,messageId:"rulesOfLexicalSuggestion"}]})},"CallExpression:exit":d,ClassBody:p,"ClassBody:exit":d,FunctionDeclaration:g,"FunctionDeclaration:exit":x,FunctionExpression:g,"FunctionExpression:exit":x}},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:a,isIgnoredFunction:a,isLexicalProvider:a,isSafeDollarFunction:a},type:"object"}],type:"suggestion"}},o}function y(){if(d)return p;d=1;const{name:e,version:n}=i,{rulesOfLexical:t}=m(),r={plugins:["@lexical"],rules:{"@lexical/rules-of-lexical":"warn"}},o={configs:{all:r,"flat/all":null,"flat/recommended":null,"legacy-all":r,"legacy-recommended":r,recommended:r},meta:{name:e,version:n},rules:{"rules-of-lexical":t}},s={plugins:{"@lexical":o},rules:{"@lexical/rules-of-lexical":"warn"}};return o.configs["flat/all"]=s,o.configs["flat/recommended"]=s,p=o}var h=y();const v=e({__proto__:null,default:n(h)},[h]);export{v as default};
|