mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-11-13 15:32:53 +09:00
The no-restricted-syntax `.card` selector used `\bcard\b`, which flagged any className containing "card" as a word — including unrelated compound classes like `settings-card`, `sk-spec-card`, `auth-card`, and `wp-site-card-skeleton`, none of which are the legacy `.card` class the rule's message targets. Narrowed it to the legacy card family as a LEADING token (`card`, `card-header`, `card-body`, …), removing ~220 false-positive warnings while still flagging real `.card` usage (225 remain). Frontend ESLint warnings: 1616 (plan baseline) → 1190; 0 errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
62 lines
2.1 KiB
JavaScript
62 lines
2.1 KiB
JavaScript
import js from '@eslint/js';
|
|
import globals from 'globals';
|
|
import reactPlugin from 'eslint-plugin-react';
|
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
|
|
export default [
|
|
{ ignores: ['dist/**', 'node_modules/**'] },
|
|
{
|
|
files: ['**/*.{js,jsx}'],
|
|
languageOptions: {
|
|
ecmaVersion: 2022,
|
|
sourceType: 'module',
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.es2021,
|
|
},
|
|
parserOptions: {
|
|
ecmaFeatures: { jsx: true },
|
|
},
|
|
},
|
|
plugins: {
|
|
react: reactPlugin,
|
|
'react-hooks': reactHooks,
|
|
'react-refresh': reactRefresh,
|
|
},
|
|
rules: {
|
|
...js.configs.recommended.rules,
|
|
...reactPlugin.configs.flat.recommended.rules,
|
|
...reactPlugin.configs.flat['jsx-runtime'].rules,
|
|
...reactHooks.configs['recommended-latest'].rules,
|
|
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
|
'react/prop-types': 'off',
|
|
'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
|
|
|
// Discourage inline styles — prefer SCSS classes and shared components.
|
|
'no-restricted-syntax': [
|
|
'warn',
|
|
{
|
|
selector: 'JSXAttribute[name.name="style"]',
|
|
message: 'Inline styles are discouraged. Use SCSS classes or a shared primitive instead.',
|
|
},
|
|
{
|
|
selector: 'JSXOpeningElement[name.name="button"]',
|
|
message: 'Use the shared Button component (or IconButton for icon-only actions).',
|
|
},
|
|
{
|
|
// Match the legacy card family (.card, .card-header, .card-body, …) as a
|
|
// LEADING class token — not unrelated compounds like `settings-card`,
|
|
// `sk-spec-card`, or `wp-site-card-skeleton`, which the old `\bcard\b`
|
|
// pattern flagged as false positives.
|
|
selector: 'JSXOpeningElement[name.name="div"] > JSXAttribute[name.name="className"] > Literal[value=/(^|\\s)card(\\s|$|-)/]',
|
|
message: 'Use the shared Card component instead of the legacy .card class.',
|
|
},
|
|
],
|
|
},
|
|
settings: {
|
|
react: { version: 'detect' },
|
|
},
|
|
},
|
|
];
|