Skip to content

Commit

Permalink
Migrate to ES Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
workeffortwaste committed Feb 10, 2022
1 parent 208af09 commit d27e269
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 26 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'standard'
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
rules: {
}
}
15 changes: 0 additions & 15 deletions .eslintrc.js

This file was deleted.

22 changes: 15 additions & 7 deletions layout-shift-gif.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@
*/

/* Args */
const yargs = require('yargs')
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'

const options = yargs
/* Puppeteer */
import puppeteer from 'puppeteer'

/* Misc */
import fs from 'fs'
import tmp from 'tmp'

/* Image generation */
import GIFEncoder from 'gif-encoder-2'
import pkg from 'canvas'
const { createCanvas, loadImage } = pkg

const options = yargs(hideBin(process.argv))
.usage('Usage: --url <url> --device [mobile|desktop] --cookies <filename> --output <filename> --type <new|old>')
.example('layout-shift-gif --url https://blacklivesmatter.com/ --device mobile --output layout-shift.gif')
.default({ device: 'mobile', cookies: null, output: 'layout-shift.gif', type: 'new' })
Expand All @@ -21,12 +34,7 @@ const options = yargs
.demandOption(['url'])
.argv

const puppeteer = require('puppeteer')
const devices = puppeteer.devices
const { createCanvas, loadImage } = require('canvas')
const GIFEncoder = require('gif-encoder-2')
const fs = require('fs')
const tmp = require('tmp')

/* Network conditions */
const Good3G = {
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"author": "Chris Johnson (https://defaced.dev)",
"license": "ISC",
"type": "module",
"dependencies": {
"canvas": "^2.9.0",
"gif-encoder-2": "^1.0.5",
Expand All @@ -31,10 +32,10 @@
},
"homepage": "https://defaced.dev/tools/layout-shift-gif-generator/",
"devDependencies": {
"eslint": "^7.14.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1"
"eslint-plugin-promise": "^5.2.0"
}
}

0 comments on commit d27e269

Please sign in to comment.