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

Commit 21c1d7f

Browse files
committed
fix: use local stylelint for config resolution if available
Although the running of stylelint was changed to use the local project's instance if available in #381, the instance used to determine the configuration was unfortunately left as the bundled version. This made no difference then, and made no difference when the bundled version was still compatible with the local project one... but caused issues when there is a mismatch. This fixes it so we always use the stylelint instance local to the project if there is one available, falling back to the bundled one if one isn't available. Fixes #440.
1 parent b598700 commit 21c1d7f

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)