Files
2026-09-15 17:29:31 -06:00

102 lines
3.7 KiB
JavaScript

import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import nodePlugin from 'eslint-plugin-n';
import unicorn from 'eslint-plugin-unicorn';
export default [
// Astro sources are a separate linting ecosystem; scripts/ and test/ are plain Node
{
ignores: ['src/**', '.astro/**', 'public/**', 'dist/**', 'astro.config.mjs', 'node_modules/**'],
},
// Base JavaScript recommended rules
js.configs.recommended,
// Node.js rules
...nodePlugin.configs['flat/mixed-esm-and-cjs'],
// Unicorn rules (modern best practices)
unicorn.configs.recommended,
// Place Prettier last to disable conflicting stylistic rules
eslintConfigPrettier,
// Project-specific tweaks
{
rules: {
// Allow console for CLI tools in this repo
'no-console': 'off',
// Relax some Unicorn rules that are too opinionated for this codebase
'unicorn/prevent-abbreviations': 'off',
'unicorn/no-null': 'off',
},
},
// CLI scripts and tests for the docs site
{
files: ['scripts/**/*.js', 'scripts/**/*.mjs', 'test/**/*.js', 'test/**/*.mjs'],
rules: {
// Allow CommonJS patterns for Node CLI scripts
'unicorn/prefer-module': 'off',
'unicorn/import-style': 'off',
'unicorn/no-process-exit': 'off',
'n/no-process-exit': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/prefer-top-level-await': 'off',
// Avoid failing CI on incidental unused vars in internal scripts
'no-unused-vars': 'off',
// Reduce style-only churn in internal tools
'unicorn/prefer-ternary': 'off',
'unicorn/filename-case': 'off',
'unicorn/no-array-reduce': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/consistent-function-scoping': 'off',
// Keep newly recommended Unicorn rules from imposing unrelated source churn.
'unicorn/better-dom-traversing': 'off',
'unicorn/consistent-boolean-name': 'off',
'unicorn/name-replacements': 'off',
'unicorn/no-array-sort': 'off',
'unicorn/no-break-in-nested-loop': 'off',
'unicorn/no-computed-property-existence-check': 'off',
'unicorn/no-declarations-before-early-exit': 'off',
'unicorn/no-top-level-assignment-in-function': 'off',
'unicorn/no-unreadable-for-of-expression': 'off',
'unicorn/no-unsafe-string-replacement': 'off',
'unicorn/no-useless-collection-argument': 'off',
'unicorn/no-useless-else': 'off',
'unicorn/operator-assignment': 'off',
'unicorn/prefer-await': 'off',
'unicorn/prefer-continue': 'off',
'unicorn/prefer-https': 'off',
'unicorn/prefer-minimal-ternary': 'off',
'unicorn/prefer-number-coercion': 'off',
'unicorn/prefer-simple-condition-first': 'off',
'unicorn/prefer-split-limit': 'off',
'unicorn/prefer-string-repeat': 'off',
'unicorn/prefer-unicode-code-point-escapes': 'off',
'unicorn/require-array-sort-compare': 'off',
'unicorn/single-line-block-comment-style': 'off',
'n/no-extraneous-require': 'off',
'n/no-extraneous-import': 'off',
'n/no-unpublished-require': 'off',
'n/no-unpublished-import': 'off',
// Some scripts intentionally use globals provided at runtime
'no-undef': 'off',
// Additional relaxed rules for legacy/internal scripts
'no-useless-catch': 'off',
'unicorn/prefer-number-properties': 'off',
'no-unreachable': 'off',
'unicorn/text-encoding-identifier-case': 'off',
},
},
// ESLint config file should not be checked for publish-related Node rules
{
files: ['eslint.config.mjs'],
rules: {
'n/no-unpublished-import': 'off',
},
},
];