Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 19, 2025

Problem

Previously, this repository used NX for builds and tests but ESLint was configured to run from the root directory only. This meant:

  • All linting had to run against the entire codebase, even when changes were made to just one package
  • No caching benefits for linting - every lint run processed all files
  • No ability to run linting on individual packages
  • Slower CI and local development cycles

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:

module.exports = {
  extends: ['../../.eslintrc.js'],
  root: false,
};

⚡ NX lint targets - All packages now have individual lint targets in their project.json files using the @nx/eslint:lint executor

📜 Updated scripts - Root package.json scripts now use NX:

  • npm run lintnx run-many --target=lint --all
  • npm run lint:fixnx run-many --target=lint --all --fix

🚀 Optimized caching - Added @nx/eslint:lint to targetDefaults in nx.json for proper cache configuration

Benefits

  • Independent caching: Each package's lint results are cached separately by NX
  • Faster builds: Only changed packages re-run linting (tested: "11 out of 11 tasks" read from cache)
  • Parallel execution: Multiple packages can be linted simultaneously
  • Granular control: Developers can lint specific packages with nx lint <package-name>
  • Future extensibility: Easy to add package-specific lint rules when needed

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

# Lint all packages (with caching)
npm run lint

# Lint specific packages
nx lint gamut
nx lint styleguide

# Lint multiple specific packages
nx run-many --target=lint --projects=gamut,gamut-styles

# Fix linting issues
npm run lint:fix
nx lint styleguide --fix

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
    • Triggering command: /usr/local/bin/node ./bin/post-install (dns block)
    • Triggering command: node /home/REDACTED/work/gamut/gamut/node_modules/.bin/nx run-many --target=build --projects=gamut --dry-run (dns block)
    • Triggering command: 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.

Copy link

nx-cloud bot commented Aug 19, 2025

View your CI Pipeline Execution ↗ for commit 51fc848


☁️ Nx Cloud last updated this comment at 2025-08-20 17:42:13 UTC

@CLAassistant
Copy link

CLAassistant commented Aug 19, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ jakemhiller
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

@Copilot Copilot AI changed the title [WIP] Currently this repo uses NX but ESLint is set up to run from the root. Update the repo so that each NX library has an eslint config file and an NX lint task so linting can be run and cached separately feat: Migrate ESLint configuration from root-only to per-package NX lint tasks Aug 19, 2025
Copilot finished work on behalf of jakemhiller August 19, 2025 20:59
@Copilot Copilot AI requested a review from jakemhiller August 19, 2025 20:59
Copilot AI and others added 3 commits August 20, 2025 13:09
- 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]>
@jakemhiller jakemhiller force-pushed the copilot/fix-592298ba-a569-4099-88e6-9a2012641367 branch from 899210c to 51fc848 Compare August 20, 2025 17:09
@codecademydev
Copy link
Collaborator

📬Published Alpha Packages:

[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]

@codecademydev
Copy link
Collaborator

🚀 Styleguide deploy preview ready!

https://68a603013ee1152d70c8e903--gamut-preview.netlify.app

Deploy Logs

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants