2 * @fileoverview Provide the function that emits deprecation warnings.
3 * @author Toru Nagashima <http://github.com/mysticatea>
7 //------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------
11 const path
= require("path");
13 //------------------------------------------------------------------------------
15 //------------------------------------------------------------------------------
17 // Definitions for deprecation warnings.
18 const deprecationWarningMessages
= {
19 ESLINT_LEGACY_ECMAFEATURES
:
20 "The 'ecmaFeatures' config file property is deprecated and has no effect."
23 const sourceFileErrorCache
= new Set();
26 * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
27 * for each unique file path, but repeated invocations with the same file path have no effect.
28 * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
29 * @param {string} source The name of the configuration source to report the warning for.
30 * @param {string} errorCode The warning message to show.
33 function emitDeprecationWarning(source
, errorCode
) {
34 const cacheKey
= JSON
.stringify({ source
, errorCode
});
36 if (sourceFileErrorCache
.has(cacheKey
)) {
40 sourceFileErrorCache
.add(cacheKey
);
42 const rel
= path
.relative(process
.cwd(), source
);
43 const message
= deprecationWarningMessages
[errorCode
];
46 `${message} (found in "${rel}")`,
52 //------------------------------------------------------------------------------
54 //------------------------------------------------------------------------------
57 emitDeprecationWarning