From b5d0d4de4634c5c816567db76674b1679440a782 Mon Sep 17 00:00:00 2001 From: Maxime Brazeilles Date: Mon, 29 Jan 2024 13:30:51 +0100 Subject: [PATCH 1/3] [CHORE] Long overdue dep update --- package.json | 4 +- packages/mjml-accordion/src/Accordion.js | 4 +- packages/mjml-accordion/src/AccordionText.js | 4 +- packages/mjml-accordion/src/AccordionTitle.js | 11 +- packages/mjml-carousel/src/Carousel.js | 10 +- packages/mjml-carousel/src/CarouselImage.js | 2 +- packages/mjml-cli/package.json | 4 +- packages/mjml-cli/src/client.js | 6 +- .../mjml-cli/src/commands/outputToConsole.js | 2 +- packages/mjml-cli/src/helpers/fileContext.js | 7 +- packages/mjml-column/src/index.js | 7 +- packages/mjml-core/package.json | 2 +- packages/mjml-core/src/createComponent.js | 18 +- .../mjml-core/src/helpers/mediaQueries.js | 13 +- packages/mjml-core/src/helpers/mjmlconfig.js | 15 +- .../mjml-core/src/helpers/shorthandParser.js | 2 +- packages/mjml-core/src/index.js | 25 +- packages/mjml-hero/src/index.js | 20 +- packages/mjml-migrate/package.json | 2 +- packages/mjml-parser-xml/package.json | 4 +- packages/mjml-raw/src/index.js | 2 +- test.js | 1 - yarn.lock | 3642 ++++++++++------- 23 files changed, 2253 insertions(+), 1554 deletions(-) diff --git a/package.json b/package.json index 95f507375..5be26fb74 100755 --- a/package.json +++ b/package.json @@ -24,11 +24,11 @@ "babel-plugin-lodash": "^3.3.4", "eslint": "^6.8.0", "eslint-config-airbnb-base": "^14.1.0", - "eslint-config-prettier": "^6.11.0", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.21.1", "lerna": "^3.22.1", "open": "^7.3.0", - "prettier": "^2.0.5", + "prettier": "^3.2.4", "rimraf": "^3.0.2" } } diff --git a/packages/mjml-accordion/src/Accordion.js b/packages/mjml-accordion/src/Accordion.js index 085ab0959..8e85c97e3 100644 --- a/packages/mjml-accordion/src/Accordion.js +++ b/packages/mjml-accordion/src/Accordion.js @@ -92,8 +92,8 @@ export default class MjAccordion extends BodyComponent { return `
diff --git a/packages/mjml-accordion/src/AccordionTitle.js b/packages/mjml-accordion/src/AccordionTitle.js index a441113b0..b60490cfe 100644 --- a/packages/mjml-accordion/src/AccordionTitle.js +++ b/packages/mjml-accordion/src/AccordionTitle.js @@ -100,17 +100,18 @@ export default class MjAccordionTitle extends BodyComponent { render() { const contentElements = [this.renderTitle(), this.renderIcons()] - const content = (this.getAttribute('icon-position') === 'right' - ? contentElements - : contentElements.reverse() + const content = ( + this.getAttribute('icon-position') === 'right' + ? contentElements + : contentElements.reverse() ).join('\n') return `
diff --git a/packages/mjml-carousel/src/Carousel.js b/packages/mjml-carousel/src/Carousel.js index fd8c5ec57..2a13fae7a 100644 --- a/packages/mjml-carousel/src/Carousel.js +++ b/packages/mjml-carousel/src/Carousel.js @@ -186,9 +186,9 @@ export default class MjCarousel extends BodyComponent { } .mj-carousel-${carouselId}-radio-1:checked ${repeat( - '+ *', - length - 1, - )}+ .mj-carousel-content .mj-carousel-${carouselId}-thumbnail-1 { + '+ *', + length - 1, + )}+ .mj-carousel-content .mj-carousel-${carouselId}-thumbnail-1 { border-color: transparent; } } @@ -344,8 +344,8 @@ export default class MjCarousel extends BodyComponent { ${this.htmlAttributes({ style: 'carousel.table', border: '0', - 'cellpadding': '0', - 'cellspacing': '0', + cellpadding: '0', + cellspacing: '0', width: '100%', role: 'presentation', class: 'mj-carousel-main', diff --git a/packages/mjml-carousel/src/CarouselImage.js b/packages/mjml-carousel/src/CarouselImage.js index d993a37e1..f975f99ac 100644 --- a/packages/mjml-carousel/src/CarouselImage.js +++ b/packages/mjml-carousel/src/CarouselImage.js @@ -142,7 +142,7 @@ export default class MjCarouselImage extends BodyComponent { > ${ href - ? `${image}` + ? `${image}` : image } diff --git a/packages/mjml-cli/package.json b/packages/mjml-cli/package.json index efe24df18..5a30d4686 100644 --- a/packages/mjml-cli/package.json +++ b/packages/mjml-cli/package.json @@ -27,7 +27,7 @@ "dependencies": { "@babel/runtime": "^7.14.6", "chokidar": "^3.0.0", - "glob": "^7.1.1", + "glob": "^10.3.10", "html-minifier": "^4.0.0", "js-beautify": "^1.6.14", "lodash": "^4.17.21", @@ -35,7 +35,7 @@ "mjml-migrate": "4.14.1", "mjml-parser-xml": "4.14.1", "mjml-validator": "4.13.0", - "yargs": "^16.1.0" + "yargs": "^17.7.2" }, "devDependencies": { "@babel/cli": "^7.8.4", diff --git a/packages/mjml-cli/src/client.js b/packages/mjml-cli/src/client.js index 87c3db9c4..587afd63d 100644 --- a/packages/mjml-cli/src/client.js +++ b/packages/mjml-cli/src/client.js @@ -322,7 +322,11 @@ export default async () => { } case 's': { const addFileHeaderComment = !argv.noStdoutFileComment - Promise.all(convertedStream.map(converted => outputToConsole(converted, addFileHeaderComment))) + Promise.all( + convertedStream.map((converted) => + outputToConsole(converted, addFileHeaderComment), + ), + ) .then(() => (process.exitCode = EXIT_CODE)) // eslint-disable-line no-return-assign .catch(() => (process.exitCode = 1)) // eslint-disable-line no-return-assign break diff --git a/packages/mjml-cli/src/commands/outputToConsole.js b/packages/mjml-cli/src/commands/outputToConsole.js index 0d7856dc1..77456af91 100644 --- a/packages/mjml-cli/src/commands/outputToConsole.js +++ b/packages/mjml-cli/src/commands/outputToConsole.js @@ -1,7 +1,7 @@ export default ({ compiled: { html }, file }, addFileHeaderComment) => new Promise((resolve) => { let output = '' - if(addFileHeaderComment) { + if (addFileHeaderComment) { output = `\n` } output += `${html}\n` diff --git a/packages/mjml-cli/src/helpers/fileContext.js b/packages/mjml-cli/src/helpers/fileContext.js index 8ccf7d7b6..90ebf2155 100644 --- a/packages/mjml-cli/src/helpers/fileContext.js +++ b/packages/mjml-cli/src/helpers/fileContext.js @@ -1,11 +1,12 @@ import fs from 'fs' import path from 'path' -const includeRegexp = /]+path=['"](.*(?:\.mjml|\.css|\.html))['"]\s*[^<>]*(\/>|>\s*<\/mj-include>)/gi +const includeRegexp = + /]+path=['"](.*(?:\.mjml|\.css|\.html))['"]\s*[^<>]*(\/>|>\s*<\/mj-include>)/gi -const ensureIncludeIsSupportedFile = (file) => +const ensureIncludeIsSupportedFile = (file) => path.extname(file).match(/\.mjml|\.css|\.html/) ? file : `${file}.mjml` - + const error = (e) => console.error(e.stack || e) // eslint-disable-line no-console export default (baseFile, filePath) => { diff --git a/packages/mjml-column/src/index.js b/packages/mjml-column/src/index.js index f99768191..d40d02b19 100644 --- a/packages/mjml-column/src/index.js +++ b/packages/mjml-column/src/index.js @@ -138,7 +138,7 @@ export default class MjColumn extends BodyComponent { return width case 'px': default: - return `${parsedWidth / parseInt(containerWidth, 10) * 100}%` + return `${(parsedWidth / parseInt(containerWidth, 10)) * 100}%` } } @@ -267,9 +267,8 @@ export default class MjColumn extends BodyComponent { padding: component.getAttribute('padding'), 'padding-top': component.getAttribute('padding-top'), 'padding-right': component.getAttribute('padding-right'), - 'padding-bottom': component.getAttribute( - 'padding-bottom', - ), + 'padding-bottom': + component.getAttribute('padding-bottom'), 'padding-left': component.getAttribute('padding-left'), 'word-break': 'break-word', }, diff --git a/packages/mjml-core/package.json b/packages/mjml-core/package.json index cc122aa56..30a937692 100644 --- a/packages/mjml-core/package.json +++ b/packages/mjml-core/package.json @@ -27,7 +27,7 @@ "detect-node": "^2.0.4", "html-minifier": "^4.0.0", "js-beautify": "^1.6.14", - "juice": "^9.0.0", + "juice": "^10.0.0", "lodash": "^4.17.21", "mjml-migrate": "4.14.1", "mjml-parser-xml": "4.14.1", diff --git a/packages/mjml-core/src/createComponent.js b/packages/mjml-core/src/createComponent.js index 1be1ef120..0d4c655e5 100644 --- a/packages/mjml-core/src/createComponent.js +++ b/packages/mjml-core/src/createComponent.js @@ -99,7 +99,7 @@ class Component { ignoreIncludes: true, }) return partialMjml.children - .map(child => this.context.processing(child, this.context)) + .map((child) => this.context.processing(child, this.context)) .join('') } @@ -158,7 +158,7 @@ export class BodyComponent extends Component { htmlAttributes(attributes) { const specialAttributes = { - style: v => this.styles(v), + style: (v) => this.styles(v), default: identity, } @@ -199,7 +199,7 @@ export class BodyComponent extends Component { renderChildren(children, options = {}) { const { props = {}, - renderer = component => component.render(), + renderer = (component) => component.render(), attributes = {}, rawXML = false, } = options @@ -207,20 +207,22 @@ export class BodyComponent extends Component { children = children || this.props.children if (rawXML) { - return children.map(child => jsonToXML(child)).join('\n') + return children.map((child) => jsonToXML(child)).join('\n') } const sibling = children.length - const rawComponents = filter(this.context.components, c => c.isRawElement()) + const rawComponents = filter(this.context.components, (c) => + c.isRawElement(), + ) const nonRawSiblings = children.filter( - child => !find(rawComponents, c => c.getTagName() === child.tagName), + (child) => !find(rawComponents, (c) => c.getTagName() === child.tagName), ).length let output = '' let index = 0 - forEach(children, children => { + forEach(children, (children) => { const component = initComponent({ name: children.tagName, initialDatas: { @@ -260,7 +262,7 @@ export class HeadComponent extends Component { handlerChildren() { const { children } = this.props - return children.map(children => { + return children.map((children) => { const component = initComponent({ name: children.tagName, initialDatas: { diff --git a/packages/mjml-core/src/helpers/mediaQueries.js b/packages/mjml-core/src/helpers/mediaQueries.js index bae81fefd..a3bd1396b 100644 --- a/packages/mjml-core/src/helpers/mediaQueries.js +++ b/packages/mjml-core/src/helpers/mediaQueries.js @@ -1,15 +1,16 @@ import { map, isEmpty } from 'lodash' // eslint-disable-next-line import/prefer-default-export -export default function buildMediaQueriesTags(breakpoint, mediaQueries = {}, options = {}) { +export default function buildMediaQueriesTags( + breakpoint, + mediaQueries = {}, + options = {}, +) { if (isEmpty(mediaQueries)) { return '' } - const { - forceOWADesktop = false, - printerSupport = false, - } = options + const { forceOWADesktop = false, printerSupport = false } = options const baseMediaQueries = map( mediaQueries, @@ -31,7 +32,7 @@ export default function buildMediaQueriesTags(breakpoint, mediaQueries = {}, opt ${thunderbirdMediaQueries.join('\n')} ${ - printerSupport + printerSupport ? `