Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/examples/html-eslint/MetaItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script lang="ts">
export const name = "html-eslint";
export default {};
</script>
<template>
<div>
Example to try
<a href="https://html-eslint.org/" target="_blank">HTML ESLINT</a>.
</div>
</template>
18 changes: 18 additions & 0 deletions src/examples/html-eslint/eslint.config.js.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from "eslint/config";
import html from "@html-eslint/eslint-plugin";

export default defineConfig([
// lint html files
{
files: ["**/*.html"],
plugins: {
html,
},
// When using the recommended rules
extends: ["html/recommended"],
language: "html/html",
rules: {
"html/no-duplicate-class": "error",
}
}
]);
1 change: 1 addition & 0 deletions src/examples/html-eslint/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as description, name } from "./MetaItem.vue";
9 changes: 9 additions & 0 deletions src/examples/html-eslint/package.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
type: "module",
devDependencies: {
"@eslint/js": "latest",
eslint: "latest",
"@html-eslint/eslint-plugin": "latest",
"@html-eslint/parser": "latest",
},
};
10 changes: 10 additions & 0 deletions src/examples/html-eslint/src/example.html.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head>
</head>
<body>
<div>
<li> foo </li>
</div>
</body>
</html>
48 changes: 48 additions & 0 deletions src/plugins/plugins/html-eslint/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { ESLintConfig, ESLintLegacyConfig, PluginMeta } from "../..";

export const name = "@html-eslint/eslint-plugin";
export const meta: PluginMeta = {
description: "An ESLint plugin for formatting and linting HTML.",
repo: "https://github.com/yeonjuan/html-eslint",
lang: ["html"],
};
export const devDependencies = {
[name]: "latest",
"@html-eslint/parser": "latest",
};
export const eslintLegacyConfig: ESLintLegacyConfig = {
plugins: ["@html-eslint"],
overrides: [
{
files: ["*.html"],
parser: "@html-eslint/parser",
extends: ["plugin:@html-eslint/recommended-legacy"],
},
],
};
export const eslintConfig: ESLintConfig<"html"> = {
*imports(helper) {
if (helper.type === "module") {
yield helper.i(`import html from '${name}'`);
} else {
yield helper.require({
local: "html",
source: name,
});
}
},
async *expression(names, helper) {
yield helper.x(`{
files: ["**/*.html"],
plugins: {
html: ${names.html},
},
// When using the recommended rules
extends: ["html/recommended"],
language: "html/html",
rules: {
"html/no-duplicate-class": "error",
}
}`);
},
};