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

Commit

Permalink
Do not attempt to fix on save when disabled
Browse files Browse the repository at this point in the history
If `disableWhenNoEslintConfig` is disabling linting, we should also
not be trying to perform an autofix.
  • Loading branch information
IanVS committed Jan 5, 2017
1 parent 913d0e1 commit 668496c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
'use strict';
'use babel';

// eslint-disable-next-line import/no-extraneous-dependencies, import/extensions
var _path = require('path');

var _path2 = _interopRequireDefault(_path);

var _atom = require('atom');

var _helpers = require('./helpers');

var _workerHelpers = require('./worker-helpers');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
// eslint-disable-next-line import/no-extraneous-dependencies, import/extensions


// Configuration
const scopes = [];
Expand Down Expand Up @@ -46,6 +54,11 @@ module.exports = {
const filePath = editor.getPath();
const projectPath = atom.project.relativizePath(filePath)[0];

// Do not try to fix if linting should be disabled
const fileDir = _path2.default.dirname(filePath);
const configPath = (0, _workerHelpers.getConfigPath)(fileDir);
if (configPath === null && atom.config.get('linter-eslint.disableWhenNoEslintConfig')) return;

this.worker.request('job', {
type: 'fix',
config: atom.config.get('linter-eslint'),
Expand Down
7 changes: 7 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
'use babel'

import Path from 'path'
// eslint-disable-next-line import/no-extraneous-dependencies, import/extensions
import { CompositeDisposable, } from 'atom'

import {
spawnWorker, showError, idsToIgnoredRules, processESLintMessages,
generateDebugString
} from './helpers'
import { getConfigPath } from './worker-helpers'

// Configuration
const scopes = []
Expand Down Expand Up @@ -48,6 +50,11 @@ module.exports = {
const filePath = editor.getPath()
const projectPath = atom.project.relativizePath(filePath)[0]

// Do not try to fix if linting should be disabled
const fileDir = Path.dirname(filePath)
const configPath = getConfigPath(fileDir)
if (configPath === null && atom.config.get('linter-eslint.disableWhenNoEslintConfig')) return

this.worker.request('job', {
type: 'fix',
config: atom.config.get('linter-eslint'),
Expand Down

0 comments on commit 668496c

Please sign in to comment.