File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
eng/tools/eslint-plugin-tsv/src Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1
1
import parser from "yaml-eslint-parser" ;
2
2
import { NamedESLint } from "./interfaces/named-eslint.js" ;
3
+ import emitAutorest from "./rules/emit-autorest.js" ;
3
4
import kebabCaseOrg from "./rules/kebab-case-org.js" ;
4
5
5
6
const plugin : NamedESLint . Plugin = {
6
7
configs : { recommended : { } } ,
7
8
name : "tsv" ,
8
9
rules : {
9
10
[ kebabCaseOrg . name ] : kebabCaseOrg ,
11
+ [ emitAutorest . name ] : emitAutorest ,
10
12
} ,
11
13
} ;
12
14
@@ -17,6 +19,7 @@ plugin.configs.recommended = {
17
19
files : [ "*.yaml" , "**/*.yaml" ] ,
18
20
rules : {
19
21
[ `${ plugin . name } /${ kebabCaseOrg . name } ` ] : "error" ,
22
+ [ `${ plugin . name } /${ emitAutorest . name } ` ] : "error" ,
20
23
} ,
21
24
languageOptions : {
22
25
parser : parser ,
Original file line number Diff line number Diff line change
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 ;
You can’t perform that action at this time.
0 commit comments