Skip to content

Commit 3b7580e

Browse files
committed
Add stub for new rule emit-autorest
1 parent 733db68 commit 3b7580e

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

eng/tools/eslint-plugin-tsv/src/eslint-plugin-tsv.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import parser from "yaml-eslint-parser";
22
import { NamedESLint } from "./interfaces/named-eslint.js";
3+
import emitAutorest from "./rules/emit-autorest.js";
34
import kebabCaseOrg from "./rules/kebab-case-org.js";
45

56
const plugin: NamedESLint.Plugin = {
67
configs: { recommended: {} },
78
name: "tsv",
89
rules: {
910
[kebabCaseOrg.name]: kebabCaseOrg,
11+
[emitAutorest.name]: emitAutorest,
1012
},
1113
};
1214

@@ -17,6 +19,7 @@ plugin.configs.recommended = {
1719
files: ["*.yaml", "**/*.yaml"],
1820
rules: {
1921
[`${plugin.name}/${kebabCaseOrg.name}`]: "error",
22+
[`${plugin.name}/${emitAutorest.name}`]: "error",
2023
},
2124
languageOptions: {
2225
parser: parser,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { NamedRule } from "../interfaces/named-eslint.js";
2+
3+
export const rule: NamedRule.RuleModule = {
4+
name: "emit-autorest",
5+
meta: {
6+
type: "problem",
7+
docs: {
8+
description:
9+
"Requires emitter 'typespec-autorest' to be enabled by default, and requires emitted autorest to match content in repo",
10+
},
11+
schema: [],
12+
messages: {
13+
disabled: "Path does not match format '.*/specification/{orgName}/': ''{{filename}}'",
14+
autorestDiff: "Emitted autorest does not match content in repo",
15+
},
16+
},
17+
create(context) {
18+
return {
19+
Program(node) {
20+
// const filename = path.resolve(context.filename as string);
21+
// const pathSegments = filename.split(path.sep);
22+
// const specificationIndex = pathSegments.indexOf("specification");
23+
// const pathValid = specificationIndex >= 0 && specificationIndex < pathSegments.length - 1;
24+
// if (!pathValid) {
25+
// context.report({
26+
// node,
27+
// messageId: "invalid",
28+
// data: { filename: filename },
29+
// });
30+
// return;
31+
// }
32+
// const orgName = pathSegments[specificationIndex + 1];
33+
// const kebabCaseRegex = /^[a-z0-9]+(-[a-z0-9]+)*$/;
34+
// const orgNameKebabCase = orgName.match(kebabCaseRegex);
35+
// if (!orgNameKebabCase) {
36+
// context.report({
37+
// node,
38+
// messageId: "kebab",
39+
// data: { orgName: orgName },
40+
// });
41+
// }
42+
},
43+
};
44+
},
45+
};
46+
47+
export default rule;

0 commit comments

Comments
 (0)