Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add first draft of recommended config
  • Loading branch information
francoismassart committed Aug 24, 2025
commit 0423c7924d3e112c0fef01f59c2f5fc87b2dbb92
43 changes: 38 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as parserBase from "@typescript-eslint/parser";
import { TSESLint } from "@typescript-eslint/utils";
import { Linter } from "@typescript-eslint/utils/ts-eslint";
import { FlatConfig, Linter } from "@typescript-eslint/utils/ts-eslint";

import { rules } from "./rules";
import { recommendedRulesConfig, rules } from "./rules";

export const parser: TSESLint.FlatConfig.Parser = {
meta: parserBase.meta,
Expand All @@ -27,13 +27,46 @@ const { name, version } =
// Plugin not fully initialized yet.
// See https://eslint.org/docs/latest/extend/plugins#configs-in-plugins
const plugin = {
// `configs`, assigned later
configs: {},
rules,
meta: {
name,
version,
},
// `configs`, assigned later
configs: {},
rules,
} satisfies Linter.Plugin;

// Config base for all configurations
const configBase: FlatConfig.Config = {
name: "tailwindcss/base",
plugins: {
tailwindcss: plugin,
},
settings: {
tailwindcss: {},
},
files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
languageOptions: {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
},
};

// Prepare configs here so we can reference `plugin`
const sharedConfigs: FlatConfig.SharedConfigs = {
recommended: {
...configBase,
name: "tailwindcss/recommended",
rules: recommendedRulesConfig,
},
};

// Inject shared configs into the plugin
Object.assign(plugin.configs, sharedConfigs);

export default plugin;
9 changes: 8 additions & 1 deletion src/rules/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Linter } from "@typescript-eslint/utils/ts-eslint";

import {
classnamesOrder,
RULE_NAME as CLASSNAMES_ORDER,
Expand All @@ -7,7 +9,12 @@ import {
RULE_NAME as NO_CUSTOM_CLASSNAME,
} from "./no-custom-classname";

export const rules = {
export const rules: Linter.PluginRules = {
[CLASSNAMES_ORDER]: classnamesOrder,
[NO_CUSTOM_CLASSNAME]: noCustomClassname,
};

export const recommendedRulesConfig: Linter.RulesRecord = {
[CLASSNAMES_ORDER]: "error",
[NO_CUSTOM_CLASSNAME]: "warn",
};