Skip to content

Commit

Permalink
Update dependency eslint to v7 (#420)
Browse files Browse the repository at this point in the history
* Update dependency eslint to v7

* Switch to eslint-config-problems; format code

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Ryan Zimmerman <opensrc@ryanzim.com>
  • Loading branch information
3 people committed Oct 30, 2020
1 parent 4344b33 commit fee216e
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 32 deletions.
32 changes: 15 additions & 17 deletions index.js
Expand Up @@ -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)

Expand Down Expand Up @@ -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") {
Expand All @@ -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(", "),
Expand Down Expand Up @@ -203,7 +201,7 @@ function AtImport(options) {
result.messages.push({
type: "dependency",
plugin: "postcss-import",
file: file,
file,
parent: sourceFile,
})
})
Expand All @@ -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 (
Expand Down
9 changes: 5 additions & 4 deletions lib/parse-statements.js
Expand Up @@ -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 = []
Expand Down Expand Up @@ -35,7 +35,7 @@ module.exports = function (result, styles) {
if (nodes.length) {
statements.push({
type: "nodes",
nodes: nodes,
nodes,
media: [],
})
nodes = []
Expand All @@ -47,7 +47,7 @@ module.exports = function (result, styles) {
if (nodes.length) {
statements.push({
type: "nodes",
nodes: nodes,
nodes,
media: [],
})
}
Expand Down Expand Up @@ -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)
}

Expand Down
6 changes: 2 additions & 4 deletions lib/process-content.js
Expand Up @@ -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 = []
Expand All @@ -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])
}
Expand Down
2 changes: 1 addition & 1 deletion lib/resolve-id.js
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions package.json
Expand Up @@ -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",
Expand All @@ -46,7 +45,10 @@
"test": "ava"
},
"eslintConfig": {
"extends": "eslint-config-i-am-meticulous",
"extends": "eslint-config-problems",
"env": {
"node": true
},
"plugins": [
"prettier"
],
Expand Down
1 change: 1 addition & 0 deletions test/custom-load.js
@@ -1,3 +1,4 @@
"use strict"
// external tooling
const test = require("ava")

Expand Down
1 change: 1 addition & 0 deletions test/custom-resolve.js
@@ -1,3 +1,4 @@
"use strict"
// builtin tooling
const path = require("path")

Expand Down
1 change: 1 addition & 0 deletions test/custom-syntax-parser.js
@@ -1,3 +1,4 @@
"use strict"
// external tooling
const test = require("ava")
const scss = require("postcss-scss")
Expand Down
1 change: 1 addition & 0 deletions test/filter.js
@@ -1,3 +1,4 @@
"use strict"
// external tooling
const test = require("ava")

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/imports/modules/main-js/main.js
@@ -1 +1,2 @@
"use strict"
module.exports = {}
5 changes: 3 additions & 2 deletions test/helpers/check-fixture.js
Expand Up @@ -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

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/import-events.js
@@ -1,3 +1,4 @@
"use strict"
// builtin tooling
const { readFileSync } = require("fs")
const { resolve } = require("path")
Expand Down
1 change: 1 addition & 0 deletions test/import.js
@@ -1,3 +1,4 @@
"use strict"
// builtin tooling
const { readFileSync } = require("fs")
const path = require("path")
Expand Down
1 change: 1 addition & 0 deletions test/lint.js
@@ -1,3 +1,4 @@
"use strict"
// external tooling
const test = require("ava")
const postcss = require("postcss")
Expand Down
1 change: 1 addition & 0 deletions test/media.js
@@ -1,3 +1,4 @@
"use strict"
// external tooling
const test = require("ava")

Expand Down
1 change: 1 addition & 0 deletions test/order.js
@@ -1,3 +1,4 @@
"use strict"
// external tooling
const test = require("ava")

Expand Down
1 change: 1 addition & 0 deletions test/plugins.js
@@ -1,3 +1,4 @@
"use strict"
// external tooling
const test = require("ava")
const postcss = require("postcss")
Expand Down
1 change: 1 addition & 0 deletions test/resolve.js
@@ -1,3 +1,4 @@
"use strict"
// external tooling
const test = require("ava")

Expand Down
1 change: 1 addition & 0 deletions test/syntax-error.js
@@ -1,3 +1,4 @@
"use strict"
// builtin tooling
const fs = require("fs")

Expand Down

0 comments on commit fee216e

Please sign in to comment.