.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / tslint / lib / rules / classNameRule.js
1 "use strict";
2 /**
3  * @license
4  * Copyright 2013 Palantir Technologies, Inc.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 Object.defineProperty(exports, "__esModule", { value: true });
19 var tslib_1 = require("tslib");
20 var tsutils_1 = require("tsutils");
21 var ts = require("typescript");
22 var Lint = require("../index");
23 var utils_1 = require("../utils");
24 var className_examples_1 = require("./code-examples/className.examples");
25 var Rule = /** @class */ (function (_super) {
26     tslib_1.__extends(Rule, _super);
27     function Rule() {
28         return _super !== null && _super.apply(this, arguments) || this;
29     }
30     Rule.prototype.apply = function (sourceFile) {
31         return this.applyWithFunction(sourceFile, walk);
32     };
33     /* tslint:disable:object-literal-sort-keys */
34     Rule.metadata = {
35         ruleName: "class-name",
36         description: "Enforces PascalCased class and interface names.",
37         rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n            Makes it easy to differentiate classes from regular variables at a glance.\n\n            JavaScript and general programming convention is to refer to classes in PascalCase.\n            It's confusing to use camelCase or other conventions for class names.\n        "], ["\n            Makes it easy to differentiate classes from regular variables at a glance.\n\n            JavaScript and general programming convention is to refer to classes in PascalCase.\n            It's confusing to use camelCase or other conventions for class names.\n        "]))),
38         optionsDescription: "Not configurable.",
39         options: null,
40         optionExamples: [true],
41         type: "style",
42         typescriptOnly: false,
43         codeExamples: className_examples_1.codeExamples,
44     };
45     /* tslint:enable:object-literal-sort-keys */
46     Rule.FAILURE_STRING = "Class name must be in pascal case";
47     return Rule;
48 }(Lint.Rules.AbstractRule));
49 exports.Rule = Rule;
50 function walk(ctx) {
51     return ts.forEachChild(ctx.sourceFile, function cb(node) {
52         if ((tsutils_1.isClassLikeDeclaration(node) && node.name !== undefined) ||
53             tsutils_1.isInterfaceDeclaration(node)) {
54             if (!utils_1.isPascalCased(node.name.text)) {
55                 ctx.addFailureAtNode(node.name, Rule.FAILURE_STRING);
56             }
57         }
58         return ts.forEachChild(node, cb);
59     });
60 }
61 var templateObject_1;