-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
test: forbid use of named imports for fixtures #61228
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61228 +/- ##
==========================================
- Coverage 88.54% 88.53% -0.02%
==========================================
Files 704 704
Lines 208738 208738
Branches 40278 40273 -5
==========================================
- Hits 184833 184806 -27
- Misses 15914 15952 +38
+ Partials 7991 7980 -11 🚀 New features to boost your workflow:
|
| selector: `:not(VariableDeclarator[id.type="Identifier"])>CallExpression[callee.name="require"][arguments.0.value=${fixturesSpecifier}]`, | ||
| message: 'Do not destructure, use `const fixtures =` instead', | ||
| }, | ||
| ])(/^(\.\.\u002f)+common\u002ffixtures(\.js)?$/), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth passing a RegExp literal just to repeatedly stringify it? Would it be easier just to pass a string literal here?
| return path.join(fixturesDir, ...args); | ||
| args.unshift(fixturesDir); | ||
| return Reflect.apply(path.join, this, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious - what's the benefit?
Having
import { path } from '../common/fixtures.mjsresults inpathto refer to a function, which is confusing as it more often refers tonode:path. In general, most utils of this module benefits from being prefixed withfixtures.(i.e.fileURL(…)vsfixtures.fileURL(…)).Refs: #61089 (comment)