Skip to content

Commit

Permalink
Stronger config typing
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeharder committed Dec 19, 2024
1 parent 5907a21 commit d0ae1de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
26 changes: 11 additions & 15 deletions eng/tools/eslint-plugin-tsv/src/eslint-plugin-tsv.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
import { Linter } from "eslint";
import parser from "yaml-eslint-parser";
import { NamedESLint } from "./named-eslint.js";
import kebabCaseOrg from "./rules/kebab-case-org.js";

const plugin: NamedESLint.Plugin = {
configs: { recommended: {} },
name: "tsv",
rules: {
[kebabCaseOrg.name]: kebabCaseOrg,
},
};

const configs: Record<string, Linter.Config> = {
recommended: {
plugins: {
[plugin.name]: plugin,
},
files: ["*.yaml", "**/*.yaml"],
rules: {
[`${plugin.name}/${kebabCaseOrg.name}`]: "error",
},
languageOptions: {
parser: parser,
},
plugin.configs.recommended = {
plugins: {
[plugin.name]: plugin,
},
files: ["*.yaml", "**/*.yaml"],
rules: {
[`${plugin.name}/${kebabCaseOrg.name}`]: "error",
},
languageOptions: {
parser: parser,
},
};

plugin.configs = configs;

export default plugin;
3 changes: 2 additions & 1 deletion eng/tools/eslint-plugin-tsv/src/named-eslint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ESLint, Rule } from "eslint";
import { ESLint, Linter, Rule } from "eslint";

// ESLint with names for convenience

Expand All @@ -10,6 +10,7 @@ export namespace NamedRule {

export namespace NamedESLint {
export interface Plugin extends ESLint.Plugin {
configs: { recommended: Linter.Config };
name: string;
rules?: Record<string, NamedRule.RuleModule>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import eslintPluginTsv from "../../../src/eslint-plugin-tsv.js";

export const config = [
...eslintPluginTsv.configs.recommended,
];

export default config;
export default eslintPluginTsv.configs.recommended;

0 comments on commit d0ae1de

Please sign in to comment.