Skip to content

Commit

Permalink
Add setting to disable linter if project uses ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
chee authored and sonicdoe committed Aug 12, 2017
1 parent 94f9db8 commit 7444f86
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ module.exports = {
description: 'Only run if standard, semistandard or happiness present in package.json `devDependencies`',
default: false
},
checkForEslintConfig: {
type: 'boolean',
title: 'Disable if the project uses ESLint',
description: 'Do not run if the project has configured ESLint',
default: true
},
honorStyleSettings: {
type: 'boolean',
description: 'Honor code style settings on package.json',
Expand Down Expand Up @@ -98,7 +104,8 @@ module.exports = {

var style = selectStyle(filePath, {
style: opts.style || config.style,
checkStyleDevDependencies: config.checkStyleDevDependencies
checkStyleDevDependencies: config.checkStyleDevDependencies,
checkForEslintConfig: config.checkForEslintConfig
})

// Cache style settings and args of some file
Expand Down
6 changes: 6 additions & 0 deletions lib/utils/select-style.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var allowUnsafeNewFunction = require('loophole').allowUnsafeNewFunction
var pkgConfig = require('pkg-config')
var detectEslintConfig = require('detect-eslint-config')
var dirname = require('path').dirname
var styleSettings = require('./style-settings')

Expand Down Expand Up @@ -48,6 +49,11 @@ function getStyleThroughDevDeps (filePath, style) {
}

module.exports = function selectStyle (filePath, options) {
// Return early if the project uses ESLint
if (options.checkForEslintConfig && detectEslintConfig(filePath)) {
return noStyle()
}

// See if it should get style from the package.json
if (options.checkStyleDevDependencies) {
return getStyleThroughDevDeps(filePath, options.style)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"atom-package-deps": "^4.6.0",
"babel-eslint": "^7.1.0",
"detect-eslint-config": "^0.5.6",
"eslint-rule-documentation": "^1.0.9",
"esprima": "^3.1.1",
"happiness": "^10.0.2",
Expand Down

0 comments on commit 7444f86

Please sign in to comment.