From fee216ea46323ee64bc96fa2b06f7547b5f8e6bb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2020 13:30:47 -0400 Subject: [PATCH] Update dependency eslint to v7 (#420) * Update dependency eslint to v7 * Switch to eslint-config-problems; format code Co-authored-by: Renovate Bot Co-authored-by: Ryan Zimmerman --- index.js | 32 +++++++++---------- lib/parse-statements.js | 9 +++--- lib/process-content.js | 6 ++-- lib/resolve-id.js | 2 +- package.json | 10 +++--- test/custom-load.js | 1 + test/custom-resolve.js | 1 + test/custom-syntax-parser.js | 1 + test/filter.js | 1 + test/fixtures/imports/modules/main-js/main.js | 1 + test/helpers/check-fixture.js | 5 +-- test/import-events.js | 1 + test/import.js | 1 + test/lint.js | 1 + test/media.js | 1 + test/order.js | 1 + test/plugins.js | 1 + test/resolve.js | 1 + test/syntax-error.js | 1 + 19 files changed, 45 insertions(+), 32 deletions(-) diff --git a/index.js b/index.js index 0687f65c..6b788492 100755 --- a/index.js +++ b/index.js @@ -10,18 +10,16 @@ const processContent = require("./lib/process-content") const parseStatements = require("./lib/parse-statements") function AtImport(options) { - options = Object.assign( - { - root: process.cwd(), - path: [], - skipDuplicates: true, - resolve: resolveId, - load: loadContent, - plugins: [], - addModulesDirectories: [], - }, - options - ) + options = { + root: process.cwd(), + path: [], + skipDuplicates: true, + resolve: resolveId, + load: loadContent, + plugins: [], + addModulesDirectories: [], + ...options, + } options.root = path.resolve(options.root) @@ -59,7 +57,7 @@ function AtImport(options) { if (index === 0) return if (stmt.parent) { - const before = stmt.parent.node.raws.before + const { before } = stmt.parent.node.raws if (stmt.type === "nodes") stmt.nodes[0].raws.before = before else stmt.node.raws.before = before } else if (stmt.type === "nodes") { @@ -76,8 +74,8 @@ function AtImport(options) { } else if (stmt.type === "media") stmt.node.params = stmt.media.join(", ") else { - const nodes = stmt.nodes - const parent = nodes[0].parent + const { nodes } = stmt + const { parent } = nodes[0] const mediaNode = atRule({ name: "media", params: stmt.media.join(", "), @@ -203,7 +201,7 @@ function AtImport(options) { result.messages.push({ type: "dependency", plugin: "postcss-import", - file: file, + file, parent: sourceFile, }) }) @@ -224,7 +222,7 @@ function AtImport(options) { function loadImportContent(result, stmt, filename, options, state) { const atRule = stmt.node - const media = stmt.media + const { media } = stmt if (options.skipDuplicates) { // skip files already imported at the same scope if ( diff --git a/lib/parse-statements.js b/lib/parse-statements.js index 228e451d..ac25e925 100644 --- a/lib/parse-statements.js +++ b/lib/parse-statements.js @@ -4,7 +4,7 @@ const valueParser = require("postcss-value-parser") // extended tooling -const stringify = valueParser.stringify +const { stringify } = valueParser function split(params, start) { const list = [] @@ -35,7 +35,7 @@ module.exports = function (result, styles) { if (nodes.length) { statements.push({ type: "nodes", - nodes: nodes, + nodes, media: [], }) nodes = [] @@ -47,7 +47,7 @@ module.exports = function (result, styles) { if (nodes.length) { statements.push({ type: "nodes", - nodes: nodes, + nodes, media: [], }) } @@ -76,7 +76,8 @@ function parseImport(result, atRule) { "@import must precede all other statements (besides @charset)", { node: atRule } ) - } else prev = getPrev(prev) + } + prev = getPrev(prev) } while (prev) } diff --git a/lib/process-content.js b/lib/process-content.js index 3de45ac1..531e7745 100644 --- a/lib/process-content.js +++ b/lib/process-content.js @@ -10,7 +10,7 @@ const postcss = require("postcss") let sugarss module.exports = function processContent(result, content, filename, options) { - const plugins = options.plugins + const { plugins } = options const ext = path.extname(filename) const parserList = [] @@ -20,9 +20,7 @@ module.exports = function processContent(result, content, filename, options) { if (!sugarss) { try { sugarss = require("sugarss") - } catch (e) { - // Ignore - } + } catch {} // Ignore } if (sugarss) return runPostcss(content, filename, plugins, [sugarss]) } diff --git a/lib/resolve-id.js b/lib/resolve-id.js index e342ad06..ffef034c 100644 --- a/lib/resolve-id.js +++ b/lib/resolve-id.js @@ -17,7 +17,7 @@ module.exports = function (id, base, options) { const resolveOpts = { basedir: base, moduleDirectory: moduleDirectories.concat(options.addModulesDirectories), - paths: paths, + paths, extensions: [".css"], packageFilter: function processPackage(pkg) { if (pkg.style) pkg.main = pkg.style diff --git a/package.json b/package.json index 0660b082..9465ca0e 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,8 @@ }, "devDependencies": { "ava": "^3.0.0", - "eslint": "^5.0.0", - "eslint-config-i-am-meticulous": "^11.0.0", - "eslint-plugin-import": "^2.17.1", + "eslint": "^7.0.0", + "eslint-config-problems": "^5.0.0", "eslint-plugin-prettier": "^3.0.0", "postcss": "^8.0.0", "postcss-scss": "^3.0.0", @@ -46,7 +45,10 @@ "test": "ava" }, "eslintConfig": { - "extends": "eslint-config-i-am-meticulous", + "extends": "eslint-config-problems", + "env": { + "node": true + }, "plugins": [ "prettier" ], diff --git a/test/custom-load.js b/test/custom-load.js index eb306d3b..872b15a7 100644 --- a/test/custom-load.js +++ b/test/custom-load.js @@ -1,3 +1,4 @@ +"use strict" // external tooling const test = require("ava") diff --git a/test/custom-resolve.js b/test/custom-resolve.js index e3aafb32..130f9dab 100644 --- a/test/custom-resolve.js +++ b/test/custom-resolve.js @@ -1,3 +1,4 @@ +"use strict" // builtin tooling const path = require("path") diff --git a/test/custom-syntax-parser.js b/test/custom-syntax-parser.js index a9b66c15..729f6b29 100644 --- a/test/custom-syntax-parser.js +++ b/test/custom-syntax-parser.js @@ -1,3 +1,4 @@ +"use strict" // external tooling const test = require("ava") const scss = require("postcss-scss") diff --git a/test/filter.js b/test/filter.js index 724be5e3..1e2f70d6 100644 --- a/test/filter.js +++ b/test/filter.js @@ -1,3 +1,4 @@ +"use strict" // external tooling const test = require("ava") diff --git a/test/fixtures/imports/modules/main-js/main.js b/test/fixtures/imports/modules/main-js/main.js index 4ba52ba2..588e23ee 100644 --- a/test/fixtures/imports/modules/main-js/main.js +++ b/test/fixtures/imports/modules/main-js/main.js @@ -1 +1,2 @@ +"use strict" module.exports = {} diff --git a/test/helpers/check-fixture.js b/test/helpers/check-fixture.js index cf217680..480d04b0 100644 --- a/test/helpers/check-fixture.js +++ b/test/helpers/check-fixture.js @@ -15,8 +15,8 @@ function read(name, ext) { } module.exports = function (t, file, opts, postcssOpts, warnings) { - opts = Object.assign({ path: "test/fixtures/imports" }, opts) - postcssOpts = Object.assign({ from: undefined }, postcssOpts) + opts = { path: "test/fixtures/imports", ...opts } + postcssOpts = { from: undefined, ...postcssOpts } if (typeof file === "string") file = { name: file, ext: ".css" } const { name, ext } = file @@ -27,6 +27,7 @@ module.exports = function (t, file, opts, postcssOpts, warnings) { const expected = read(`${name}.expected`) // handy thing: checkout actual in the *.actual.css file fs.writeFile(`test/fixtures/${name}.actual.css`, actual, err => { + // eslint-disable-next-line no-console if (err) console.warn(`Warning: ${err}; not fatal, continuing`) }) t.is(actual, expected) diff --git a/test/import-events.js b/test/import-events.js index 00a0489c..638754ea 100644 --- a/test/import-events.js +++ b/test/import-events.js @@ -1,3 +1,4 @@ +"use strict" // builtin tooling const { readFileSync } = require("fs") const { resolve } = require("path") diff --git a/test/import.js b/test/import.js index 76e9053a..9b637c22 100644 --- a/test/import.js +++ b/test/import.js @@ -1,3 +1,4 @@ +"use strict" // builtin tooling const { readFileSync } = require("fs") const path = require("path") diff --git a/test/lint.js b/test/lint.js index c6efdce3..6361ae71 100644 --- a/test/lint.js +++ b/test/lint.js @@ -1,3 +1,4 @@ +"use strict" // external tooling const test = require("ava") const postcss = require("postcss") diff --git a/test/media.js b/test/media.js index 99781fe4..cdac2144 100644 --- a/test/media.js +++ b/test/media.js @@ -1,3 +1,4 @@ +"use strict" // external tooling const test = require("ava") diff --git a/test/order.js b/test/order.js index d6e405b1..86af6642 100644 --- a/test/order.js +++ b/test/order.js @@ -1,3 +1,4 @@ +"use strict" // external tooling const test = require("ava") diff --git a/test/plugins.js b/test/plugins.js index c8b63b43..20cee886 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -1,3 +1,4 @@ +"use strict" // external tooling const test = require("ava") const postcss = require("postcss") diff --git a/test/resolve.js b/test/resolve.js index 36475414..2be4794c 100644 --- a/test/resolve.js +++ b/test/resolve.js @@ -1,3 +1,4 @@ +"use strict" // external tooling const test = require("ava") diff --git a/test/syntax-error.js b/test/syntax-error.js index feba2c0a..98330607 100644 --- a/test/syntax-error.js +++ b/test/syntax-error.js @@ -1,3 +1,4 @@ +"use strict" // builtin tooling const fs = require("fs")