Pre-defined glob patterns, constants, and file matching utilities for ESLint configuration.
Glob patterns for matching various source file types.
/** Source file extension pattern */
const GLOB_SRC_EXT: string; // '?([cm])[jt]s?(x)'
/** All source files pattern */
const GLOB_SRC: string; // '**/*.?([cm])[jt]s?(x)'
/** JavaScript files pattern */
const GLOB_JS: string; // '**/*.?([cm])js'
/** JSX files pattern */
const GLOB_JSX: string; // '**/*.?([cm])jsx'
/** TypeScript files pattern */
const GLOB_TS: string; // '**/*.?([cm])ts'
/** TSX files pattern */
const GLOB_TSX: string; // '**/*.?([cm])tsx'Usage Examples:
import { GLOB_TS, GLOB_JS, GLOB_SRC } from "@antfu/eslint-config";
// Use in ESLint config
export default [
{
files: [GLOB_TS, GLOB_TSX],
rules: {
'@typescript-eslint/no-unused-vars': 'error',
},
},
{
files: [GLOB_JS, GLOB_JSX],
rules: {
'no-unused-vars': 'error',
},
},
];Patterns for CSS and styling related files.
/** All style files pattern */
const GLOB_STYLE: string; // '**/*.{c,le,sc}ss'
/** CSS files pattern */
const GLOB_CSS: string; // '**/*.css'
/** PostCSS files pattern */
const GLOB_POSTCSS: string; // '**/*.{p,post}css'
/** Less files pattern */
const GLOB_LESS: string; // '**/*.less'
/** SCSS files pattern */
const GLOB_SCSS: string; // '**/*.scss'Patterns for JSON, YAML, and other data formats.
/** JSON files pattern */
const GLOB_JSON: string; // '**/*.json'
/** JSON5 files pattern */
const GLOB_JSON5: string; // '**/*.json5'
/** JSON with comments pattern */
const GLOB_JSONC: string; // '**/*.jsonc'
/** YAML files pattern */
const GLOB_YAML: string; // '**/*.y?(a)ml'
/** TOML files pattern */
const GLOB_TOML: string; // '**/*.toml'
/** XML files pattern */
const GLOB_XML: string; // '**/*.xml'Patterns for framework-specific files and components.
/** Vue files pattern */
const GLOB_VUE: string; // '**/*.vue'
/** Svelte files pattern (including JS/TS variants) */
const GLOB_SVELTE: string; // '**/*.svelte?(.{js,ts})'
/** Astro files pattern */
const GLOB_ASTRO: string; // '**/*.astro'
/** Astro TypeScript pattern */
const GLOB_ASTRO_TS: string; // '**/*.astro/*.ts'Patterns for documentation and media files.
/** Markdown files pattern */
const GLOB_MARKDOWN: string; // '**/*.md'
/** Nested markdown pattern */
const GLOB_MARKDOWN_IN_MARKDOWN: string; // '**/*.md/*.md'
/** HTML files pattern */
const GLOB_HTML: string; // '**/*.htm?(l)'
/** SVG files pattern */
const GLOB_SVG: string; // '**/*.svg'
/** GraphQL files pattern */
const GLOB_GRAPHQL: string; // '**/*.{g,graph}ql'Combined patterns for common use cases.
/** Markdown code blocks pattern */
const GLOB_MARKDOWN_CODE: string; // Combines GLOB_MARKDOWN and GLOB_SRC
/** Test files patterns array */
const GLOB_TESTS: string[]; // Array of test file patterns
/** All source files patterns array */
const GLOB_ALL_SRC: string[]; // Array of all supported source patternsExpanded Values:
// GLOB_TESTS includes:
[
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
`**/*.spec.${GLOB_SRC_EXT}`,
`**/*.test.${GLOB_SRC_EXT}`,
`**/*.bench.${GLOB_SRC_EXT}`,
`**/*.benchmark.${GLOB_SRC_EXT}`,
]
// GLOB_ALL_SRC includes:
[
GLOB_SRC, // JS/TS files
GLOB_STYLE, // CSS files
GLOB_JSON, // JSON files
GLOB_JSON5, // JSON5 files
GLOB_MARKDOWN, // Markdown files
GLOB_SVELTE, // Svelte files
GLOB_VUE, // Vue files
GLOB_YAML, // YAML files
GLOB_XML, // XML files
GLOB_HTML, // HTML files
]Default patterns for files and directories to exclude from linting.
/** Default exclusion patterns array */
const GLOB_EXCLUDE: string[];Excluded Patterns:
const GLOB_EXCLUDE = [
// Dependencies
'**/node_modules',
// Build outputs
'**/dist',
'**/output',
'**/coverage',
'**/.nuxt',
'**/.next',
'**/.svelte-kit',
'**/.vercel',
'**/.vite-inspect',
// Lock files
'**/package-lock.json',
'**/yarn.lock',
'**/pnpm-lock.yaml',
'**/bun.lockb',
// Temporary directories
'**/temp',
'**/.temp',
'**/tmp',
'**/.tmp',
'**/.history',
'**/.cache',
'**/.yarn',
// IDE and tools
'**/.idea',
'**/.changeset',
'**/.vitepress/cache',
// Generated files
'**/CHANGELOG*.md',
'**/*.min.*',
'**/LICENSE*',
'**/__snapshots__',
'**/auto-import?(s).d.ts',
'**/components.d.ts',
'**/vite.config.*.timestamp-*',
];Default mappings for renaming ESLint plugins to shorter names.
/** Default plugin name mappings */
const defaultPluginRenaming: Record<string, string>;Default Mappings:
const defaultPluginRenaming = {
'@eslint-react': 'react',
'@eslint-react/dom': 'react-dom',
'@eslint-react/hooks-extra': 'react-hooks-extra',
'@eslint-react/naming-convention': 'react-naming-convention',
'@next/next': 'next',
'@stylistic': 'style',
'@typescript-eslint': 'ts',
'import-lite': 'import',
'n': 'node',
'vitest': 'test',
'yml': 'yaml',
};Default configuration values for stylistic formatting rules.
/** Default stylistic configuration */
const StylisticConfigDefaults: StylisticConfig;Default Values:
const StylisticConfigDefaults = {
indent: 2,
quotes: 'single',
jsx: true,
semi: false,Common patterns for using these constants in ESLint configurations.
Framework-specific configurations:
import { GLOB_VUE, GLOB_TS, GLOB_TSX } from "@antfu/eslint-config";
export default [
{
files: [GLOB_VUE],
rules: {
'vue/no-unused-vars': 'error',
},
},
{
files: [GLOB_TS, GLOB_TSX],
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
},
},
];Test-specific configurations:
import { GLOB_TESTS, GLOB_SRC } from "@antfu/eslint-config";
export default [
{
files: [GLOB_SRC],
rules: {
'no-console': 'warn',
},
},
{
files: GLOB_TESTS,
rules: {
'no-console': 'off', // Allow console in tests
},
},
];Custom exclusions:
import { GLOB_EXCLUDE } from "@antfu/eslint-config";
export default [
{
ignores: [
...GLOB_EXCLUDE,
'**/custom-build/**',
'**/generated/**',
],
},
];File type specific formatting:
import {
GLOB_CSS,
GLOB_HTML,
GLOB_MARKDOWN,
GLOB_JSON,
GLOB_YAML
} from "@antfu/eslint-config";
export default [
{
files: [GLOB_CSS, GLOB_HTML],
rules: {
// Prettier handles these
},
},
{
files: [GLOB_MARKDOWN],
rules: {
// Markdown-specific rules
},
},
{
files: [GLOB_JSON, GLOB_YAML],
rules: {
// Data format rules
},
},
];