Skip to content

hilja/lint

Repository files navigation

My oxlint/oxfmt config setup

An opinionated oxlint and oxfmt config setup.

It includes:

  • oxfmt
  • oxlint
  • oxlint-tsgolint
  • eslint-plugin-react-x
import {
  lintConfig, // oxlint rules
  fmtConfig, // oxfmt config
  reactConfig, // React rules
  reactRouterConfig, // React Router rules
} from '@hilja/lint'

// Straight oxlint and oxfmt exports
import { oxlint, oxfmt } from '@hilja/lint/oxc'

Install

pnpm add -D @hil/lint

Usage

// oxlint.config.ts
import { lintConfig, reactConfig, reactRouterConfig, oxlint } from '@hilja/lint'

// Spread in extra rules, or picking keys will also work
const extendedLintConfig = {
  ...lintConfig,
  rules: {
    ...lintConfig.rules,
    'no-restricted-imports': ['error', { paths: ['zod', 'zod/*'] }],
  },
}

export default oxlint.defineConfig({
  extends: [extendedLintConfig],
  overrides: [
    {
      // Target react rules only to tsx files in a specific workspace
      files: ['foo/app/**/*.tsx'],
      plugins: reactConfig.plugins,
      jsPlugins: reactConfig.jsPlugins,
      rules: { ...reactConfig.rules, ...reactRouterConfig.rules },
    },
    {
      // Override normally
      files: ['{core,db,lgh}/**/*'],
      rules: {
        'no-restricted-imports': 'off',
      },
    },
  ],
  settings: reactConfig.settings,
  env: {
    builtin: true,
  },
  ignorePatterns: [
    '**/build/**/*',
    '**/fixtures/**/*',
    '**/node_modules/**/*',
    'foo/.react-router/**/*',
  ],
})
// oxfmt.config.ts
import { fmtConfig, oxfmt } from '@hilja/lint'

export default oxfmt.defineConfig({
  ...fmtConfig,
  sortTailwindcss: {
    functions: ['twm', 'cva'],
    stylesheet: 'foo/app/styles/tailwind.css',
  },
})

JSON config files

The JSON config files in ,/json are strictly for convenience. They are created from the ts files with pnpm json which calls ./scripts/create-json.ts. They should not be fiddled with manually.

About

My oxlint and oxfmt config files

Resources

Stars

Watchers

Forks

Contributors