@html-eslint/eslint-plugin
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -12,3 +12,5 @@ module.exports = { | ||
"@html-eslint/indent": "error", | ||
"@html-eslint/require-li-container": "error", | ||
"@html-eslint/quotes": "error", | ||
}, | ||
}; |
@@ -0,1 +1,2 @@ | ||
/** @type {string[]} */ | ||
module.exports = [ | ||
@@ -2,0 +3,0 @@ "aa", // Afar |
@@ -1,2 +0,7 @@ | ||
module.exprots = { | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
/** @type {RuleCategory} */ | ||
module.exports = { | ||
BEST_PRACTICE: "Best Practice", | ||
@@ -3,0 +8,0 @@ SEO: "SEO", |
@@ -1,10 +0,3 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
const { RULE_CATEGORY, NODE_TYPES } = require("../constants"); | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const MESSAGE_IDS = { | ||
@@ -21,3 +14,3 @@ EXPECT_NEW_LINE_AFTER: "expectAfter", | ||
description: "Enforce newline between elements", | ||
category: CATEGORY.STYLE, | ||
category: RULE_CATEGORY.STYLE, | ||
recommended: true, | ||
@@ -37,3 +30,3 @@ }, | ||
sibilings | ||
.filter((node) => node.type !== "text" && node.range[0]) | ||
.filter((node) => node.type !== NODE_TYPES.TEXT && node.range[0]) | ||
.forEach((current, index, arr) => { | ||
@@ -58,3 +51,3 @@ const after = arr[index + 1]; | ||
const children = (node.childNodes || []).filter( | ||
(n) => !!n.range[0] && n.type !== "text" | ||
(n) => !!n.range[0] && n.type !== NODE_TYPES.TEXT | ||
); | ||
@@ -90,3 +83,3 @@ const first = children[0]; | ||
"*"(node) { | ||
if (node.type !== "text") { | ||
if (node.type !== NODE_TYPES.TEXT) { | ||
checkSiblings(node.childNodes || []); | ||
@@ -93,0 +86,0 @@ checkChild(node); |
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
* @typedef {import("../types").HTMLNode} HTMLNode | ||
@@ -13,4 +12,3 @@ * | ||
/** @type {RuleCategory} */ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const { RULE_CATEGORY, NODE_TYPES } = require("../constants"); | ||
@@ -34,3 +32,3 @@ /** @type {MessageId} */ | ||
description: "Enforce consistent indentation", | ||
category: CATEGORY.STYLE, | ||
category: RULE_CATEGORY.STYLE, | ||
recommended: true, | ||
@@ -138,3 +136,3 @@ }, | ||
}); | ||
if (node.parent && node.parent.type === "Pre") { | ||
if (node.parent && node.parent.type === NODE_TYPES.PRE) { | ||
return; | ||
@@ -141,0 +139,0 @@ } |
@@ -12,2 +12,4 @@ const requireLang = require("./require-lang"); | ||
const indent = require("./indent"); | ||
const requireLiContainer = require("./require-li-container"); | ||
const quotes = require("./quotes"); | ||
@@ -25,3 +27,5 @@ module.exports = { | ||
"no-skip-heading-levels": noSkipHeadingLevels, | ||
"require-li-container": requireLiContainer, | ||
indent: indent, | ||
quotes: quotes, | ||
}; |
@@ -1,9 +0,2 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const { RULE_CATEGORY } = require("../constants"); | ||
const { NodeUtils } = require("./utils"); | ||
@@ -21,3 +14,3 @@ | ||
description: "Disallow to use duplicate id", | ||
category: CATEGORY.BEST_PRACTICE, | ||
category: RULE_CATEGORY.BEST_PRACTICE, | ||
recommended: true, | ||
@@ -24,0 +17,0 @@ }, |
@@ -1,10 +0,3 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
const { RULE_CATEGORY } = require("../constants"); | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const MESSAGE_IDS = { | ||
@@ -22,3 +15,3 @@ EXTRA_BETWEEN: "unexpectBetween", | ||
description: "Disallow an extra spacing around attributes", | ||
category: CATEGORY.STYLE, | ||
category: RULE_CATEGORY.STYLE, | ||
recommended: true, | ||
@@ -25,0 +18,0 @@ }, |
@@ -1,9 +0,2 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const { RULE_CATEGORY } = require("../constants"); | ||
const { NodeUtils } = require("./utils"); | ||
@@ -21,3 +14,3 @@ | ||
description: "Disallow using inline style", | ||
category: CATEGORY.BEST_PRACTICE, | ||
category: RULE_CATEGORY.BEST_PRACTICE, | ||
recommended: false, | ||
@@ -24,0 +17,0 @@ }, |
@@ -1,10 +0,3 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
const { RULE_CATEGORY } = require("../constants"); | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const MESSAGE_IDS = { | ||
@@ -20,3 +13,3 @@ MULTIPLE_H1: "unexpectedMultiH1", | ||
description: "Disallow multiple `<h1></h1>`.", | ||
category: CATEGORY.SEO, | ||
category: RULE_CATEGORY.SEO, | ||
recommended: true, | ||
@@ -23,0 +16,0 @@ }, |
@@ -1,10 +0,3 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
const { RULE_CATEGORY } = require("../constants"); | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const MESSAGE_IDS = { | ||
@@ -20,3 +13,3 @@ UNEXPECTED: "unexpected", | ||
description: "Disallow skipping heading levels", | ||
category: CATEGORY.ACCESSIBILITY, | ||
category: RULE_CATEGORY.ACCESSIBILITY, | ||
recommended: false, | ||
@@ -23,0 +16,0 @@ }, |
@@ -1,10 +0,3 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
const { RULE_CATEGORY } = require("../constants"); | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const MESSAGE_IDS = { | ||
@@ -20,3 +13,3 @@ MISSING_DOCTYPE: "missingDoctype", | ||
description: "Require `<!DOCTYPE HTML>` in html,", | ||
category: CATEGORY.BEST_PRACTICE, | ||
category: RULE_CATEGORY.BEST_PRACTICE, | ||
recommended: true, | ||
@@ -23,0 +16,0 @@ }, |
@@ -1,10 +0,3 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
const { RULE_CATEGORY } = require("../constants"); | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const MESSAGE_IDS = { | ||
@@ -20,3 +13,3 @@ MISSING_ALT: "missingAlt", | ||
description: "Require `alt` attribute at `<img>` tag", | ||
category: CATEGORY.ACCESSIBILITY, | ||
category: RULE_CATEGORY.ACCESSIBILITY, | ||
recommended: true, | ||
@@ -23,0 +16,0 @@ }, |
@@ -1,10 +0,2 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const IOS_639_1 = require("../constants/iso_639_1"); | ||
const { RULE_CATEGORY, ISO_639_1 } = require("../constants"); | ||
const { NodeUtils } = require("./utils"); | ||
@@ -23,3 +15,3 @@ | ||
description: "Require `lang` attribute at `<html>` tag", | ||
category: CATEGORY.SEO, | ||
category: RULE_CATEGORY.SEO, | ||
recommended: true, | ||
@@ -45,3 +37,3 @@ }, | ||
}); | ||
} else if (!IOS_639_1.includes(langAttr.value)) { | ||
} else if (!ISO_639_1.includes(langAttr.value)) { | ||
context.report({ | ||
@@ -48,0 +40,0 @@ node: node.startTag, |
@@ -1,13 +0,6 @@ | ||
/** | ||
* @typedef {import("../types").RuleCategory} RuleCategory | ||
*/ | ||
const { RULE_CATEGORY, NODE_TYPES } = require("../constants"); | ||
/** | ||
* @type {RuleCategory} | ||
*/ | ||
const CATEGORY = require("../constants/rule-category"); | ||
const MESSAGE_IDS = { | ||
MISSING_TITLE: "missingTitle", | ||
EMPTY_TITLE: "emptyTitle", | ||
MISSING_TITLE: "missing", | ||
EMPTY_TITLE: "empty", | ||
}; | ||
@@ -21,3 +14,3 @@ | ||
description: "Require `<title><title/>` in the `<head><head/>`", | ||
category: CATEGORY.SEO, | ||
category: RULE_CATEGORY.SEO, | ||
recommended: true, | ||
@@ -39,3 +32,3 @@ }, | ||
const titleTag = (node.childNodes || []).find( | ||
(node) => node.type === "Title" | ||
(node) => node.type === NODE_TYPES.TITLE | ||
); | ||
@@ -50,3 +43,4 @@ | ||
!(titleTag.childNodes || []).some( | ||
(node) => node.type === "text" && node.value.trim().length > 0 | ||
(node) => | ||
node.type === NODE_TYPES.TEXT && node.value.trim().length > 0 | ||
) | ||
@@ -53,0 +47,0 @@ ) { |
@@ -9,4 +9,5 @@ // https://stylelint.io/user-guide/rules/regex | ||
/** | ||
* @param {string} name | ||
* @returns {boolean} | ||
* Checks a given name follows `kebab-case` or not. | ||
* @param {string} name name to check | ||
* @returns {boolean} `true` if a name follows `kebab-case`, otherwise `false`. | ||
*/ | ||
@@ -18,4 +19,5 @@ isKebabCase(name) { | ||
/** | ||
* @param {string} name | ||
* @returns {boolean} | ||
* Checks a given name follows `snake_case` or not. | ||
* @param {string} name name to check | ||
* @returns {boolean} `true` if a name follows `snake_case`, otherwise `false`. | ||
*/ | ||
@@ -27,4 +29,5 @@ isSnakeCase(name) { | ||
/** | ||
* @param {string} name | ||
* @returns {boolean} | ||
* Checks a given name follows `PascalCase` or not. | ||
* @param {string} name name to check | ||
* @returns {boolean} `true` if a name follows `PascalCase`, otherwise `false`. | ||
*/ | ||
@@ -36,4 +39,5 @@ isPascalCase(name) { | ||
/** | ||
* @param {string} name | ||
* @returns {boolean} | ||
* Checks a given name follows `camelCase` or not. | ||
* @param {string} name name to check | ||
* @returns {boolean} `true` if a name follows `camelCase`, otherwise `false`. | ||
*/ | ||
@@ -40,0 +44,0 @@ isCamelCase(name) { |
@@ -8,2 +8,11 @@ export type RuleCategory = { | ||
export type NodeTypes = { | ||
TEXT: "text"; | ||
TITLE: "Title"; | ||
PRE: "Pre"; | ||
MENU: "Menu"; | ||
OL: "Ol"; | ||
UL: "Ul"; | ||
}; | ||
type Loc = { | ||
@@ -10,0 +19,0 @@ end: { |
{ | ||
"name": "@html-eslint/eslint-plugin", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "ESLint plugin for html", | ||
@@ -29,6 +29,18 @@ "author": "yeonjuan", | ||
}, | ||
"engines": { | ||
"node": ">=8.10.0" | ||
}, | ||
"keywords": [ | ||
"eslint", | ||
"eslintplugin", | ||
"eslint-plugin", | ||
"html", | ||
"formatter", | ||
"lint", | ||
"accessibility" | ||
], | ||
"devDependencies": { | ||
"@html-eslint/parser": "^0.4.1" | ||
"@html-eslint/parser": "^0.5.0" | ||
}, | ||
"gitHead": "0171c6eccb93800af6af3e6988dd5c6bcd0f4958" | ||
"gitHead": "94642c3e6d8bc7f8987ddbbc12ea655f0bfc6c4d" | ||
} |
# `@html-eslint/eslint-plugin` | ||
> TODO: description | ||
An ESLint plugin which provides lint rules for HTML. | ||
## Usage | ||
``` | ||
const eslintPlugin = require('@html-eslint/eslint-plugin'); | ||
// TODO: DEMONSTRATE API | ||
``` | ||
- [Getting Started](https://github.com/yeonjuan/html-eslint#Getting-Started) | ||
- [Installation](https://github.com/yeonjuan/html-eslint#Installation) | ||
- [Configuration](https://github.com/yeonjuan/html-eslint#Configuration) | ||
- [Recommended Configs](https://github.com/yeonjuan/html-eslint#Recommended-Configs) | ||
- [Rules](https://github.com/yeonjuan/html-eslint#Rules) | ||
- [License](https://github.com/yeonjuan/html-eslint#License) |
33371
27
1194
11