Skip to content

Commit fee216e

Browse files
renovate[bot]renovate-botRyanZim
authored
Update dependency eslint to v7 (#420)
* Update dependency eslint to v7 * Switch to eslint-config-problems; format code Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Ryan Zimmerman <[email protected]>
1 parent 4344b33 commit fee216e

19 files changed

+45
-32
lines changed

index.js

+15-17
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@ const processContent = require("./lib/process-content")
1010
const parseStatements = require("./lib/parse-statements")
1111

1212
function AtImport(options) {
13-
options = Object.assign(
14-
{
15-
root: process.cwd(),
16-
path: [],
17-
skipDuplicates: true,
18-
resolve: resolveId,
19-
load: loadContent,
20-
plugins: [],
21-
addModulesDirectories: [],
22-
},
23-
options
24-
)
13+
options = {
14+
root: process.cwd(),
15+
path: [],
16+
skipDuplicates: true,
17+
resolve: resolveId,
18+
load: loadContent,
19+
plugins: [],
20+
addModulesDirectories: [],
21+
...options,
22+
}
2523

2624
options.root = path.resolve(options.root)
2725

@@ -59,7 +57,7 @@ function AtImport(options) {
5957
if (index === 0) return
6058

6159
if (stmt.parent) {
62-
const before = stmt.parent.node.raws.before
60+
const { before } = stmt.parent.node.raws
6361
if (stmt.type === "nodes") stmt.nodes[0].raws.before = before
6462
else stmt.node.raws.before = before
6563
} else if (stmt.type === "nodes") {
@@ -76,8 +74,8 @@ function AtImport(options) {
7674
} else if (stmt.type === "media")
7775
stmt.node.params = stmt.media.join(", ")
7876
else {
79-
const nodes = stmt.nodes
80-
const parent = nodes[0].parent
77+
const { nodes } = stmt
78+
const { parent } = nodes[0]
8179
const mediaNode = atRule({
8280
name: "media",
8381
params: stmt.media.join(", "),
@@ -203,7 +201,7 @@ function AtImport(options) {
203201
result.messages.push({
204202
type: "dependency",
205203
plugin: "postcss-import",
206-
file: file,
204+
file,
207205
parent: sourceFile,
208206
})
209207
})
@@ -224,7 +222,7 @@ function AtImport(options) {
224222

225223
function loadImportContent(result, stmt, filename, options, state) {
226224
const atRule = stmt.node
227-
const media = stmt.media
225+
const { media } = stmt
228226
if (options.skipDuplicates) {
229227
// skip files already imported at the same scope
230228
if (

lib/parse-statements.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const valueParser = require("postcss-value-parser")
55

66
// extended tooling
7-
const stringify = valueParser.stringify
7+
const { stringify } = valueParser
88

99
function split(params, start) {
1010
const list = []
@@ -35,7 +35,7 @@ module.exports = function (result, styles) {
3535
if (nodes.length) {
3636
statements.push({
3737
type: "nodes",
38-
nodes: nodes,
38+
nodes,
3939
media: [],
4040
})
4141
nodes = []
@@ -47,7 +47,7 @@ module.exports = function (result, styles) {
4747
if (nodes.length) {
4848
statements.push({
4949
type: "nodes",
50-
nodes: nodes,
50+
nodes,
5151
media: [],
5252
})
5353
}
@@ -76,7 +76,8 @@ function parseImport(result, atRule) {
7676
"@import must precede all other statements (besides @charset)",
7777
{ node: atRule }
7878
)
79-
} else prev = getPrev(prev)
79+
}
80+
prev = getPrev(prev)
8081
} while (prev)
8182
}
8283

lib/process-content.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const postcss = require("postcss")
1010
let sugarss
1111

1212
module.exports = function processContent(result, content, filename, options) {
13-
const plugins = options.plugins
13+
const { plugins } = options
1414
const ext = path.extname(filename)
1515

1616
const parserList = []
@@ -20,9 +20,7 @@ module.exports = function processContent(result, content, filename, options) {
2020
if (!sugarss) {
2121
try {
2222
sugarss = require("sugarss")
23-
} catch (e) {
24-
// Ignore
25-
}
23+
} catch {} // Ignore
2624
}
2725
if (sugarss) return runPostcss(content, filename, plugins, [sugarss])
2826
}

lib/resolve-id.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function (id, base, options) {
1717
const resolveOpts = {
1818
basedir: base,
1919
moduleDirectory: moduleDirectories.concat(options.addModulesDirectories),
20-
paths: paths,
20+
paths,
2121
extensions: [".css"],
2222
packageFilter: function processPackage(pkg) {
2323
if (pkg.style) pkg.main = pkg.style

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@
2727
},
2828
"devDependencies": {
2929
"ava": "^3.0.0",
30-
"eslint": "^5.0.0",
31-
"eslint-config-i-am-meticulous": "^11.0.0",
32-
"eslint-plugin-import": "^2.17.1",
30+
"eslint": "^7.0.0",
31+
"eslint-config-problems": "^5.0.0",
3332
"eslint-plugin-prettier": "^3.0.0",
3433
"postcss": "^8.0.0",
3534
"postcss-scss": "^3.0.0",
@@ -46,7 +45,10 @@
4645
"test": "ava"
4746
},
4847
"eslintConfig": {
49-
"extends": "eslint-config-i-am-meticulous",
48+
"extends": "eslint-config-problems",
49+
"env": {
50+
"node": true
51+
},
5052
"plugins": [
5153
"prettier"
5254
],

test/custom-load.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// external tooling
23
const test = require("ava")
34

test/custom-resolve.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// builtin tooling
23
const path = require("path")
34

test/custom-syntax-parser.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// external tooling
23
const test = require("ava")
34
const scss = require("postcss-scss")

test/filter.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// external tooling
23
const test = require("ava")
34

Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
"use strict"
12
module.exports = {}

test/helpers/check-fixture.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function read(name, ext) {
1515
}
1616

1717
module.exports = function (t, file, opts, postcssOpts, warnings) {
18-
opts = Object.assign({ path: "test/fixtures/imports" }, opts)
19-
postcssOpts = Object.assign({ from: undefined }, postcssOpts)
18+
opts = { path: "test/fixtures/imports", ...opts }
19+
postcssOpts = { from: undefined, ...postcssOpts }
2020
if (typeof file === "string") file = { name: file, ext: ".css" }
2121
const { name, ext } = file
2222

@@ -27,6 +27,7 @@ module.exports = function (t, file, opts, postcssOpts, warnings) {
2727
const expected = read(`${name}.expected`)
2828
// handy thing: checkout actual in the *.actual.css file
2929
fs.writeFile(`test/fixtures/${name}.actual.css`, actual, err => {
30+
// eslint-disable-next-line no-console
3031
if (err) console.warn(`Warning: ${err}; not fatal, continuing`)
3132
})
3233
t.is(actual, expected)

test/import-events.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// builtin tooling
23
const { readFileSync } = require("fs")
34
const { resolve } = require("path")

test/import.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// builtin tooling
23
const { readFileSync } = require("fs")
34
const path = require("path")

test/lint.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// external tooling
23
const test = require("ava")
34
const postcss = require("postcss")

test/media.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// external tooling
23
const test = require("ava")
34

test/order.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// external tooling
23
const test = require("ava")
34

test/plugins.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// external tooling
23
const test = require("ava")
34
const postcss = require("postcss")

test/resolve.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// external tooling
23
const test = require("ava")
34

test/syntax-error.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict"
12
// builtin tooling
23
const fs = require("fs")
34

0 commit comments

Comments
 (0)