Skip to content

Commit

Permalink
feat: add callee support to tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
ASafaeirad committed Oct 22, 2024
1 parent 2936be2 commit efb51e7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ interface Options {
cypress?: boolean; // controls cypress plugin
playwright?: boolean // controls playwright plugin
storybook?: boolean; // controls storybook plugin
tailwind?: boolean; // controls tailwindcss plugin
tailwind?: boolean | { callee?: string[] }; // controls tailwindcss plugin
next?: boolean; // controls next plugin
prettier?: boolean; // controls prettier plugin
disableExpensiveRules?: boolean; // controls expensive rules
Expand Down
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { init } from './src/index.mjs';
export default init(
{
ignores: ['cjs/'],
fp: false,
test: true,
esm: true,
node: true,
Expand Down
4 changes: 4 additions & 0 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ const defaultOptions = {
*/
export function init(initOptions = {}, ...extend) {
const options = merge(defaultOptions, initOptions);

if (options.tailwind === true) {
options.tailwind = {};
}
if (options.typescript === true) {
options.typescript = {};
}
Expand Down
12 changes: 10 additions & 2 deletions src/modules/tailwind.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/** @return { Promise<import('eslint').Linter.Config> } */
async function tailwind() {
/**
* @param { import('../option').Options } options
* @return { Promise<import('eslint').Linter.Config> }
*/
async function tailwind(options = {}) {
const plugin = await import('eslint-plugin-tailwindcss');
return {
plugins: { tailwindcss: plugin.default ?? plugin },
settings: {
tailwindcss: {
callees: options.callees ?? ['cva', 'classnames', 'classNames', 'class', 'clsx', 'cn', 'cns', 'cx'],
},
},
rules: {
'tailwindcss/classnames-order': 'warn',
'tailwindcss/enforces-negative-arbitrary-values': 'warn',
Expand Down
2 changes: 1 addition & 1 deletion src/option.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface Options extends Linter.Config {
react?: boolean;
sort?: boolean;
next?: boolean;
tailwind?: boolean;
tailwind?: boolean | { callees: string[] };
node?: boolean;
strict?: boolean;
import?: { internalRegExp?: string; lifetime?: number; projects?: string | string[] } | boolean;
Expand Down

0 comments on commit efb51e7

Please sign in to comment.