Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 6686c77

Browse files
authored
Merge pull request #553 from AtomLinter/arcanemagus/fix-local-stylelint-config
Use local stylelint for config resolution if available
2 parents b598700 + 21c1d7f commit 6686c77

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/helpers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ export function refreshModulesPath(modulesDir) {
168168
}
169169

170170
function getProjectDir(filePath) {
171+
if (!filePath) {
172+
// No file (e.g. in the specs)
173+
return null;
174+
}
171175
const projectDir = atom.project.relativizePath(filePath)[0];
172176
return projectDir !== null ? projectDir : path.dirname(filePath);
173177
}

lib/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import hasValidScope from './validate';
77
// Dependencies
88
let helpers;
99
let dirname;
10-
let stylelint;
1110

1211
function loadDeps() {
1312
if (!helpers) {
@@ -16,9 +15,6 @@ function loadDeps() {
1615
if (!dirname) {
1716
({ dirname } = require('path'));
1817
}
19-
if (!stylelint) {
20-
stylelint = require('stylelint');
21-
}
2218
}
2319

2420
export default {
@@ -156,6 +152,8 @@ export default {
156152
}
157153

158154
helpers.startMeasure('linter-stylelint: Create Linter');
155+
// Use the project local stylelint to resolve the config if one exists
156+
const stylelint = await helpers.getStylelintInstance();
159157
const stylelintLinter = await stylelint.createLinter();
160158
helpers.endMeasure('linter-stylelint: Create Linter');
161159

0 commit comments

Comments
 (0)