-
Notifications
You must be signed in to change notification settings - Fork 31
feat: Migrate ESLint configuration from root-only to per-package NX lint tasks #3160
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
base: main
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 51fc848 ☁️ Nx Cloud last updated this comment at |
|
- Install @nx/eslint plugin - Create .eslintrc.js for each package extending root config - Add lint targets to all project.json files using @nx/eslint executor - Update package.json scripts to use NX for linting - Configure targetDefaults for proper lint caching - All packages now have individual lint tasks that can be cached separately Co-authored-by: jakemhiller <[email protected]>
899210c
to
51fc848
Compare
📬Published Alpha Packages:[email protected] |
🚀 Styleguide deploy preview ready! |
- Added .eslintignore to exclude node_modules - Updated .eslintrc.json to include reportUnusedDisableDirectives and refined ignorePatterns - Removed .x-eslintignore as it was redundant - Enhanced .eslintrc.js in styleguide package with overrides for .mdx files - Modified tsconfig.storybook.json to include additional storybook file patterns - Adjusted Popover.stories.tsx to cast rest props correctly
- Converted .eslintrc.js files to .eslintrc.json for multiple packages - Updated ignore patterns to maintain consistency across configurations - Ensured all packages now utilize the new JSON format for ESLint settings
Problem
Previously, this repository used NX for builds and tests but ESLint was configured to run from the root directory only. This meant:
Solution
This PR migrates the ESLint configuration to use NX's per-package approach, enabling independent linting with caching for each library.
Key Changes
🔧 Added @nx/eslint plugin to provide NX-managed linting capabilities
📁 Per-package ESLint configurations - Each of the 11 packages now has its own
.eslintrc.js
file that extends the root configuration:⚡ NX lint targets - All packages now have individual
lint
targets in theirproject.json
files using the@nx/eslint:lint
executor📜 Updated scripts - Root package.json scripts now use NX:
npm run lint
→nx run-many --target=lint --all
npm run lint:fix
→nx run-many --target=lint --all --fix
🚀 Optimized caching - Added
@nx/eslint:lint
totargetDefaults
innx.json
for proper cache configurationBenefits
nx lint <package-name>
Backward Compatibility
✅ lint-staged integration still works - continues using
@codecademy/eslint-config/bin/eslint-fix.js
for staged files✅ husky pre-commit hooks continue to function normally
✅ Error reporting maintains the same behavior for failed lints
✅ Existing workflows remain unchanged
Usage Examples
The implementation maintains full compatibility with existing workflows while providing the performance and caching benefits of NX's per-package approach.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cloud.nx.app
/usr/local/bin/node ./bin/post-install
(dns block)node /home/REDACTED/work/gamut/gamut/node_modules/.bin/nx run-many --target=build --projects=gamut --dry-run
(dns block)node /home/REDACTED/work/gamut/gamut/node_modules/.bin/nx build eslint-plugin-gamut
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.