From 5c1917dc00e8f2578cbcd956b68ab27798149d9b Mon Sep 17 00:00:00 2001 From: Christopher Lamey Date: Wed, 10 Feb 2016 13:21:07 -0700 Subject: [PATCH 1/4] Exec csslint from project root to pick up project .csslintrc --- lib/main.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.coffee b/lib/main.coffee index 4c5f58e..84316c8 100644 --- a/lib/main.coffee +++ b/lib/main.coffee @@ -18,8 +18,8 @@ module.exports = text = textEditor.getText() parameters = ['--format=json', '-'] exec = path.join(__dirname, '..', 'node_modules', 'atomlinter-csslint', 'cli.js') - cwd = path.dirname(textEditor.getPath()) - helpers.execNode(exec, parameters, {stdin: text, cwd: cwd}).then (output) -> + paths = atom.project.relativizePath(filePath) + helpers.execNode(exec, parameters, {stdin: text, cwd: paths.projectPath}).then (output) -> lintResult = JSON.parse(output) toReturn = [] if lintResult.messages.length < 1 From f9bc62015f8282d71c9969142209edc65c0df089 Mon Sep 17 00:00:00 2001 From: Christopher Lamey Date: Wed, 10 Feb 2016 14:48:29 -0700 Subject: [PATCH 2/4] Handle cwd for non-project files --- lib/main.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/main.coffee b/lib/main.coffee index 84316c8..ad4b3d1 100644 --- a/lib/main.coffee +++ b/lib/main.coffee @@ -19,7 +19,10 @@ module.exports = parameters = ['--format=json', '-'] exec = path.join(__dirname, '..', 'node_modules', 'atomlinter-csslint', 'cli.js') paths = atom.project.relativizePath(filePath) - helpers.execNode(exec, parameters, {stdin: text, cwd: paths.projectPath}).then (output) -> + cwd = paths.projectPath + if (!cwd) + cwd = path.dirname(textEditor.getPath()) + helpers.execNode(exec, parameters, {stdin: text, cwd: cwd}).then (output) -> lintResult = JSON.parse(output) toReturn = [] if lintResult.messages.length < 1 From acb32455159372cad64b1ffa60b2d6af92a0a942 Mon Sep 17 00:00:00 2001 From: Christopher Lamey Date: Wed, 10 Feb 2016 15:22:55 -0700 Subject: [PATCH 3/4] Use project negation convention --- lib/main.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.coffee b/lib/main.coffee index ad4b3d1..09661d2 100644 --- a/lib/main.coffee +++ b/lib/main.coffee @@ -20,7 +20,7 @@ module.exports = exec = path.join(__dirname, '..', 'node_modules', 'atomlinter-csslint', 'cli.js') paths = atom.project.relativizePath(filePath) cwd = paths.projectPath - if (!cwd) + if not (cwd) cwd = path.dirname(textEditor.getPath()) helpers.execNode(exec, parameters, {stdin: text, cwd: cwd}).then (output) -> lintResult = JSON.parse(output) From f49822ca899236822aa04b462248b3fd6ac5312a Mon Sep 17 00:00:00 2001 From: Christopher Lamey Date: Wed, 10 Feb 2016 16:02:02 -0700 Subject: [PATCH 4/4] 2 space indent! --- lib/main.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.coffee b/lib/main.coffee index 09661d2..ff44d1f 100644 --- a/lib/main.coffee +++ b/lib/main.coffee @@ -21,7 +21,7 @@ module.exports = paths = atom.project.relativizePath(filePath) cwd = paths.projectPath if not (cwd) - cwd = path.dirname(textEditor.getPath()) + cwd = path.dirname(textEditor.getPath()) helpers.execNode(exec, parameters, {stdin: text, cwd: cwd}).then (output) -> lintResult = JSON.parse(output) toReturn = []