This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 141
Ignore home config from disableWhenNoEslintConfig #778
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.isConfigAtHomeRoot = isConfigAtHomeRoot; | ||
|
||
var _userHome = require('user-home'); | ||
|
||
var _userHome2 = _interopRequireDefault(_userHome); | ||
|
||
var _path = require('path'); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
/** | ||
* Check if a config is directly inside a user's home directory. | ||
* Such config files are used by ESLint as a fallback, only for situations | ||
* when there is no other config file between a file being linted and root. | ||
* | ||
* @param {string} configPath - The path of the config file being checked | ||
* @return {Boolean} True if the file is directly in the current user's home | ||
*/ | ||
/* eslint-disable import/prefer-default-export */ | ||
|
||
function isConfigAtHomeRoot(configPath) { | ||
return (0, _path.dirname)(configPath) === _userHome2.default; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* eslint no-undef: error */ | ||
|
||
foo = 42; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
|
||
import userHome from 'user-home' | ||
import { dirname } from 'path' | ||
|
||
/** | ||
* Check if a config is directly inside a user's home directory. | ||
* Such config files are used by ESLint as a fallback, only for situations | ||
* when there is no other config file between a file being linted and root. | ||
* | ||
* @param {string} configPath - The path of the config file being checked | ||
* @return {Boolean} True if the file is directly in the current user's home | ||
*/ | ||
export function isConfigAtHomeRoot(configPath) { | ||
return (dirname(configPath) === userHome) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,10 @@ import { CompositeDisposable, } from 'atom' | |
|
||
import { | ||
spawnWorker, showError, idsToIgnoredRules, processESLintMessages, | ||
generateDebugString | ||
generateDebugString, | ||
} from './helpers' | ||
import { getConfigPath } from './worker-helpers' | ||
import { isConfigAtHomeRoot } from './is-config-at-home-root' | ||
|
||
// Configuration | ||
const scopes = [] | ||
|
@@ -54,7 +55,8 @@ module.exports = { | |
// Do not try to fix if linting should be disabled | ||
const fileDir = Path.dirname(filePath) | ||
const configPath = getConfigPath(fileDir) | ||
if (configPath === null && disableWhenNoEslintConfig) return | ||
const noProjectConfig = (configPath === null || isConfigAtHomeRoot(configPath)) | ||
if (noProjectConfig && disableWhenNoEslintConfig) return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm personally not a fan of one line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's how it was before, so I'm just going to leave it for now. :) |
||
|
||
this.worker.request('job', { | ||
type: 'fix', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is the exact same in both test cases, you could move it into
copyFileToTempDir
, if you want to leave it as a parameter though you might as well just call the functioncopyFileToDir
😛.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I passed it in so that I could rimraf it after the test. Guess I could indeed rename it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Arcanemagus I ended up moving it to the function after all. Seemed … cleaner, I guess.