Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
Fixed: support for eslint 1.x-rc (0.14.2)
Browse files Browse the repository at this point in the history
Close #54
Close #55
  • Loading branch information
MoOx committed Jul 18, 2015
1 parent 7a73a4c commit 6a3c1cb
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 55 deletions.
33 changes: 21 additions & 12 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
extends: eslint:recommended

ecmaFeatures:
modules: true

Expand All @@ -7,20 +9,27 @@ env:
browser: true
node: true

# 0: off, 1: warning, 2: error
rules:
# semicolons are useless
semi: [2, "never"]

indent: [2, 2] # 2 spaces indentation
max-len: [2, 80, 4]
quotes: [2, "double"]
semi: [2, "never"]
no-multiple-empty-lines: [2, {"max": 1}]

# 2 spaces indentation
indent: [2, 2]

# trailing coma are cool for diff
comma-dangle: [2, "always"]

# enforce comma at eol (never before)
brace-style: [2, "stroustrup"]
comma-dangle: [2, "always-multiline"]
comma-style: [2, "last"]
computed-property-spacing: [2, "never"]
dot-location: [2, "property"]

one-var: [2, "never"]
no-bitwise: [2]

valid-jsdoc: 2
object-curly-spacing: [2, "never"]
array-bracket-spacing: [2, "never"]
space-unary-ops: [2, {"words": true, "nonwords": false}]
space-after-keywords: [2, "always"]
space-before-blocks: [2, "always"]
space-before-function-paren: [2, "never"]
space-in-parens: [2, "never"]
spaced-comment: [2, "always"]
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.14.2 - 2015-07-18

- Fixed: support for eslint 1.x-rc

# 0.14.1 - 2015-06-15

- Fixed: support for eslint 0.24.x
Expand Down
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ function lint(input, config, webpack, callback) {
if (res.warningCount && config.quiet) {
res.warningCount = 0
res.results[0].warningCount = 0
res.results[0].messages = res.results[0].messages.filter(function(message) {
return message.severity !== 1
})
res.results[0].messages = res.results[0].messages
.filter(function(message) {
return message.severity !== 1
})
}

if (res.errorCount || res.warningCount) {
Expand Down Expand Up @@ -73,7 +74,11 @@ function lint(input, config, webpack, callback) {
}
}
else {
throw new Error("Your module system doesn't support emitWarning. Update available? \n" + messages)
throw new Error(
"Your module system doesn't support emitWarning. " +
"Update available? \n" +
messages
)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-loader",
"version": "0.14.1",
"version": "0.14.2",
"description": "eslint loader (for webpack)",
"keywords": [
"lint",
Expand All @@ -25,14 +25,14 @@
"index.js"
],
"peerDependencies": {
"eslint": "0.21 - 0.24"
"eslint": "0.21 - 0.24 || ~1.0.0-rc-0"
},
"dependencies": {
"loader-utils": "^0.2.7",
"object-assign": "^2.0.0"
"object-assign": "^3.0.0"
},
"devDependencies": {
"eslint": "^0.24.0",
"eslint": "^1.0.0-rc-1",
"eslint-friendly-formatter": "^1.0.3",
"tape": "^4.0.0",
"webpack": "^1.8.4"
Expand Down
9 changes: 7 additions & 2 deletions test/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ test("eslint-loader can return error if file is bad", function(t) {
}
),
function(err, stats) {
if (err) {throw err}
if (err) {
throw err
}

// console.log(stats.compilation.errors)
t.ok(stats.hasErrors(), "a file that contains eslint errors should return error")
t.ok(
stats.hasErrors(),
"a file that contains eslint errors should return error"
)
t.end()
})
})
4 changes: 3 additions & 1 deletion test/eslintignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ test("eslint-loader ignores files present in .eslintignore", function(t) {
}
),
function(err, stats) {
if (err) {throw err}
if (err) {
throw err
}

// console.log(stats.compilation.warnings)
t.notOk(stats.hasWarnings(), "an ignored doesn't give a warning")
Expand Down
13 changes: 10 additions & 3 deletions test/force-emit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ test("eslint-loader can force to emit error", function(t) {
}
),
function(err, stats) {
if (err) {throw err}
if (err) {
throw err
}

// console.log(stats.compilation.errors)
t.ok(stats.hasErrors(), "a file should return error if asked")
// console.log(stats.compilation.warnings)
t.notOk(stats.hasWarnings(), "a file should return no warning if error asked")
t.notOk(
stats.hasWarnings(),
"a file should return no warning if error asked"
)
t.end()
})
})
Expand All @@ -35,7 +40,9 @@ test("eslint-loader can force to emit warning", function(t) {
}
),
function(err, stats) {
if (err) {throw err}
if (err) {
throw err
}

// console.log(stats.compilation.warnings)
t.ok(stats.hasWarnings(), "a file should return warning if asked")
Expand Down
28 changes: 23 additions & 5 deletions test/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var webpack = require("webpack")
var assign = require("object-assign")
var conf = require("./utils/conf")

/* eslint-disable no-console */
test("eslint-loader can use eslint formatter", function(t) {
webpack(assign({},
conf,
Expand All @@ -11,10 +12,17 @@ test("eslint-loader can use eslint formatter", function(t) {
}
),
function(err, stats) {
if (err) {throw err}
if (err) {
throw err
}

console.log("### Here is a example of the default formatter")
console.log("# " + stats.compilation.errors[0].message.split("\n").join("\n# "))
console.log(
"# " +
stats.compilation.errors[0].message
.split("\n")
.join("\n# ")
)
t.ok(stats.compilation.errors[0].message, "webpack have some output")
t.end()
})
Expand All @@ -31,11 +39,21 @@ test("eslint-loader can use custom formatter", function(t) {
}
),
function(err, stats) {
if (err) {throw err}
if (err) {
throw err
}

console.log("### Here is a example of another formatter")
console.log("# " + stats.compilation.errors[0].message.split("\n").join("\n# "))
t.ok(stats.compilation.errors[0].message, "webpack have some output with custom formatters")
console.log(
"# " +
stats.compilation.errors[0].message
.split("\n")
.join("\n# ")
)
t.ok(
stats.compilation.errors[0].message,
"webpack have some output with custom formatters"
)
t.end()
})
})
4 changes: 3 additions & 1 deletion test/ok.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ test("eslint-loader don't throw error if file is ok", function(t) {
}
),
function(err, stats) {
if (err) {throw err}
if (err) {
throw err
}

// console.log(stats.compilation.errors)
t.notOk(stats.hasErrors(), "a good file doesn't give any error")
Expand Down
4 changes: 3 additions & 1 deletion test/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ test("eslint-loader supports query strings parameters", function(t) {
}
),
function(err, stats) {
if (err) {throw err}
if (err) {
throw err
}

// console.log(stats.compilation.errors)
t.notOk(stats.hasErrors(), "a good file doesn't give any error")
Expand Down
51 changes: 32 additions & 19 deletions test/quiet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,36 @@ var webpack = require("webpack")
var assign = require("object-assign")
var conf = require("./utils/conf")

test("eslint-loader only returns errors and not warnings if quiet is set", function(t) {
webpack(assign({},
conf,
{
entry: "./test/fixtures/warn.js",
eslint: assign({}, conf.eslint, {
quiet: true,
}),
}
),
function(err, stats) {
if (err) {throw err}
test(
"eslint-loader only returns errors and not warnings if quiet is set",
function(t) {
webpack(assign({},
conf,
{
entry: "./test/fixtures/warn.js",
eslint: assign({}, conf.eslint, {
quiet: true,
}),
}
),
function(err, stats) {
if (err) {
throw err
}

// console.log(stats.compilation.warnings)
t.notOk(stats.hasWarnings(), "a file that contains eslint warning should return nothing if quiet option is true")
// console.log(stats.compilation.errors)
t.notOk(stats.hasErrors(), "a file that contains eslint warning should return no error if it contains only warning in quiet mode")
t.end()
})
})
// console.log(stats.compilation.warnings)
t.notOk(
stats.hasWarnings(),
"a file that contains eslint warning should return nothing if quiet " +
"option is true"
)
// console.log(stats.compilation.errors)
t.notOk(
stats.hasErrors(),
"a file that contains eslint warning should return no error if it " +
"contains only warning in quiet mode"
)
t.end()
})
}
)
14 changes: 11 additions & 3 deletions test/warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@ test("eslint-loader can return warning", function(t) {
}
),
function(err, stats) {
if (err) {throw err}
if (err) {
throw err
}

// console.log(stats.compilation.warnings)
t.ok(stats.hasWarnings(), "a file that contains eslint warning should return warning")
t.ok(
stats.hasWarnings(),
"a file that contains eslint warning should return warning"
)

// console.log(stats.compilation.errors)
t.notOk(stats.hasErrors(), "a bad file should return no error if it contains only warning by default")
t.notOk(
stats.hasErrors(),
"a bad file should return no error if it contains only warning by default"
)
t.end()
})
})

0 comments on commit 6a3c1cb

Please sign in to comment.