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

Updated to SVGO 2 #565

Closed
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion __fixtures__/withSvgoYml/.svgo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"plugins": [{"removeTitle": false}]}
{"plugins": [{"name": "removeTitle", "active": false}]}
3 changes: 2 additions & 1 deletion __fixtures__/withSvgoYml/.svgo.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
plugins:
- removeTitle: false
- name: removeTitle
active: false
2 changes: 1 addition & 1 deletion packages/cli/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('cli', () => {

it('should support --svgo-config as json', async () => {
const result = await cli(
`--svgo-config '{"plugins": [{"removeTitle": false}]}' __fixtures__/simple/file.svg`,
`--svgo-config '{"plugins": [{"name": "removeTitle", "active": false}]}' __fixtures__/simple/file.svg`,
)
expect(result).toMatchSnapshot()
}, 10000)
Expand Down
72 changes: 64 additions & 8 deletions packages/core/src/__snapshots__/config.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ Object {
"runtimeConfig": true,
"svgProps": null,
"svgo": true,
"svgoConfig": null,
"svgoConfig": Object {
"plugins": Array [
Object {
"active": true,
"name": "convertStyleToAttrs",
},
],
},
"template": null,
"titleProp": false,
"typescript": false,
Expand Down Expand Up @@ -51,7 +58,14 @@ Object {
"runtimeConfig": true,
"svgProps": null,
"svgo": true,
"svgoConfig": null,
"svgoConfig": Object {
"plugins": Array [
Object {
"active": true,
"name": "convertStyleToAttrs",
},
],
},
"template": null,
"titleProp": false,
"typescript": false,
Expand All @@ -75,7 +89,14 @@ Object {
"runtimeConfig": true,
"svgProps": null,
"svgo": true,
"svgoConfig": null,
"svgoConfig": Object {
"plugins": Array [
Object {
"active": true,
"name": "convertStyleToAttrs",
},
],
},
"template": null,
"titleProp": false,
"typescript": false,
Expand Down Expand Up @@ -104,7 +125,14 @@ Object {
"runtimeConfig": true,
"svgProps": null,
"svgo": true,
"svgoConfig": null,
"svgoConfig": Object {
"plugins": Array [
Object {
"active": true,
"name": "convertStyleToAttrs",
},
],
},
"template": null,
"titleProp": false,
"typescript": false,
Expand Down Expand Up @@ -133,7 +161,14 @@ Object {
"runtimeConfig": true,
"svgProps": null,
"svgo": true,
"svgoConfig": null,
"svgoConfig": Object {
"plugins": Array [
Object {
"active": true,
"name": "convertStyleToAttrs",
},
],
},
"template": null,
"titleProp": false,
"typescript": false,
Expand Down Expand Up @@ -162,7 +197,14 @@ Object {
"runtimeConfig": true,
"svgProps": null,
"svgo": true,
"svgoConfig": null,
"svgoConfig": Object {
"plugins": Array [
Object {
"active": true,
"name": "convertStyleToAttrs",
},
],
},
"template": null,
"titleProp": false,
"typescript": false,
Expand All @@ -186,7 +228,14 @@ Object {
"runtimeConfig": true,
"svgProps": null,
"svgo": true,
"svgoConfig": null,
"svgoConfig": Object {
"plugins": Array [
Object {
"active": true,
"name": "convertStyleToAttrs",
},
],
},
"template": null,
"titleProp": false,
"typescript": false,
Expand Down Expand Up @@ -215,7 +264,14 @@ Object {
"runtimeConfig": true,
"svgProps": null,
"svgo": true,
"svgoConfig": null,
"svgoConfig": Object {
"plugins": Array [
Object {
"active": true,
"name": "convertStyleToAttrs",
},
],
},
"template": null,
"titleProp": false,
"typescript": false,
Expand Down
52 changes: 28 additions & 24 deletions packages/core/src/__snapshots__/convert.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand All @@ -36,7 +36,7 @@ function SvgComponent() {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand All @@ -59,7 +59,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand Down Expand Up @@ -88,7 +88,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand All @@ -112,7 +112,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<Path d=\\"M51 37L37 51M51 51L37 37\\" />
<Path d=\\"M51 37 37 51M51 51 37 37\\" />
</G>
</Svg>
)
Expand All @@ -136,7 +136,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<Svg.Path d=\\"M51 37L37 51M51 51L37 37\\" />
<Svg.Path d=\\"M51 37 37 51M51 51 37 37\\" />
</Svg.G>
</Svg>
)
Expand Down Expand Up @@ -166,7 +166,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<Path d=\\"M51 37L37 51M51 51L37 37\\" />
<Path d=\\"M51 37 37 51M51 51 37 37\\" />
</G>
</Svg>
)
Expand All @@ -190,7 +190,7 @@ function SvgComponent() {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<Path d=\\"M51 37L37 51M51 51L37 37\\" />
<Path d=\\"M51 37 37 51M51 51 37 37\\" />
</G>
</Svg>
)
Expand Down Expand Up @@ -220,7 +220,7 @@ function SvgComponent(props, svgRef) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<Path d=\\"M51 37L37 51M51 51L37 37\\" />
<Path d=\\"M51 37 37 51M51 51 37 37\\" />
</G>
</Svg>
)
Expand Down Expand Up @@ -250,7 +250,7 @@ function SvgComponent(props, svgRef) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand Down Expand Up @@ -281,7 +281,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand All @@ -304,7 +304,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand All @@ -327,7 +327,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand Down Expand Up @@ -378,7 +378,7 @@ exports[`convert config should support options 14 1`] = `
"import * as React from \\"react\\";

function SvgComponent(props) {
return <svg width={88} height={88} xmlns=\\"http://www.w3.org/2000/svg\\" {...props}><g stroke=\\"#063855\\" strokeWidth={2} fill=\\"none\\" fillRule=\\"evenodd\\" strokeLinecap=\\"square\\"><path d=\\"M51 37L37 51M51 51L37 37\\" /></g></svg>;
return <svg width={88} height={88} xmlns=\\"http://www.w3.org/2000/svg\\" {...props}><g stroke=\\"#063855\\" strokeWidth={2} fill=\\"none\\" fillRule=\\"evenodd\\" strokeLinecap=\\"square\\"><path d=\\"M51 37 37 51M51 51 37 37\\" /></g></svg>;
}

export default SvgComponent;"
Expand Down Expand Up @@ -411,7 +411,7 @@ function SvgComponent({ title, titleId, ...props }) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand All @@ -434,7 +434,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand All @@ -458,7 +458,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand Down Expand Up @@ -505,7 +505,7 @@ function SvgComponent(props) {
fillRule=\\"evenodd\\"
strokeLinecap=\\"square\\"
>
<path d=\\"M51 37L37 51M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" />
</g>
</svg>
)
Expand Down Expand Up @@ -599,9 +599,8 @@ function SvgComponent(props) {
strokeLinecap=\\"square\\"
>
<g id=\\"prefix__Dismiss\\" stroke=\\"#063855\\" strokeWidth={2}>
<path d=\\"M51 37L37 51M51 51L37 37\\" id=\\"prefix__Shape\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" id=\\"prefix__Shape\\" />
</g>
<style />
</g>
</svg>
)
Expand All @@ -616,7 +615,13 @@ exports[`convert should remove null characters 1`] = `

function SvgComponent(props) {
return (
<svg xmlns=\\"http://www.w3.org/2000/svg\\" width={25} height={25} {...props}>
<svg
xmlns=\\"http://www.w3.org/2000/svg\\"
width={25}
height={25}
xmlSpace=\\"preserve\\"
{...props}
>
<path
d=\\"M19.4 24.5H5.6c-2.8 0-5.1-2.3-5.1-5.1V5.6C.5 2.8 2.8.5 5.6.5h13.8c2.8 0 5.1 2.3 5.1 5.1v13.8c0 2.8-2.3 5.1-5.1 5.1z\\"
fill=\\"#fff\\"
Expand All @@ -637,12 +642,11 @@ exports[`convert should remove style tags 1`] = `
function SvgComponent(props) {
return (
<svg width={88} height={88} xmlns=\\"http://www.w3.org/2000/svg\\" {...props}>
<style />
<g fill=\\"red\\" fillRule=\\"evenodd\\" strokeLinecap=\\"square\\">
<g id=\\"prefix__Dismiss\\" stroke=\\"#063855\\" strokeWidth={2}>
<path d=\\"M51 37L37 51\\" id=\\"prefix__Shape\\" />
<path d=\\"M51 51L37 37\\" />
<path d=\\"M51 37 37 51M51 51 37 37\\" id=\\"prefix__Shape\\" />
</g>
<style />
</g>
</svg>
)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const DEFAULT_CONFIG = {
replaceAttrValues: null,
svgProps: null,
svgo: true,
svgoConfig: null,
svgoConfig: { plugins: [{ name: 'convertStyleToAttrs', active: true }]},
Copy link
Contributor

Choose a reason for hiding this comment

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

This plugin is error prone and was disabled because of it. I don't recommend to enable it.

template: null,
titleProp: false,
runtimeConfig: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var _ref = /*#__PURE__*/React.createElement(\\"g\\", {
fillRule: \\"evenodd\\",
strokeLinecap: \\"square\\"
}, /*#__PURE__*/React.createElement(\\"path\\", {
d: \\"M51 37L37 51M51 51L37 37\\"
d: \\"M51 37 37 51M51 51 37 37\\"
}));

function SvgIcon(props) {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-svgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"dependencies": {
"cosmiconfig": "^7.0.0",
"deepmerge": "^4.2.2",
"svgo": "^1.2.2"
"svgo": "^2.3.0"

Choose a reason for hiding this comment

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

Could you update this to ^2.3.1 so that it incorporates the css-select vulnerability fix?

}
}
Loading