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

ast(parser): fix bug with literals #499

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/utils/__snapshots__/ast-utils.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ exports[`utils addProperty add entry property using add 1`] = `
}],

man: () => duper,
objects: are,
objects: 'are',

super: [yeah, {
loader: 'eslint-loader'
super: ['yeah', {
loader: ''eslint-loader''
}],

nice: ':)',
man: () => duper
nice: '':)'',
man: '() => duper'
}
}"
`;

exports[`utils addProperty add entry property using init 1`] = `
"module.exports = {
entry: {
objects: are,
objects: 'are',

super: [yeah, {
loader: 'eslint-loader'
super: ['yeah', {
loader: ''eslint-loader''
}],

nice: ':)',
man: () => duper
nice: '':)'',
man: '() => duper'
}
}"
`;
Expand Down
42 changes: 21 additions & 21 deletions packages/utils/__snapshots__/recursive-parser.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ module.exports = {
foo: \\"Promise.resolve()\\",
man: \\"() => duper\\",
mode: \\"yaaa\\",
objects: are not,
objects: 'are not',

super: [op, {
test: /\\\\.(wasm|c)$/,
loader: 'pia-loader',
enforce: 'pre',
include: [asd, 'Stringy'],
super: ['op', {
test: '/\\\\.(wasm|c)$/',
loader: ''pia-loader'',
enforce: ''pre'',
include: ['asd', ''Stringy''],

options: {
formatter: 'nao'
formatter: ''nao''
}
}],

nice: '=)',
foo: Promise.resolve(),
man: () => nice!!,
mode: super-man
nice: ''=)'',
foo: 'Promise.resolve()',
man: '() => nice!!',
mode: 'super-man'
}
}
"
Expand All @@ -50,22 +50,22 @@ module.exports = {
exports[`init transforms correctly using "fixture-1" data 1`] = `
"module.exports = {
entry: {
objects: are,
objects: 'are',

super: [yeah, {
test: /\\\\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [customObj, 'Stringy'],
super: ['yeah', {
test: '/\\\\.(js|vue)$/',
loader: ''eslint-loader'',
enforce: ''pre'',
include: ['customObj', ''Stringy''],

options: {
formatter: 'someOption'
formatter: ''someOption''
}
}],

nice: ':)',
foo: Promise.resolve(),
man: () => duper
nice: '':)'',
foo: 'Promise.resolve()',
man: '() => duper'
}
};"
`;
1 change: 1 addition & 0 deletions packages/utils/ast-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ function addProperty(j, p, key, value, action) {
});
valForNode = objectExp;
} else {
value = `'${value}'`;
Copy link
Member

Choose a reason for hiding this comment

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

this is incorrect. The reason why your tests are failing on remove is because you haven't double-quoted your strings.

valForNode = createIdentifierOrLiteral(j, value);
}
let pushVal;
Expand Down