1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = warnRemovedSettings;
|
7 |
|
8 | var _WarnSettings = _interopRequireDefault(require("./WarnSettings"));
|
9 |
|
10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11 |
|
12 | const warnSettings = (0, _WarnSettings.default)();
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | const has = (obj, property) => {
|
30 | return Object.prototype.hasOwnProperty.call(obj, property);
|
31 | };
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | const getMovedSettings = ruleName => {
|
40 | switch (ruleName) {
|
41 | case 'require-jsdoc':
|
42 | return ['exemptEmptyFunctions'];
|
43 |
|
44 | case 'require-returns':
|
45 | return ['forceRequireReturn'];
|
46 |
|
47 | case 'valid-types':
|
48 | return ['allowEmptyNamepaths', 'checkSeesForNamepaths'];
|
49 |
|
50 | case 'require-example':
|
51 | return ['avoidExampleOnConstructors'];
|
52 |
|
53 | case 'check-examples':
|
54 | return ['captionRequired', 'exampleCodeRegex', 'rejectExampleCodeRegex', 'allowInlineConfig', 'noDefaultExampleRules', 'matchingFileName', 'configFile', 'eslintrcForExamples', 'baseConfig', 'reportUnusedDisableDirectives'];
|
55 | }
|
56 |
|
57 |
|
58 |
|
59 | return [];
|
60 | };
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | function warnRemovedSettings(context, ruleName) {
|
68 | const movedSettings = getMovedSettings(ruleName);
|
69 |
|
70 | if (!context.settings || !context.settings.jsdoc) {
|
71 | return;
|
72 | }
|
73 |
|
74 | var _iteratorNormalCompletion = true;
|
75 | var _didIteratorError = false;
|
76 | var _iteratorError = undefined;
|
77 |
|
78 | try {
|
79 | for (var _iterator = movedSettings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
80 | const setting = _step.value;
|
81 |
|
82 | if (has(context.settings.jsdoc, setting) && !warnSettings.hasBeenWarned(context, setting)) {
|
83 | context.report({
|
84 | loc: {
|
85 | start: {
|
86 | column: 1,
|
87 | line: 1
|
88 | }
|
89 | },
|
90 | message: `\`settings.jsdoc.${setting}\` has been removed, ` + `use options in the rule \`${ruleName}\` instead.`
|
91 | });
|
92 | warnSettings.markSettingAsWarned(context, setting);
|
93 | }
|
94 | }
|
95 | } catch (err) {
|
96 | _didIteratorError = true;
|
97 | _iteratorError = err;
|
98 | } finally {
|
99 | try {
|
100 | if (!_iteratorNormalCompletion && _iterator.return != null) {
|
101 | _iterator.return();
|
102 | }
|
103 | } finally {
|
104 | if (_didIteratorError) {
|
105 | throw _iteratorError;
|
106 | }
|
107 | }
|
108 | }
|
109 | }
|
110 |
|
111 | module.exports = exports.default;
|
112 |
|
\ | No newline at end of file |