Skip to content

Flatter #228

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 8 commits into from
May 5, 2025
Merged

Flatter #228

merged 8 commits into from
May 5, 2025

Conversation

cwillisf
Copy link
Contributor

@cwillisf cwillisf commented Apr 30, 2025

Proposed Changes

Follow eslint community conventions better by offering flat configurations rather than functions to generate them.

Reason for Changes

I started trying to use the previous version (see #214) and realized it wasn't practical.

Test Coverage

Now with tests! It's not full coverage, but it at least covers our recommended ruleset for eslint.

I now also have a real-world example of this configuration in action: scratchfoundation/scratch-l10n#624

I forgot to add `eslint-plugin-jsdoc` when creating our new
configuration, even though it's present in the legacy configurations.
This change re-adds the plugin and configures it for better interaction
with TypeScript.
BREAKING CHANGE: Configurations are now returned as objects, like most
shared ESLint configurations. The `make*Config` functions are no more.
Also, everything is now exported through one file.
See comments about `no-undef`
@cwillisf cwillisf requested review from colbygk and Copilot April 30, 2025 21:52
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces function‐generated configurations with flat static configurations for both ESLint and Prettier, following the latest community conventions. It updates various test examples (both good and bad) to reflect the new configuration style, revises legacy configuration files, and updates the documentation accordingly.

Reviewed Changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/recommended/react.good.jsx Valid React example using the new flat configuration.
test/recommended/react.bad.jsx Bad React test case demonstrating expected ESLint errors.
test/recommended/plain.good.ts Valid plain TypeScript example.
test/recommended/plain.good.mjs Valid plain JavaScript example.
test/recommended/plain.bad.ts Bad TypeScript test case with expected errors.
test/recommended/plain.bad.mjs Bad JavaScript test case with expected errors (e.g. unexpected JSX).
test/recommended/eslint.config.mjs ESLint configuration file updated to use flat configs.
test/eslint.test.mjs Linting tests updated to reflect new configuration results.
prettier.config.mjs Prettier configuration now exports a recommended config directly.
lib/prettier.mjs Legacy Prettier config module updated to export the new recommended config.
lib/legacy/*.mjs Legacy configuration files updated with proper type annotations.
lib/index.mjs Re-exports flat ESLint and Prettier configuration objects.
lib/eslint.mjs ESLint configurations revamped to align with flat configuration style.
eslint.config.mjs Main ESLint config file now uses the flat configuration API.
README.md Documentation updated to explain the flat configuration usage.
Files not reviewed (2)
  • package.json: Language not supported
  • test/snapshots/eslint.test.mjs.snap: Language not supported
Comments suppressed due to low confidence (1)

lib/eslint.mjs:353

  • The variable 'eslintConfigPrettier' is referenced but not defined. Consider replacing it with the appropriate Prettier configuration (for example, 'prettierConfigScratch.recommended') or importing its definition.
eslintConfigPrettier,

Copy link

@georgyangelov georgyangelov left a comment

Choose a reason for hiding this comment

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

yay, tests 🎉

Clever idea with the snapshots

@cwillisf cwillisf merged commit 71edf06 into master May 5, 2025
2 checks passed
@cwillisf cwillisf deleted the flatter branch May 5, 2025 20:43
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants