2 * @fileoverview Provide the function that emits deprecation warnings.
3 * @author Toru Nagashima <http://github.com/mysticatea>
7 //------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------
11 const path = require("path");
12 const lodash = require("lodash");
14 //------------------------------------------------------------------------------
16 //------------------------------------------------------------------------------
18 // Definitions for deprecation warnings.
19 const deprecationWarningMessages = {
20 ESLINT_LEGACY_ECMAFEATURES:
21 "The 'ecmaFeatures' config file property is deprecated and has no effect.",
22 ESLINT_PERSONAL_CONFIG_LOAD:
23 "'~/.eslintrc.*' config files have been deprecated. " +
24 "Please use a config file per project or the '--config' option.",
25 ESLINT_PERSONAL_CONFIG_SUPPRESS:
26 "'~/.eslintrc.*' config files have been deprecated. " +
27 "Please remove it or add 'root:true' to the config files in your " +
28 "projects in order to avoid loading '~/.eslintrc.*' accidentally."
32 * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
33 * for each unique file path, but repeated invocations with the same file path have no effect.
34 * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
35 * @param {string} source The name of the configuration source to report the warning for.
36 * @param {string} errorCode The warning message to show.
39 const emitDeprecationWarning = lodash.memoize((source, errorCode) => {
40 const rel = path.relative(process.cwd(), source);
41 const message = deprecationWarningMessages[errorCode];
44 `${message} (found in "${rel}")`,
48 }, (...args) => JSON.stringify(args));
50 //------------------------------------------------------------------------------
52 //------------------------------------------------------------------------------
55 emitDeprecationWarning