-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: support ESLint Flat Configs #55
Conversation
Hey @arthurgeron , I really appreciate the work you're doing on this plugin! I'd be happy to help test it early and provide feedback if that would be helpful. Thanks! |
- Added `eslint.config.js` for ESLint V9 flat config compatibility. - Updated `jest.config.js` to disable TypeScript diagnostics. - Modified `package.json` to reflect beta version and adjust ESLint dependency. - Enhanced README with ESLint V9 flat config usage instructions. - Refactored test files to utilize a shared `ruleTester` configuration. - Introduced `eslint-configs.ts` for flat config rule definitions. - Updated `eslintConfig.ts` to include metadata and improve rule exports.
- Introduced new test files for ESLint v9 compatibility, including , , and . - Updated to include for environment variable management in tests.
- Updated `package.json` to replace `ts-prune` with `knip` for dead code analysis. - Added `@types/estree` as a dependency for type definitions.
- Introduced `flat-config.ts` and `traditional-config.ts` for ESLint rule definitions. - Updated `index.ts` to import from the new config files. - Moved messages for useMemo rules in `messages.ts`. - Updated `knip.json` to ignore the new config files.
Thank you, @sedlukha. |
@arthurgeron when i try to use Option 2: Using the recommended configimport { flatConfig } from '@arthurgeron/eslint-plugin-react-usememo';
export default [
// Other configs...
flatConfig.configs.recommended,
]; it returns error:
|
@arthurgeron this type of config Option 1: Importing the default configimport { flatConfig } from '@arthurgeron/eslint-plugin-react-usememo';
export default [
{
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
plugins: {
'@arthurgeron/react-usememo': flatConfig,
},
rules: {
'@arthurgeron/react-usememo/require-usememo': 'error',
'@arthurgeron/react-usememo/require-memo': 'error',
'@arthurgeron/react-usememo/require-usememo-children': 'error',
},
},
]; fails with error too:
but without
|
@arthurgeron I recommend checking this migration guide: https://eslint.org/docs/latest/extend/plugin-migration-flat-config, seems like you skip some parts of it |
I'm figuring out a way to test both V8 and V9, but there are many dependencies related. I might have to only support v9 and make this a new major. |
- Updated `jest.config.js` to ignore specific test paths using regex for better flexibility. - Modified `package.json` to streamline the test command for ESLint v9. - Removed legacy `ruleTester.ts` file and replaced it with a new implementation for ESLint v8 and v9. - Added comprehensive test cases for the `require-memo`, `require-usecallback`, and `require-
@arthurgeron could you please create new beta release? i will test on my projects |
Surely, just keep in mind not all rules are working with ESLint V9, yet.
|
…nese - Introduced new markdown files for code style, ESLint, project general, and testing guidelines to enhance project documentation. - Established best practices for TypeScript, React, error handling, and memoization. - Documented ESLint configuration options and rules, including compatibility with ESLint v8 and v9. - Outlined testing approach and structure, ensuring compatibility testing across ESLint versions.
- Added a new test path to Jest configuration to ignore specific test cases. - Updated README to reflect changes in ESLint parser options for JSX support. - Modified ESLint rule tester to use the flat config format and adjusted parser settings. - Cleaned up test cases by removing unnecessary parser options and dummy tests. - Changed ESLint rules in example configurations from error to warn for better flexibility during development.
@sedlukha could you please test |
- Added custom rule options to both v8 and v9 example configurations - Created example components to demonstrate ignored components and props - Added validation test cases for each rule option
Looking for volunteers to test out |
feat: support ESLint Flat Configs
Key Changes
eslint.config.js
) + compatibility layer between ESLint v8 and v9Technical Implementation
The implementation uses a compatibility layer to handle differences between ESLint v8 and v9 APIs, particularly around rule context, scope handling, and configuration formats. This allows the same rule logic to work seamlessly in both environments without code duplication.
New Example Projects
Example projects' configurations now include custom rule options demonstrating how to:
ignoredComponents
ignoredPropNames
strict
optionignoredHookCallsNames
Documentation Updates
Testing
All rule functionality has been tested with both ESLint v8 and v9 configurations to ensure consistent behavior across environments. The test suite includes:
Developer Impact
Possible approaches:
This version has been tagged as
2.5.0--beta5
for testing before the final release.