Skip to content

Commit f06ffe7

Browse files
committed
Code tidying
1 parent 7494447 commit f06ffe7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use babel';
22

3-
import path from 'path';
43
import configLoader from 'lesshint/lib/config-loader';
4+
import { findCachedAsync, rangeFromLineNumber } from 'atom-linter';
5+
import Lesshint from 'lesshint';
6+
import path from 'path';
57
import os from 'os';
68

79
export default class LinterLesshint {
@@ -40,22 +42,19 @@ export default class LinterLesshint {
4042
}
4143

4244
static provideLinter () {
43-
const Lesshint = require('lesshint');
44-
const Helpers = require('atom-linter');
45-
4645
return {
4746
name: 'lesshint',
4847
grammarScopes: ['source.css.less'],
4948
scope: 'file',
5049
lintOnFly: true,
5150
lint: async (editor) => {
5251
const lesshint = new Lesshint();
53-
const text = editor.getText();
5452
const filePath = editor.getPath();
55-
let configFile = await Helpers.findCachedAsync(path.dirname(filePath), '.lesshintrc');
53+
54+
let configFile = await findCachedAsync(path.dirname(filePath), '.lesshintrc');
5655

5756
if (!configFile && this.globalConfig) {
58-
configFile = await Helpers.findCachedAsync(this.globalConfigDir, '.lesshintrc');
57+
configFile = await findCachedAsync(this.globalConfigDir, '.lesshintrc');
5958
}
6059

6160
if (!configFile && this.onlyWithRc) {
@@ -79,6 +78,8 @@ export default class LinterLesshint {
7978
let errors = [];
8079

8180
try {
81+
const text = editor.getText();
82+
8283
errors = lesshint.checkString(text, filePath);
8384
} catch (e) {
8485
atom.notifications.addError("lesshint couldn't check this file.", {
@@ -90,7 +91,7 @@ export default class LinterLesshint {
9091
return errors.map(({ linter, message, line, column, severity }) => {
9192
line = line || editor.getLineCount();
9293

93-
const range = Helpers.rangeFromLineNumber(editor, line - 1, column - 1);
94+
const range = rangeFromLineNumber(editor, line - 1, column - 1);
9495

9596
const type = severity;
9697
const html = `<span class='badge badge-flexible'>${linter}</span> ${message}`;

0 commit comments

Comments
 (0)