test(eslint-config): add tests for no-direct-currency-formatting rule#3964
Merged
nima-ct merged 3 commits intoFEC-753-no-direct-currency-formatting-rulefrom Apr 8, 2026
Conversation
Use Jest projects in jest.test.config.js so custom ESLint rule tests run in a node environment alongside the existing jsdom test suite.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Covers intl.formatNumber, destructured/aliased variants, Intl.NumberFormat, variable-resolved options, spread elements, and <FormattedNumber /> from react-intl. Includes cases proving the false-positive bug where non-currency <FormattedNumber /> usage (percent, decimal, no style) is incorrectly flagged.
4374ea0 to
f7413c9
Compare
The eslint-rules project inherits Babel config resolution which loads
babel-plugin-istanbul, conflicting with Jest's own coverage instrumentation.
Setting transform: {} avoids this since the rule files are plain CommonJS.
25248f5
into
FEC-753-no-direct-currency-formatting-rule
12 of 18 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
eslint-rulesJest project tojest.test.config.jsusing thenodeenvironment, since ESLint'sRuleTesterrequiresstructuredCloneand has no DOM dependencies — incompatible with the existingjsdom/MC app preset setup. The main test suite excludes the rules directory, so there's no interference. Future rule tests underpackages/eslint-config-mc-app/rules/are picked up automatically.no-direct-currency-formattingrule coveringintl.formatNumber, destructured/aliased variants (includingformatCurrency),Intl.NumberFormat, variable-resolved options, spread elements (including nested), currency in first argument,<FormattedNumber />(named, aliased, namespace, andrequireimports), and allowlisted wrapper paths (Unix + Windows).<FormattedNumber />imported fromreact-intlis flagged even for non-currency usage (style="percent",style="decimal", no style prop — via both named and namespace imports). The rule'sJSXOpeningElementhandler needs to inspect JSX attributes for currency props, similar to how theCallExpressionhandler already checks arguments.CI note
All CI failures (including starter template jobs) are caused by the same 5 intentionally-failing tests. No infrastructure or unrelated tests are broken.
Test plan
pnpm jest --config jest.test.config.js --testPathPatterns='eslint-config-mc-app/rules'runs the rule tests (43 pass, 5 fail on the known bug)pnpm testruns both the main suite and the rule tests without interference<FormattedNumber />false-positive bug is fixed in the rule, all 48 tests should pass