@yafh/eslint-plugin
Advanced tools
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _types = require('@typescript-eslint/types');var _utils = require('@typescript-eslint/utils');var r=_utils.ESLintUtils.RuleCreator(e=>e);function l(e,t){let o=e.source.value;return t instanceof RegExp?t.test(o):typeof t=="string"?o.startsWith(t):t.some(s=>o.startsWith(s))}function u(e,t){let o=e.source.value;return t.test(o)}function f(e){return e.type===_types.AST_NODE_TYPES.ImportSpecifier&&(e.imported.range[0]!==e.local.range[0]||e.imported.range[1]!==e.local.range[1])}var T="icon-component-prefix",d=r({name:T,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[{type:["string","array"],description:"Icon Component source matcher"},{type:["string"],description:"prefix"}],messages:{missingIconComponentPrefix:"Expect icon component prefix '{{prefix}}'"}},defaultOptions:[["@ricons","@vicons","@v2icons","@sicons"],"Icon"],create:(e,t)=>({ImportDeclaration(o){let[s,i]=t;if(l(o,s))for(let n of o.specifiers)n.local.name.startsWith(i)||e.report({loc:n.loc,messageId:"missingIconComponentPrefix",data:{prefix:i},fix(m){let c=RegExp(`^${i}`,"i").test(n.local.name),a=i+(c?n.local.name.substring(i.length):n.local.name);return n.type===_types.AST_NODE_TYPES.ImportSpecifier&&!f(n)&&(a=`${n.local.name} as ${a}`),m.replaceText(n.local,a)}})}})});var _path = require('path');var E="no-index-vue",g=r({name:E,meta:{type:"problem",docs:{description:"",recommended:"recommended"},schema:[],messages:{noIndexVue:"Do not use index.vue"}},defaultOptions:[],create:e=>({Program(){_path.basename.call(void 0, e.getFilename()).toLocaleLowerCase()==="index.vue"&&e.report({loc:{line:1,column:0},messageId:"noIndexVue"})}})});var v="no-multiple-slash-comment";function b(e){return e.type!==_utils.AST_TOKEN_TYPES.Line?!1:/^\/\s*<(amd-module|amd-dependency|reference){1}.*\/>\s*$/.test(e.value)}var x=r({name:v,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[],messages:{noMultipleSlashComment:"Do not use multiple slashes for single line comments."}},defaultOptions:[],create:e=>{let t=e.getSourceCode();return{Program(){t.getAllComments().filter(o=>o.type==="Line").filter(o=>!b(o)).filter(o=>/^\/+/.test(o.value)).forEach(o=>{e.report({node:o,messageId:"noMultipleSlashComment",fix:s=>s.replaceText(o,`//${o.value.replace(/^\/+/,"")}`)})})}}}});var _pascalcase = require('pascal-case');var N="pascal-case-component-name",C=r({name:N,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},schema:[],messages:{missingPascalCaseComponentName:"Vue component name must be PascalCase. e.g. {{pascalCase}}"}},defaultOptions:[],create:e=>({Program(){let t=_path.basename.call(void 0, e.getFilename());if(!t.endsWith(".vue"))return;let o=t.split(".")[0],s=_pascalcase.pascalCase.call(void 0, o,{transform:_pascalcase.pascalCaseTransformMerge});o!==s&&e.report({loc:{line:1,column:0},messageId:"missingPascalCaseComponentName",data:{pascalCase:s+t.slice(o.length)}})}})});var j="no-cjs-icon-component",L=/^@(r|v|v2)icons/i;function A(e){var c;let[t,o,s,...i]=e.split("/"),n=o!=="utils"&&!["es","",void 0].includes((c=s==null?void 0:s.trim())==null?void 0:c.toLocaleLowerCase());return{org:t,iconSet:o,isUtil:o==="utils",shouldFix:n,fixSource:()=>{var p;if(!n)return e;let a=[t,o,"es"];return((p=s==null?void 0:s.trim())==null?void 0:p.toLocaleLowerCase())!=="lib"&&a.push(s),a.push(...i),a.join("/")}}}var I=r({name:j,meta:{type:"problem",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[],messages:{noCjsIconCompnoent:"Do not import icon components maybe cjs."}},defaultOptions:[],create:e=>({ImportDeclaration(t){if(!u(t,L))return;let{shouldFix:o,fixSource:s}=A(t.source.value);o&&e.report({messageId:"noCjsIconCompnoent",node:t,fix(i){return i.replaceText(t.source,`'${s()}'`)}})}})});var ne={rules:{"icon-component-prefix":d,"no-index-vue":g,"no-multiple-slash-comment":x,"pascal-case-component-name":C,"no-cjs-icon-component":I},configs:{recommended:{plugins:["@yafh"],rules:{"@yafh/icon-component-prefix":"error","@yafh/no-cjs-icon-component":"error","@yafh/no-multiple-slash-comment":"error","@yafh/no-index-vue":"error","@yafh/pascal-case-component-name":"error"}}}};exports.default = ne; | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _types = require('@typescript-eslint/types');var _utils = require('@typescript-eslint/utils');var i=_utils.ESLintUtils.RuleCreator(o=>o);function c(o){return o.toLowerCase().trim()}function u(o,t){let e=c(o.source.value);return typeof t=="string"?e===t:t.some(r=>e.startsWith(c(r)))}function f(o,t){let e=c(o.source.value);return typeof t=="string"?e.startsWith(c(t)):t.some(r=>e.startsWith(c(r)))}function d(o,t){let e=o.source.value;return t.test(e)}function g(o){return o.type===_types.AST_NODE_TYPES.ImportSpecifier&&(o.imported.range[0]!==o.local.range[0]||o.imported.range[1]!==o.local.range[1])}var E="icon-component-prefix",x=i({name:E,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[{type:["string","array"],description:"Icon Component source matcher"},{type:["string"],description:"prefix"}],messages:{missingIconComponentPrefix:"Expect icon component prefix '{{prefix}}'"}},defaultOptions:[["@ricons","@vicons","@v2icons","@sicons"],"Icon"],create:(o,t)=>({ImportDeclaration(e){let[r,n]=t;if(f(e,r))for(let s of e.specifiers)s.local.name.startsWith(n)||o.report({loc:s.loc,messageId:"missingIconComponentPrefix",data:{prefix:n},fix(m){let p=RegExp(`^${n}`,"i").test(s.local.name),a=n+(p?s.local.name.substring(n.length):s.local.name);return s.type===_types.AST_NODE_TYPES.ImportSpecifier&&!g(s)&&(a=`${s.local.name} as ${a}`),m.replaceText(s.local,a)}})}})});var _path = require('path');var v="no-index-vue",I=i({name:v,meta:{type:"problem",docs:{description:"",recommended:"recommended"},schema:[],messages:{noIndexVue:"Do not use index.vue"}},defaultOptions:[],create:o=>({Program(){_path.basename.call(void 0, o.getFilename()).toLocaleLowerCase()==="index.vue"&&o.report({loc:{line:1,column:0},messageId:"noIndexVue"})}})});var P="no-multiple-slash-comment";function R(o){return o.type!==_utils.AST_TOKEN_TYPES.Line?!1:/^\/\s*<(amd-module|amd-dependency|reference){1}.*\/>\s*$/.test(o.value)}var S=i({name:P,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[],messages:{noMultipleSlashComment:"Do not use multiple slashes for single line comments."}},defaultOptions:[],create:o=>{let t=o.getSourceCode();return{Program(){t.getAllComments().filter(e=>e.type==="Line").filter(e=>!R(e)).filter(e=>/^\/+/.test(e.value)).forEach(e=>{o.report({node:e,messageId:"noMultipleSlashComment",fix:r=>r.replaceText(e,`//${e.value.replace(/^\/+/,"")}`)})})}}}});var _pascalcase = require('pascal-case');var W="pascal-case-component-name",y=i({name:W,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},schema:[],messages:{missingPascalCaseComponentName:"Vue component name must be PascalCase. e.g. {{pascalCase}}"}},defaultOptions:[],create:o=>({Program(){let t=_path.basename.call(void 0, o.getFilename());if(!t.endsWith(".vue"))return;let e=t.split(".")[0],r=_pascalcase.pascalCase.call(void 0, e,{transform:_pascalcase.pascalCaseTransformMerge});e!==r&&o.report({loc:{line:1,column:0},messageId:"missingPascalCaseComponentName",data:{pascalCase:r+t.slice(e.length)}})}})});var k="no-cjs-icon-component",A=/^@(r|v|v2)icons/i;function _(o){var p;let[t,e,r,...n]=o.split("/"),s=e!=="utils"&&!["es","",void 0].includes((p=r==null?void 0:r.trim())==null?void 0:p.toLocaleLowerCase());return{org:t,iconSet:e,isUtil:e==="utils",shouldFix:s,fixSource:()=>{var l;if(!s)return o;let a=[t,e,"es"];return((l=r==null?void 0:r.trim())==null?void 0:l.toLocaleLowerCase())!=="lib"&&a.push(r),a.push(...n),a.join("/")}}}var C=i({name:k,meta:{type:"problem",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[],messages:{noCjsIconCompnoent:"Do not import icon components maybe cjs."}},defaultOptions:[],create:o=>({ImportDeclaration(t){if(!d(t,A))return;let{shouldFix:e,fixSource:r}=_(t.source.value);e&&o.report({messageId:"noCjsIconCompnoent",node:t,fix(n){return n.replaceText(t.source,`'${r()}'`)}})}})});var $="no-default-import",h=i({name:$,meta:{type:"problem",docs:{description:"",recommended:"recommended"},schema:[{type:["array","string"],description:"No default import source matcher"}],messages:{noDefaultImport:"Do not use default imports in '{{source}}'",noWrokspaceImport:"Do not use workspace imports in '{{source}}'"}},defaultOptions:[[]],create:(o,t)=>({ImportDeclaration(e){let[r]=t;if(!u(e,r)||e.importKind==="type")return;let n;for(let s of e.specifiers)if(s.type==="ImportDefaultSpecifier"){n="noDefaultImport";break}else if(s.type==="ImportNamespaceSpecifier"){n="noWrokspaceImport";break}n&&o.report({node:e,messageId:n,data:{source:e.source.value}})}})});var le={rules:{"icon-component-prefix":x,"no-index-vue":I,"no-multiple-slash-comment":S,"pascal-case-component-name":y,"no-cjs-icon-component":C,"no-default-import":h},configs:{recommended:{plugins:["@yafh"],rules:{"@yafh/icon-component-prefix":"error","@yafh/no-cjs-icon-component":"error","@yafh/no-multiple-slash-comment":"error","@yafh/no-index-vue":"error","@yafh/pascal-case-component-name":"error"}}}};exports.default = le; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| import{AST_NODE_TYPES as h}from"@typescript-eslint/types";import{ESLintUtils as S}from"@typescript-eslint/utils";import{AST_NODE_TYPES as y}from"@typescript-eslint/types";var r=S.RuleCreator(e=>e);function l(e,t){let o=e.source.value;return t instanceof RegExp?t.test(o):typeof t=="string"?o.startsWith(t):t.some(s=>o.startsWith(s))}function u(e,t){let o=e.source.value;return t.test(o)}function f(e){return e.type===y.ImportSpecifier&&(e.imported.range[0]!==e.local.range[0]||e.imported.range[1]!==e.local.range[1])}var T="icon-component-prefix",d=r({name:T,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[{type:["string","array"],description:"Icon Component source matcher"},{type:["string"],description:"prefix"}],messages:{missingIconComponentPrefix:"Expect icon component prefix '{{prefix}}'"}},defaultOptions:[["@ricons","@vicons","@v2icons","@sicons"],"Icon"],create:(e,t)=>({ImportDeclaration(o){let[s,i]=t;if(l(o,s))for(let n of o.specifiers)n.local.name.startsWith(i)||e.report({loc:n.loc,messageId:"missingIconComponentPrefix",data:{prefix:i},fix(m){let c=RegExp(`^${i}`,"i").test(n.local.name),a=i+(c?n.local.name.substring(i.length):n.local.name);return n.type===h.ImportSpecifier&&!f(n)&&(a=`${n.local.name} as ${a}`),m.replaceText(n.local,a)}})}})});import{basename as O}from"node:path";var E="no-index-vue",g=r({name:E,meta:{type:"problem",docs:{description:"",recommended:"recommended"},schema:[],messages:{noIndexVue:"Do not use index.vue"}},defaultOptions:[],create:e=>({Program(){O(e.getFilename()).toLocaleLowerCase()==="index.vue"&&e.report({loc:{line:1,column:0},messageId:"noIndexVue"})}})});import{AST_TOKEN_TYPES as M}from"@typescript-eslint/utils";var v="no-multiple-slash-comment";function b(e){return e.type!==M.Line?!1:/^\/\s*<(amd-module|amd-dependency|reference){1}.*\/>\s*$/.test(e.value)}var x=r({name:v,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[],messages:{noMultipleSlashComment:"Do not use multiple slashes for single line comments."}},defaultOptions:[],create:e=>{let t=e.getSourceCode();return{Program(){t.getAllComments().filter(o=>o.type==="Line").filter(o=>!b(o)).filter(o=>/^\/+/.test(o.value)).forEach(o=>{e.report({node:o,messageId:"noMultipleSlashComment",fix:s=>s.replaceText(o,`//${o.value.replace(/^\/+/,"")}`)})})}}}});import{basename as P}from"node:path";import{pascalCase as R,pascalCaseTransformMerge as D}from"pascal-case";var N="pascal-case-component-name",C=r({name:N,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},schema:[],messages:{missingPascalCaseComponentName:"Vue component name must be PascalCase. e.g. {{pascalCase}}"}},defaultOptions:[],create:e=>({Program(){let t=P(e.getFilename());if(!t.endsWith(".vue"))return;let o=t.split(".")[0],s=R(o,{transform:D});o!==s&&e.report({loc:{line:1,column:0},messageId:"missingPascalCaseComponentName",data:{pascalCase:s+t.slice(o.length)}})}})});var j="no-cjs-icon-component",L=/^@(r|v|v2)icons/i;function A(e){var c;let[t,o,s,...i]=e.split("/"),n=o!=="utils"&&!["es","",void 0].includes((c=s==null?void 0:s.trim())==null?void 0:c.toLocaleLowerCase());return{org:t,iconSet:o,isUtil:o==="utils",shouldFix:n,fixSource:()=>{var p;if(!n)return e;let a=[t,o,"es"];return((p=s==null?void 0:s.trim())==null?void 0:p.toLocaleLowerCase())!=="lib"&&a.push(s),a.push(...i),a.join("/")}}}var I=r({name:j,meta:{type:"problem",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[],messages:{noCjsIconCompnoent:"Do not import icon components maybe cjs."}},defaultOptions:[],create:e=>({ImportDeclaration(t){if(!u(t,L))return;let{shouldFix:o,fixSource:s}=A(t.source.value);o&&e.report({messageId:"noCjsIconCompnoent",node:t,fix(i){return i.replaceText(t.source,`'${s()}'`)}})}})});var ne={rules:{"icon-component-prefix":d,"no-index-vue":g,"no-multiple-slash-comment":x,"pascal-case-component-name":C,"no-cjs-icon-component":I},configs:{recommended:{plugins:["@yafh"],rules:{"@yafh/icon-component-prefix":"error","@yafh/no-cjs-icon-component":"error","@yafh/no-multiple-slash-comment":"error","@yafh/no-index-vue":"error","@yafh/pascal-case-component-name":"error"}}}};export{ne as default}; | ||
| import{AST_NODE_TYPES as M}from"@typescript-eslint/types";import{ESLintUtils as O}from"@typescript-eslint/utils";import{AST_NODE_TYPES as T}from"@typescript-eslint/types";var i=O.RuleCreator(o=>o);function c(o){return o.toLowerCase().trim()}function u(o,t){let e=c(o.source.value);return typeof t=="string"?e===t:t.some(r=>e.startsWith(c(r)))}function f(o,t){let e=c(o.source.value);return typeof t=="string"?e.startsWith(c(t)):t.some(r=>e.startsWith(c(r)))}function d(o,t){let e=o.source.value;return t.test(e)}function g(o){return o.type===T.ImportSpecifier&&(o.imported.range[0]!==o.local.range[0]||o.imported.range[1]!==o.local.range[1])}var E="icon-component-prefix",x=i({name:E,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[{type:["string","array"],description:"Icon Component source matcher"},{type:["string"],description:"prefix"}],messages:{missingIconComponentPrefix:"Expect icon component prefix '{{prefix}}'"}},defaultOptions:[["@ricons","@vicons","@v2icons","@sicons"],"Icon"],create:(o,t)=>({ImportDeclaration(e){let[r,n]=t;if(f(e,r))for(let s of e.specifiers)s.local.name.startsWith(n)||o.report({loc:s.loc,messageId:"missingIconComponentPrefix",data:{prefix:n},fix(m){let p=RegExp(`^${n}`,"i").test(s.local.name),a=n+(p?s.local.name.substring(n.length):s.local.name);return s.type===M.ImportSpecifier&&!g(s)&&(a=`${s.local.name} as ${a}`),m.replaceText(s.local,a)}})}})});import{basename as b}from"node:path";var v="no-index-vue",I=i({name:v,meta:{type:"problem",docs:{description:"",recommended:"recommended"},schema:[],messages:{noIndexVue:"Do not use index.vue"}},defaultOptions:[],create:o=>({Program(){b(o.getFilename()).toLocaleLowerCase()==="index.vue"&&o.report({loc:{line:1,column:0},messageId:"noIndexVue"})}})});import{AST_TOKEN_TYPES as D}from"@typescript-eslint/utils";var P="no-multiple-slash-comment";function R(o){return o.type!==D.Line?!1:/^\/\s*<(amd-module|amd-dependency|reference){1}.*\/>\s*$/.test(o.value)}var S=i({name:P,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[],messages:{noMultipleSlashComment:"Do not use multiple slashes for single line comments."}},defaultOptions:[],create:o=>{let t=o.getSourceCode();return{Program(){t.getAllComments().filter(e=>e.type==="Line").filter(e=>!R(e)).filter(e=>/^\/+/.test(e.value)).forEach(e=>{o.report({node:e,messageId:"noMultipleSlashComment",fix:r=>r.replaceText(e,`//${e.value.replace(/^\/+/,"")}`)})})}}}});import{basename as N}from"node:path";import{pascalCase as L,pascalCaseTransformMerge as j}from"pascal-case";var W="pascal-case-component-name",y=i({name:W,meta:{type:"suggestion",docs:{description:"",recommended:"recommended"},schema:[],messages:{missingPascalCaseComponentName:"Vue component name must be PascalCase. e.g. {{pascalCase}}"}},defaultOptions:[],create:o=>({Program(){let t=N(o.getFilename());if(!t.endsWith(".vue"))return;let e=t.split(".")[0],r=L(e,{transform:j});e!==r&&o.report({loc:{line:1,column:0},messageId:"missingPascalCaseComponentName",data:{pascalCase:r+t.slice(e.length)}})}})});var k="no-cjs-icon-component",A=/^@(r|v|v2)icons/i;function _(o){var p;let[t,e,r,...n]=o.split("/"),s=e!=="utils"&&!["es","",void 0].includes((p=r==null?void 0:r.trim())==null?void 0:p.toLocaleLowerCase());return{org:t,iconSet:e,isUtil:e==="utils",shouldFix:s,fixSource:()=>{var l;if(!s)return o;let a=[t,e,"es"];return((l=r==null?void 0:r.trim())==null?void 0:l.toLocaleLowerCase())!=="lib"&&a.push(r),a.push(...n),a.join("/")}}}var C=i({name:k,meta:{type:"problem",docs:{description:"",recommended:"recommended"},fixable:"code",schema:[],messages:{noCjsIconCompnoent:"Do not import icon components maybe cjs."}},defaultOptions:[],create:o=>({ImportDeclaration(t){if(!d(t,A))return;let{shouldFix:e,fixSource:r}=_(t.source.value);e&&o.report({messageId:"noCjsIconCompnoent",node:t,fix(n){return n.replaceText(t.source,`'${r()}'`)}})}})});var $="no-default-import",h=i({name:$,meta:{type:"problem",docs:{description:"",recommended:"recommended"},schema:[{type:["array","string"],description:"No default import source matcher"}],messages:{noDefaultImport:"Do not use default imports in '{{source}}'",noWrokspaceImport:"Do not use workspace imports in '{{source}}'"}},defaultOptions:[[]],create:(o,t)=>({ImportDeclaration(e){let[r]=t;if(!u(e,r)||e.importKind==="type")return;let n;for(let s of e.specifiers)if(s.type==="ImportDefaultSpecifier"){n="noDefaultImport";break}else if(s.type==="ImportNamespaceSpecifier"){n="noWrokspaceImport";break}n&&o.report({node:e,messageId:n,data:{source:e.source.value}})}})});var le={rules:{"icon-component-prefix":x,"no-index-vue":I,"no-multiple-slash-comment":S,"pascal-case-component-name":y,"no-cjs-icon-component":C,"no-default-import":h},configs:{recommended:{plugins:["@yafh"],rules:{"@yafh/icon-component-prefix":"error","@yafh/no-cjs-icon-component":"error","@yafh/no-multiple-slash-comment":"error","@yafh/no-index-vue":"error","@yafh/pascal-case-component-name":"error"}}}};export{le as default}; |
+1
-1
| { | ||
| "name": "@yafh/eslint-plugin", | ||
| "version": "0.3.0", | ||
| "version": "0.4.1", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Eslint plugin for YanAndFish", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
12366
15.51%43
16.22%0
-100%