Skip to content

refactor: extract shared ESLint config and add lint scripts#4459

Open
JessenReinhart wants to merge 3 commits into
less:masterfrom
JessenReinhart:feature/eslint-cleanup
Open

refactor: extract shared ESLint config and add lint scripts#4459
JessenReinhart wants to merge 3 commits into
less:masterfrom
JessenReinhart:feature/eslint-cleanup

Conversation

@JessenReinhart

@JessenReinhart JessenReinhart commented Jun 29, 2026

Copy link
Copy Markdown

Summary

Addresses discussion #3787 by extracting shared ESLint rules to a central config location.

Changes

Commit 1: ESLint configuration setup

  • Created config/eslint/base.cjs with common ESLint rules
  • Updated packages/less/.eslintrc.cjs to extend the shared config
  • Added lint and lint:fix scripts to root package.json
  • Scoped TypeScript-specific recommended rules to .ts files only to avoid noise in legacy .js files

Commit 2: Auto-formatting

  • Applied pnpm run lint:fix using the new shared config
  • Touches only quote style and indentation; no logic changes

Testing

  • pnpm run lint passes with zero errors
  • All 139 unit tests pass

Note

The pre-commit hook (pnpm test) fails locally due to a port 8081 conflict (unrelated to these changes). Tests pass successfully when run manually.


References:

Summary by CodeRabbit

  • New Features

    • Added new lint commands for the Less package, including an auto-fix option.
  • Chores

    • Introduced shared linting defaults and updated the Less ESLint setup to consistently apply common rules via a shared base configuration.
    • Performed formatting/maintenance cleanups across benchmarking, build tooling, and internal logic without expected behavior changes.

Addresses discussion less#3787 by extracting shared ESLint rules to
config/eslint/base.cjs and adding lint/lint:fix npm scripts.

Changes:
- Created config/eslint/base.cjs with common ESLint rules
- Updated packages/less/.eslintrc.cjs to extend the shared config
- Added lint and lint:fix scripts to root package.json

The shared config maintains compatibility with both JS and TS
files. TypeScript-specific recommended rules are scoped to .ts
files only to avoid noise in legacy .js source files.

Verified: pnpm run lint passes with zero errors, 139/139 unit
tests pass (pre-commit hook failed only on unrelated port conflict).
Auto-generated by 'pnpm run lint:fix' using the new shared config.
Touches only quote style and indentation; no logic changes.

- benchmark/benchmark-runner.js: indent
- build/rollup.js: quotes (backtick -> single)
- lib/less-node/environment.js: indent
- lib/less/tree/nested-at-rule.js: indent
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 29, 2026
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 62445fcd-d5df-49b2-b967-9dd3cff76dd4

📥 Commits

Reviewing files that changed from the base of the PR and between e7eb9df and 5e63d50.

📒 Files selected for processing (1)
  • packages/less/benchmark/benchmark-runner.js
✅ Files skipped from review due to trivial changes (1)
  • packages/less/benchmark/benchmark-runner.js

📝 Walkthrough

Walkthrough

A shared ESLint base config is added and consumed by packages/less. Root lint scripts and TypeScript ESLint dependencies are added. Several Less source files are reformatted to match the updated lint rules, with no logic changes.

Changes

ESLint base config and lint tooling

Layer / File(s) Summary
Shared ESLint config and scripts
config/eslint/base.cjs, package.json
Adds a CommonJS ESLint base config with TypeScript parser settings, recommended rules, and style overrides. package.json adds lint/lint:fix scripts and @typescript-eslint plus eslint@^7.29.0 to devDependencies.

Package ESLint config and source cleanup

Layer / File(s) Summary
Package ESLint config uses shared base
packages/less/.eslintrc.cjs
Replaces the standalone config with extends: ['../../config/eslint/base.cjs'] and scoped overrides for TypeScript, library, benchmark, build, scripts, and test files.
Source formatting updates
packages/less/benchmark/benchmark-runner.js, packages/less/build/rollup.js, packages/less/lib/less-node/environment.js, packages/less/lib/less/tree/nested-at-rule.js
Reformats the listed files for quotes, indentation, and semicolon style while preserving behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

size:XL

Poem

🐇 A little lint, a little cheer,
The code style rabbit hops sincere.
Shared config hums through night and day,
And tidy quotes now lead the way.
No logic changed, just whiskers neat—
The warren’s syntax is complete!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: extracting a shared ESLint config and adding lint scripts.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.0)
packages/less/benchmark/benchmark-runner.js

File contains syntax errors that prevent linting: Line 134: expected } but instead the file ends

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/less/benchmark/benchmark-runner.js

Parsing error: '}' expected.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
config/eslint/base.cjs (1)

11-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Scope mocha to the test override. Keeping env.mocha = true in the shared base makes describe/it legal in every file. Move it into the test override so production sources still get no-undef protection.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config/eslint/base.cjs` around lines 11 - 15, The shared ESLint base config
currently enables mocha globally, which makes test globals available in all
files. Move the mocha environment setting out of the base env block and into the
existing test override in base.cjs so only test files get describe/it, while
production code still benefits from no-undef; use the env sections in the base
config and the test override as the places to update.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@config/eslint/base.cjs`:
- Around line 11-15: The shared ESLint base config currently enables mocha
globally, which makes test globals available in all files. Move the mocha
environment setting out of the base env block and into the existing test
override in base.cjs so only test files get describe/it, while production code
still benefits from no-undef; use the env sections in the base config and the
test override as the places to update.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e252831e-e4dd-419d-b489-0908dfd0ec81

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae2cc3 and e7eb9df.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • config/eslint/base.cjs
  • package.json
  • packages/less/.eslintrc.cjs
  • packages/less/benchmark/benchmark-runner.js
  • packages/less/build/rollup.js
  • packages/less/lib/less-node/environment.js
  • packages/less/lib/less/tree/nested-at-rule.js

Addresses docstring coverage warning in PR less#4459 by adding full
JSDoc to all functions in the benchmark-runner script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant