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

support eslint@4.x #178

Merged
merged 4 commits into from Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .eslintrc
@@ -1,8 +1,8 @@
---
extends: eslint:recommended

ecmaFeatures:
modules: true
parserOptions:
ecmaFeatures:
modules: true

env:
es6: true
Expand All @@ -11,7 +11,7 @@ env:

rules:
indent: [2, 2] # 2 spaces indentation
max-len: [2, 80, 4]
max-len: [2, 120, 4]
quotes: [2, "double"]
semi: [2, "never"]
no-multiple-empty-lines: [2, {"max": 1}]
Expand Down
10 changes: 5 additions & 5 deletions index.js
Expand Up @@ -88,11 +88,11 @@ function printLinterOutput(res, config, webpack) {
reportOutput = messages
}
var filePath = loaderUtils.interpolateName(webpack,
config.outputReport.filePath, {
content: res.results.map(function(r) {
return r.source
}).join("\n"),
}
config.outputReport.filePath, {
content: res.results.map(function(r) {
return r.source
}).join("\n"),
}
)
webpack.emitFile(filePath, reportOutput)
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -16,7 +16,7 @@
"index.js"
],
"peerDependencies": {
"eslint": ">=1.6.0 <4.0.0"
"eslint": ">=1.6.0 <5.0.0"
},
"dependencies": {
"find-cache-dir": "^0.1.1",
Expand All @@ -28,7 +28,7 @@
},
"devDependencies": {
"ava": "^0.17.0",
"eslint": "^3.0.0",
"eslint": "^4.0.0",
"eslint-friendly-formatter": "^2.0.4",
"npmpub": "^3.0.1",
"webpack": "^2.2.0"
Expand Down
52 changes: 26 additions & 26 deletions test/autofix.js
Expand Up @@ -12,33 +12,33 @@ test.before(function() {
})

test.cb("loader doesn't throw error if file ok after auto-fixing",
function(t) {
t.plan(2)
webpack(conf(
{
entry: "./test/fixtures/fixable-clone.js",
module: {
loaders: [
{
test: /\.js$/,
loader: "./index?fix=true",
exclude: /node_modules/,
},
],
},
}
),
function(err, stats) {
if (err) {
throw err
}
// console.log(stats.compilation.errors)
t.false(stats.hasErrors(), "a good file doesn't give any error")
// console.log(stats.compilation.warnings)
t.false(stats.hasWarnings(), "a good file doesn't give any warning")
t.end()
function(t) {
t.plan(2)
webpack(conf(
{
entry: "./test/fixtures/fixable-clone.js",
module: {
loaders: [
{
test: /\.js$/,
loader: "./index?fix=true",
exclude: /node_modules/,
},
],
},
}
),
function(err, stats) {
if (err) {
throw err
}
// console.log(stats.compilation.errors)
t.false(stats.hasErrors(), "a good file doesn't give any error")
// console.log(stats.compilation.warnings)
t.false(stats.hasWarnings(), "a good file doesn't give any warning")
t.end()
})
})
})

// remove the clone
test.after.always(function() {
Expand Down
154 changes: 77 additions & 77 deletions test/cache.js
Expand Up @@ -79,106 +79,106 @@ test.cb("should output files to cache directory", (t) => {
})

test.cb.serial("should output json.gz files to standard cache dir by default",
(t) => {
var config = assign({}, globalConfig, {
output: {
path: t.context.directory,
},
module: {
loaders: [
{
test: /\.jsx?/,
loader: eslintLoader,
exclude: /node_modules/,
query: {
cache: true,
(t) => {
var config = assign({}, globalConfig, {
output: {
path: t.context.directory,
},
module: {
loaders: [
{
test: /\.jsx?/,
loader: eslintLoader,
exclude: /node_modules/,
query: {
cache: true,
},
},
},
],
},
})
],
},
})

webpack(config, (err) => {
t.is(err, null)
webpack(config, (err) => {
t.is(err, null)

fs.readdir(defaultCacheDir, (err, files) => {
fs.readdir(defaultCacheDir, (err, files) => {
// console.log("CACHE SETTING:", t.context.cache)
files = files.filter((file) => /\b[0-9a-f]{5,40}\.json\.gz\b/.test(file))
t.is(err, null)
t.true(files.length > 0)
t.end()
files = files.filter((file) => /\b[0-9a-f]{5,40}\.json\.gz\b/.test(file))
t.is(err, null)
t.true(files.length > 0)
t.end()
})
})
})
})

test.cb.serial(
"should output files to standard cache dir if set to true in query",
(t) => {
var config = assign({}, globalConfig, {
output: {
path: t.context.directory,
},
module: {
loaders: [
{
test: /\.jsx?/,
loader: `${eslintLoader}?cache=true`,
exclude: /node_modules/,
},
],
},
})
"should output files to standard cache dir if set to true in query",
(t) => {
var config = assign({}, globalConfig, {
output: {
path: t.context.directory,
},
module: {
loaders: [
{
test: /\.jsx?/,
loader: `${eslintLoader}?cache=true`,
exclude: /node_modules/,
},
],
},
})

webpack(config, (err) => {
t.is(err, null)
webpack(config, (err) => {
t.is(err, null)

fs.readdir(defaultCacheDir, (err, files) => {
fs.readdir(defaultCacheDir, (err, files) => {
// console.log("CACHE SETTING:", t.context.cache)
files = files.filter((file) => /\b[0-9a-f]{5,40}\.json\.gz\b/.test(file))
files = files.filter((file) => /\b[0-9a-f]{5,40}\.json\.gz\b/.test(file))

t.is(err, null)
t.true(files.length > 0)
t.end()
t.is(err, null)
t.true(files.length > 0)
t.end()
})
})
})
})

test.cb.serial("should read from cache directory if cached file exists",
(t) => {
var config = assign({}, globalConfig, {
output: {
path: t.context.directory,
},
module: {
loaders: [
{
test: /\.jsx?/,
loader: eslintLoader,
exclude: /node_modules/,
query: {
cache: t.context.cache,
(t) => {
var config = assign({}, globalConfig, {
output: {
path: t.context.directory,
},
module: {
loaders: [
{
test: /\.jsx?/,
loader: eslintLoader,
exclude: /node_modules/,
query: {
cache: t.context.cache,
},
},
},
],
},
})

// @TODO Find a way to know if the file as correctly read without relying on
// Istanbul for coverage.
webpack(config, (err) => {
t.is(err, null)
],
},
})

// @TODO Find a way to know if the file as correctly read without relying on
// Istanbul for coverage.
webpack(config, (err) => {
t.is(err, null)
fs.readdir(t.context.cache, (err, files) => {

webpack(config, (err) => {
t.is(err, null)
t.true(files.length > 0)
t.end()
fs.readdir(t.context.cache, (err, files) => {
t.is(err, null)
t.true(files.length > 0)
t.end()
})
})
})
})

})
})

test.cb.serial("should have one file per module", (t) => {
var config = assign({}, globalConfig, {
Expand Down Expand Up @@ -283,5 +283,5 @@ function createTestDirectory(baseDirectory, testTitle, cb) {
}

function escapeDirectory(directory) {
return directory.replace(/[\/?<>\\:*|"\s]/g, "_")
return directory.replace(/[/?<>\\:*|"\s]/g, "_")
}