Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend javascript config in react config #34

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ Some configs extend other configs, as illustrated below. So, for example, extend
node --extends--> javascript
angular --extends--> typescript
ngrx --extends--> angular
react --extends--> javascript
graphql --extends--> node
```

4 changes: 3 additions & 1 deletion docs/react.md
Original file line number Diff line number Diff line change
@@ -20,7 +20,9 @@ Config for **React** projects.
export default tseslint.config(...react);
```

## 📏 Rules (101)
## 📏 Rules (391)

**290** rules are included from [`javascript` config](./javascript.md#📏-rules-290). For brevity, only the **101** additional rules are listed in this document.

> 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).<br>💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).<br>🧪🚫 Disabled for [test files](../README.md#🧪-test-overrides).<br>🧪⚠️ Severity lessened to warning for [test files](../README.md#🧪-test-overrides).

3 changes: 2 additions & 1 deletion src/configs/react.js
Original file line number Diff line number Diff line change
@@ -6,8 +6,9 @@ import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import { REACT_FILE_PATTERNS } from '../lib/patterns.js';
import javascript from './javascript.js';

export default tseslint.config({
export default tseslint.config(...javascript, {
matejchalk marked this conversation as resolved.
Show resolved Hide resolved
files: REACT_FILE_PATTERNS,
languageOptions: {
globals: globals.browser,
5 changes: 5 additions & 0 deletions tests/configs/react.spec.js
Original file line number Diff line number Diff line change
@@ -20,6 +20,11 @@ describe('react config', () => {
expect(Object.keys(config.rules ?? {}).join(',')).toContain('react/');
});

it('should have rule from extended javascript config', async () => {
const config = await loadConfig('components/Button.tsx');
expect(config.rules).toHaveProperty('@typescript-eslint/no-unused-vars');
});

it('should have rule from extended recommended react config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('react/jsx-key');