Repository navigation
test: Add FlatESLint tests with missing config files - #17164
Conversation
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
nzakas
left a comment
There was a problem hiding this comment.
The tests look good. Just left a couple suggestions.
| cwd: getFixturePath(""), | ||
| overrideConfigFile: "does-not-exist.js" | ||
| }); | ||
| await assert.rejects(() => eslint.lintText("var foo = 'bar';")); |
There was a problem hiding this comment.
Should we add the message check here too?
| await assert.rejects(() => eslint.lintText("var foo = 'bar';")); | |
| await assert.rejects(() => eslint.lintText("var foo = 'bar';"), /Could not find config file/u); |
There was a problem hiding this comment.
This is a system error thrown by fs.stat():
Error: ENOENT: no such file or directory, stat 'path/to/temp/eslint/fixtures/does-not-exist.js'.
I wanted to avoid checking error messages that we don't generate.
Perhaps /ENOENT/u?
There was a problem hiding this comment.
Maybe {code: "ENOENT"}? Looks more accurate to me. We can even add a checker function that asserts the code and uses a regex on the message property. (docs: https://nodejs.org/api/assert.html#assertrejectsasyncfn-error-message)
There was a problem hiding this comment.
I think anything that checks the expected error message is fine. I just want to make sure we are getting the error we're expecting. I'm agnostic as to the approach.
There was a problem hiding this comment.
Added { code: "ENOENT" }, thanks for the suggestion!
| cwd: getFixturePath(), | ||
| overrideConfigFile: "does-not-exist.js" | ||
| }); | ||
| await assert.rejects(() => eslint.lintFiles("undef*.js")); |
There was a problem hiding this comment.
Same, do we want to check the message?
| await assert.rejects(() => eslint.lintFiles("undef*.js")); | |
| await assert.rejects(() => eslint.lintFiles("undef*.js"), /Could not find config file/u); |
There was a problem hiding this comment.
I concur. We should check the error code and message when viable as any error can mask actual errors code (working or test).
There was a problem hiding this comment.
Added { code: "ENOENT" }
|
Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update. |
|
Not stale. All reviews have been resolved. Waiting for @nzakas's final review. |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [eslint](https://eslint.org) ([source](https://github.com/eslint/eslint)) | devDependencies | minor | [`8.41.0` -> `8.42.0`](https://renovatebot.com/diffs/npm/eslint/8.41.0/8.42.0) | --- ### Release Notes <details> <summary>eslint/eslint</summary> ### [`v8.42.0`](https://github.com/eslint/eslint/releases/tag/v8.42.0) [Compare Source](eslint/eslint@v8.41.0...v8.42.0) #### Features - [`b8448ff`](eslint/eslint@b8448ff) feat: correct no-useless-return behaviour in try statements ([#​16996](eslint/eslint#16996)) (Nitin Kumar) #### Bug Fixes - [`a589636`](eslint/eslint@a589636) fix: Config with `ignores` and without `files` should not always apply ([#​17181](eslint/eslint#17181)) (Milos Djermanovic) - [`c4fad17`](eslint/eslint@c4fad17) fix: Correct ignore message for "node_modules" subfolders ([#​17217](eslint/eslint#17217)) (Francesco Trotta) #### Documentation - [`01d7142`](eslint/eslint@01d7142) docs: Update README (GitHub Actions Bot) - [`e5182b7`](eslint/eslint@e5182b7) docs: Update README (GitHub Actions Bot) #### Chores - [`6ca5b7c`](eslint/eslint@6ca5b7c) chore: upgrade [@​eslint/js](https://github.com/eslint/js)[@​8](https://github.com/8).42.0 ([#​17236](eslint/eslint#17236)) (Milos Djermanovic) - [`67fc5e7`](eslint/eslint@67fc5e7) chore: package.json update for [@​eslint/js](https://github.com/eslint/js) release (ESLint Jenkins) - [`0892412`](eslint/eslint@0892412) refactor: remove `Identifier` listener in no-irregular-whitespace ([#​17235](eslint/eslint#17235)) (Milos Djermanovic) - [`f67d298`](eslint/eslint@f67d298) test: Add `FlatESLint` tests with missing config files ([#​17164](eslint/eslint#17164)) (Milos Djermanovic) - [`5b68d51`](eslint/eslint@5b68d51) chore: Fix `fixedsize` attribute in code path analysis DOT debug output ([#​17202](eslint/eslint#17202)) (Milos Djermanovic) - [`37432f2`](eslint/eslint@37432f2) chore: update descriptions in key-spacing tests ([#​17195](eslint/eslint#17195)) (Milos Djermanovic) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMTMuMCIsInVwZGF0ZWRJblZlciI6IjM1LjExMy4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCJ9--> Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1923 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
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:
While reviewing #17142, I noticed we didn't have tests where
eslint.config.jsis missing. In particular, a test that would confirm thatFlatESLintlint methods should throw if a config file was not found.What changes did you make? (Give an overview)
Added a few tests for
FlatESLint#lintText()andFlatESLint#lintFiles().Is there anything you'd like reviewers to focus on?