@yafh/eslint-plugin
Advanced tools
| [document](https://github.com/YanAndFish/eslint-config#readme) |
+91
-3
@@ -7,3 +7,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/rules/icon-component-prefix.ts | ||
| var createRule = _utils.ESLintUtils.RuleCreator((name3) => name3); | ||
| var createRule = _utils.ESLintUtils.RuleCreator((name5) => name5); | ||
| function isSourceOf(node, matcher) { | ||
@@ -113,2 +113,86 @@ const source = node.source.value; | ||
| // src/rules/no-multiple-slash-comment.ts | ||
| var name3 = "no-multiple-slash-comment"; | ||
| function isTripleSlashDirectives(comment) { | ||
| if (comment.type !== _utils.AST_TOKEN_TYPES.Line) | ||
| return false; | ||
| return /^\/\s*<(amd-module|amd-dependency|reference){1}.*\/>\s*$/.test(comment.value); | ||
| } | ||
| var no_multiple_slash_comment_default = createRule({ | ||
| name: name3, | ||
| meta: { | ||
| type: "suggestion", | ||
| docs: { | ||
| description: "", | ||
| recommended: "recommended" | ||
| }, | ||
| fixable: "code", | ||
| schema: [], | ||
| messages: { | ||
| noMultipleSlashComment: "Do not use multiple slashes for single line comments." | ||
| } | ||
| }, | ||
| defaultOptions: [], | ||
| create: (context) => { | ||
| const sourceCode = context.getSourceCode(); | ||
| return { | ||
| Program() { | ||
| sourceCode.getAllComments().filter((comment) => comment.type === "Line").filter((comment) => !isTripleSlashDirectives(comment)).filter((comment) => /^\/+/.test(comment.value)).forEach((comment) => { | ||
| context.report({ | ||
| node: comment, | ||
| messageId: "noMultipleSlashComment", | ||
| fix: (fixer) => fixer.replaceText(comment, `//${comment.value.replace(/^\/+/, "")}`) | ||
| }); | ||
| }); | ||
| } | ||
| }; | ||
| } | ||
| }); | ||
| // src/rules/pascal-case-component-name.ts | ||
| var _pascalcase = require('pascal-case'); | ||
| var name4 = "pascal-case-component-name"; | ||
| var pascal_case_component_name_default = createRule( | ||
| { | ||
| name: name4, | ||
| meta: { | ||
| type: "suggestion", | ||
| docs: { | ||
| description: "", | ||
| recommended: "recommended" | ||
| }, | ||
| schema: [], | ||
| messages: { | ||
| missingPascalCaseComponentName: "Vue component name must be PascalCase. e.g. {{pascalCase}}" | ||
| } | ||
| }, | ||
| defaultOptions: [], | ||
| create: (context) => { | ||
| return { | ||
| Program() { | ||
| const baseName = _path.basename.call(void 0, context.getFilename()); | ||
| if (!baseName.endsWith(".vue")) | ||
| return; | ||
| const fileName = baseName.split(".")[0]; | ||
| const pascalCaseName = _pascalcase.pascalCase.call(void 0, fileName, { transform: _pascalcase.pascalCaseTransformMerge }); | ||
| if (fileName !== pascalCaseName) { | ||
| context.report({ | ||
| loc: { | ||
| line: 1, | ||
| column: 0 | ||
| }, | ||
| messageId: "missingPascalCaseComponentName", | ||
| data: { | ||
| pascalCase: pascalCaseName + baseName.slice(fileName.length) | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } | ||
| ); | ||
| // src/index.ts | ||
@@ -118,3 +202,5 @@ var src_default = { | ||
| "icon-component-prefix": icon_component_prefix_default, | ||
| "no-index-vue": no_index_vue_default | ||
| "no-index-vue": no_index_vue_default, | ||
| "no-multiple-slash-comment": no_multiple_slash_comment_default, | ||
| "pascal-case-component-name": pascal_case_component_name_default | ||
| }, | ||
@@ -126,4 +212,6 @@ configs: { | ||
| "@yafh/icon-component-prefix": "error", | ||
| "@yafh/no-multiple-slash-comment": "error", | ||
| // vue | ||
| "@yafh/no-index-vue": "error" | ||
| "@yafh/no-index-vue": "error", | ||
| "@yafh/pascal-case-component-name": "error" | ||
| } | ||
@@ -130,0 +218,0 @@ } |
+91
-3
@@ -7,3 +7,3 @@ // src/rules/icon-component-prefix.ts | ||
| import { AST_NODE_TYPES } from "@typescript-eslint/types"; | ||
| var createRule = ESLintUtils.RuleCreator((name3) => name3); | ||
| var createRule = ESLintUtils.RuleCreator((name5) => name5); | ||
| function isSourceOf(node, matcher) { | ||
@@ -113,2 +113,86 @@ const source = node.source.value; | ||
| // src/rules/no-multiple-slash-comment.ts | ||
| import { AST_TOKEN_TYPES } from "@typescript-eslint/utils"; | ||
| var name3 = "no-multiple-slash-comment"; | ||
| function isTripleSlashDirectives(comment) { | ||
| if (comment.type !== AST_TOKEN_TYPES.Line) | ||
| return false; | ||
| return /^\/\s*<(amd-module|amd-dependency|reference){1}.*\/>\s*$/.test(comment.value); | ||
| } | ||
| var no_multiple_slash_comment_default = createRule({ | ||
| name: name3, | ||
| meta: { | ||
| type: "suggestion", | ||
| docs: { | ||
| description: "", | ||
| recommended: "recommended" | ||
| }, | ||
| fixable: "code", | ||
| schema: [], | ||
| messages: { | ||
| noMultipleSlashComment: "Do not use multiple slashes for single line comments." | ||
| } | ||
| }, | ||
| defaultOptions: [], | ||
| create: (context) => { | ||
| const sourceCode = context.getSourceCode(); | ||
| return { | ||
| Program() { | ||
| sourceCode.getAllComments().filter((comment) => comment.type === "Line").filter((comment) => !isTripleSlashDirectives(comment)).filter((comment) => /^\/+/.test(comment.value)).forEach((comment) => { | ||
| context.report({ | ||
| node: comment, | ||
| messageId: "noMultipleSlashComment", | ||
| fix: (fixer) => fixer.replaceText(comment, `//${comment.value.replace(/^\/+/, "")}`) | ||
| }); | ||
| }); | ||
| } | ||
| }; | ||
| } | ||
| }); | ||
| // src/rules/pascal-case-component-name.ts | ||
| import { basename as basename2 } from "node:path"; | ||
| import { pascalCase, pascalCaseTransformMerge } from "pascal-case"; | ||
| var name4 = "pascal-case-component-name"; | ||
| var pascal_case_component_name_default = createRule( | ||
| { | ||
| name: name4, | ||
| meta: { | ||
| type: "suggestion", | ||
| docs: { | ||
| description: "", | ||
| recommended: "recommended" | ||
| }, | ||
| schema: [], | ||
| messages: { | ||
| missingPascalCaseComponentName: "Vue component name must be PascalCase. e.g. {{pascalCase}}" | ||
| } | ||
| }, | ||
| defaultOptions: [], | ||
| create: (context) => { | ||
| return { | ||
| Program() { | ||
| const baseName = basename2(context.getFilename()); | ||
| if (!baseName.endsWith(".vue")) | ||
| return; | ||
| const fileName = baseName.split(".")[0]; | ||
| const pascalCaseName = pascalCase(fileName, { transform: pascalCaseTransformMerge }); | ||
| if (fileName !== pascalCaseName) { | ||
| context.report({ | ||
| loc: { | ||
| line: 1, | ||
| column: 0 | ||
| }, | ||
| messageId: "missingPascalCaseComponentName", | ||
| data: { | ||
| pascalCase: pascalCaseName + baseName.slice(fileName.length) | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } | ||
| ); | ||
| // src/index.ts | ||
@@ -118,3 +202,5 @@ var src_default = { | ||
| "icon-component-prefix": icon_component_prefix_default, | ||
| "no-index-vue": no_index_vue_default | ||
| "no-index-vue": no_index_vue_default, | ||
| "no-multiple-slash-comment": no_multiple_slash_comment_default, | ||
| "pascal-case-component-name": pascal_case_component_name_default | ||
| }, | ||
@@ -126,4 +212,6 @@ configs: { | ||
| "@yafh/icon-component-prefix": "error", | ||
| "@yafh/no-multiple-slash-comment": "error", | ||
| // vue | ||
| "@yafh/no-index-vue": "error" | ||
| "@yafh/no-index-vue": "error", | ||
| "@yafh/pascal-case-component-name": "error" | ||
| } | ||
@@ -130,0 +218,0 @@ } |
+3
-2
| { | ||
| "name": "@yafh/eslint-plugin", | ||
| "version": "0.1.0", | ||
| "version": "0.2.0", | ||
| "license": "MIT", | ||
@@ -23,3 +23,4 @@ "description": "Eslint plugin for YanAndFish", | ||
| "@typescript-eslint/types": "^6.3.0", | ||
| "@typescript-eslint/utils": "^6.2.1" | ||
| "@typescript-eslint/utils": "^6.2.1", | ||
| "pascal-case": "^3.1.2" | ||
| }, | ||
@@ -26,0 +27,0 @@ "devDependencies": { |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
14901
60.48%6
20%424
66.93%1
-50%1
Infinity%4
33.33%+ Added
+ Added
+ Added
+ Added
+ Added