Skip to content
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

test: ensure that CLI tests run with FlatESLint #17884

Merged
merged 2 commits into from
Dec 21, 2023
Merged

Conversation

fasttime
Copy link
Member

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[X] Other, please explain:

Fix unit tests.

What changes did you make? (Give an overview)

The test suite for cli.execute in tests/lib/cli.js is defined twice, once for eslintrc and once for flat config:

["eslintrc", "flat"].forEach(configType => {

This PR updates the test logic so that when the tests run in flat config mode, FlatESLint is used instead of ESLint consistently, and the useFlatConfig parameter is passed to cli.execute.

Is there anything you'd like reviewers to focus on?

@eslint-github-bot eslint-github-bot bot added the chore This change is not user-facing label Dec 20, 2023
Copy link

netlify bot commented Dec 20, 2023

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit b9f9caa
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/6583e34b1cdab4000915efcf

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Did you mean to put this up as a draft?

@@ -54,10 +54,12 @@ describe("cli", () => {
*/
async function verifyESLintOpts(cmd, opts, configType) {

const ActiveESLint = configType === "flat" ? FlatESLint : ESLint;
Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, configType is always undefined when this function (verifyESLintOpts) is called, so ActiveESLint will be always the legacy ESLint.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this helper function is used only in two eslintrc-only tests.

@fasttime
Copy link
Member Author

LGTM. Did you mean to put this up as a draft?

Thanks! I rebased my branch to solve some merge conflicts. I think this should be good to go now.

@fasttime fasttime marked this pull request as ready for review December 21, 2023 07:26
@fasttime fasttime requested a review from a team as a code owner December 21, 2023 07:26
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit 595a1f6 into main Dec 21, 2023
17 checks passed
@mdjermanovic mdjermanovic deleted the fix-flat-cli-tests branch December 21, 2023 16:06
bmish added a commit to bmish/eslint that referenced this pull request Dec 27, 2023
* main: (25 commits)
  test: ensure that CLI tests run with FlatESLint (eslint#17884)
  fix!: Behavior of CLI when no arguments are passed (eslint#17644)
  docs: Update README
  Revert "feat!: Remove CodePath#currentSegments" (eslint#17890)
  feat!: Update shouldUseFlatConfig and CLI so flat config is default (eslint#17748)
  feat!: Remove CodePath#currentSegments (eslint#17756)
  chore: update dependency markdownlint-cli to ^0.38.0 (eslint#17865)
  feat!: deprecate no-new-symbol, recommend no-new-native-nonconstructor (eslint#17710)
  feat!: check for parsing errors in suggestion fixes (eslint#16639)
  feat!: assert suggestion messages are unique in rule testers (eslint#17532)
  feat!: `no-invalid-regexp` make allowConstructorFlags case-sensitive (eslint#17533)
  fix!: no-sequences rule schema correction (eslint#17878)
  feat!: Update `eslint:recommended` configuration (eslint#17716)
  feat!: drop support for string configurations in flat config array (eslint#17717)
  feat!: Remove `SourceCode#getComments()` (eslint#17715)
  feat!: Remove deprecated context methods (eslint#17698)
  feat!: Swap FlatESLint-ESLint, FlatRuleTester-RuleTester in API (eslint#17823)
  feat!: remove formatters except html, json(-with-metadata), and stylish (eslint#17531)
  feat!: Require Node.js `^18.18.0 || ^20.9.0 || >=21.1.0` (eslint#17725)
  fix: allow circular references in config (eslint#17752)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore This change is not user-facing
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

None yet

3 participants