Skip to content

Commit 0423c79

Browse files
add first draft of recommended config
1 parent 1a871a5 commit 0423c79

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

src/index.ts

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as parserBase from "@typescript-eslint/parser";
22
import { TSESLint } from "@typescript-eslint/utils";
3-
import { Linter } from "@typescript-eslint/utils/ts-eslint";
3+
import { FlatConfig, Linter } from "@typescript-eslint/utils/ts-eslint";
44

5-
import { rules } from "./rules";
5+
import { recommendedRulesConfig, rules } from "./rules";
66

77
export const parser: TSESLint.FlatConfig.Parser = {
88
meta: parserBase.meta,
@@ -27,13 +27,46 @@ const { name, version } =
2727
// Plugin not fully initialized yet.
2828
// See https://eslint.org/docs/latest/extend/plugins#configs-in-plugins
2929
const plugin = {
30-
// `configs`, assigned later
31-
configs: {},
32-
rules,
3330
meta: {
3431
name,
3532
version,
3633
},
34+
// `configs`, assigned later
35+
configs: {},
36+
rules,
3737
} satisfies Linter.Plugin;
3838

39+
// Config base for all configurations
40+
const configBase: FlatConfig.Config = {
41+
name: "tailwindcss/base",
42+
plugins: {
43+
tailwindcss: plugin,
44+
},
45+
settings: {
46+
tailwindcss: {},
47+
},
48+
files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
49+
languageOptions: {
50+
parserOptions: {
51+
ecmaVersion: "latest",
52+
sourceType: "module",
53+
ecmaFeatures: {
54+
jsx: true,
55+
},
56+
},
57+
},
58+
};
59+
60+
// Prepare configs here so we can reference `plugin`
61+
const sharedConfigs: FlatConfig.SharedConfigs = {
62+
recommended: {
63+
...configBase,
64+
name: "tailwindcss/recommended",
65+
rules: recommendedRulesConfig,
66+
},
67+
};
68+
69+
// Inject shared configs into the plugin
70+
Object.assign(plugin.configs, sharedConfigs);
71+
3972
export default plugin;

src/rules/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Linter } from "@typescript-eslint/utils/ts-eslint";
2+
13
import {
24
classnamesOrder,
35
RULE_NAME as CLASSNAMES_ORDER,
@@ -7,7 +9,12 @@ import {
79
RULE_NAME as NO_CUSTOM_CLASSNAME,
810
} from "./no-custom-classname";
911

10-
export const rules = {
12+
export const rules: Linter.PluginRules = {
1113
[CLASSNAMES_ORDER]: classnamesOrder,
1214
[NO_CUSTOM_CLASSNAME]: noCustomClassname,
1315
};
16+
17+
export const recommendedRulesConfig: Linter.RulesRecord = {
18+
[CLASSNAMES_ORDER]: "error",
19+
[NO_CUSTOM_CLASSNAME]: "warn",
20+
};

0 commit comments

Comments
 (0)