-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking: runtime-deprecation on '~/.eslintrc' (refs eslint/rfcs#32) (#…
…12678) Co-Authored-By: Kai Cataldo <[email protected]>
- Loading branch information
1 parent
2c28fbb
commit 1118fce
Showing
7 changed files
with
483 additions
and
36 deletions.
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
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,56 @@ | ||
/** | ||
* @fileoverview Provide the function that emits deprecation warnings. | ||
* @author Toru Nagashima <http://github.com/mysticatea> | ||
*/ | ||
"use strict"; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
|
||
const path = require("path"); | ||
const lodash = require("lodash"); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Private | ||
//------------------------------------------------------------------------------ | ||
|
||
// Defitions for deprecation warnings. | ||
const deprecationWarningMessages = { | ||
ESLINT_LEGACY_ECMAFEATURES: | ||
"The 'ecmaFeatures' config file property is deprecated and has no effect.", | ||
ESLINT_PERSONAL_CONFIG_LOAD: | ||
"'~/.eslintrc.*' config files have been deprecated. " | ||
"Please use a config file per project or the '--config' option.", | ||
ESLINT_PERSONAL_CONFIG_SUPPRESS: | ||
"'~/.eslintrc.*' config files have been deprecated. " | ||
"Please remove it or add 'root:true' to the config files in your " | ||
"projects in order to avoid loading '~/.eslintrc.*' accidentally." | ||
}; | ||
|
||
/** | ||
* Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted | ||
* for each unique file path, but repeated invocations with the same file path have no effect. | ||
* No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active. | ||
* @param {string} source The name of the configuration source to report the warning for. | ||
* @param {string} errorCode The warning message to show. | ||
* @returns {void} | ||
*/ | ||
const emitDeprecationWarning = lodash.memoize((source, errorCode) => { | ||
const rel = path.relative(process.cwd(), source); | ||
const message = deprecationWarningMessages[errorCode]; | ||
|
||
process.emitWarning( | ||
`${message} (found in "${rel}")`, | ||
"DeprecationWarning", | ||
errorCode | ||
); | ||
}, (...args) => JSON.stringify(args)); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Public Interface | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = { | ||
emitDeprecationWarning | ||
}; |
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
Oops, something went wrong.