Skip to content

Extend javascript config in react config #34

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

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
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
Expand Up @@ -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
```

Expand Down
4 changes: 3 additions & 1 deletion docs/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
3 changes: 2 additions & 1 deletion src/configs/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
files: REACT_FILE_PATTERNS,
languageOptions: {
globals: globals.browser,
Expand Down
5 changes: 5 additions & 0 deletions tests/configs/react.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading