Expected Behavior
Given this test added in #1938 merged into 6.0.3:
|
// Should be replaced - typeof window followed by dot |
|
if (typeof window.document !== 'undefined') { |
|
console.log('has document'); |
|
} |
|
description: 'should not replace when followed by valid identifier characters', |
|
options: { |
|
values: { |
|
'typeof window': '"undefined"' |
|
}, |
|
preventAssignment: true |
|
} |
Comment strongly suggests it
should produce the following replacement:
// Should be replaced - typeof window followed by dot
if ("undefined".document !== 'undefined') {
console.log('has document');
}
Actual Behavior
The snapshot stored by vitest does not actually replace this:
|
// Should be replaced - "undefined" followed by dot␊ |
|
if (typeof window.document !== 'undefined') {␊ |
|
console.log('has document');␊ |
|
}` |
And, there is an older fixture + snapshot which directly conflicts with this interpretation, under replace-nothing:
|
console.log('as-it'); // eslint-disable-line |
|
console.log(typeof window.document); // eslint-disable-line |
|
description: 'replaces nothing', |
|
options: { |
|
'typeof window': `"object"` |
|
} |
Vitest Snapshot:
|
## replace-nothing: replaces nothing |
|
|
|
> Snapshot 1 |
|
|
|
`console.log('as-it'); // eslint-disable-line␊ |
|
console.log(typeof window.document); // eslint-disable-line` |
Additional Information
The older PR which introduced the replace-nothing test was #903 which had the following comment:
Personally, I believe it's dangerous to replace VERSION in the case you highlighted by default:
if (VERSION.startsWith('foo')) {
// things
}
In the case above with the previous default to match VERSION when used with a . or nested access, you would need to know all of your dependencies' code, not to mess up when replacing.
Originally posted by @o-alexandrov in #903 (comment)
What is the current intended behavior? I don't think these two tests can co-exist unless they're testing differently configured delimiters.
@rollup/plugin-replaceExpected Behavior
Given this test added in #1938 merged into 6.0.3:
plugins/packages/replace/test/fixtures/form/dollar-sign-boundary/input.js
Lines 17 to 20 in 639f456
plugins/packages/replace/test/fixtures/form/dollar-sign-boundary/_config.js
Lines 2 to 8 in 639f456
Comment strongly suggests it should produce the following replacement:
Actual Behavior
The snapshot stored by vitest does not actually replace this:
plugins/packages/replace/test/snapshots/form.js.md
Lines 43 to 46 in 639f456
And, there is an older fixture + snapshot which directly conflicts with this interpretation, under
replace-nothing:plugins/packages/replace/test/fixtures/form/replace-nothing/input.js
Lines 1 to 2 in 639f456
plugins/packages/replace/test/fixtures/form/replace-nothing/_config.js
Lines 2 to 5 in 639f456
Vitest Snapshot:
plugins/packages/replace/test/snapshots/form.js.md
Lines 76 to 81 in 639f456
Additional Information
The older PR which introduced the
replace-nothingtest was #903 which had the following comment:Originally posted by @o-alexandrov in #903 (comment)
What is the current intended behavior? I don't think these two tests can co-exist unless they're testing differently configured
delimiters.