aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint/lib/rules/completed-docs
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tslint/lib/rules/completed-docs')
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts26
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/blockExclusion.js42
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts30
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/classExclusion.js59
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts25
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusion.js33
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts28
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js18
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts8
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js60
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts34
-rw-r--r--node_modules/tslint/lib/rules/completed-docs/tagExclusion.js82
12 files changed, 445 insertions, 0 deletions
diff --git a/node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts
new file mode 100644
index 000000000..57eea1745
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.d.ts
@@ -0,0 +1,26 @@
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import { Visibility } from "../completedDocsRule";
+import { Exclusion } from "./exclusion";
+export interface IBlockExclusionDescriptor {
+ visibilities?: Visibility[];
+}
+export declare class BlockExclusion extends Exclusion<IBlockExclusionDescriptor> {
+ readonly visibilities: Set<Visibility>;
+ excludes(node: ts.Node): boolean;
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/blockExclusion.js b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.js
new file mode 100644
index 000000000..fdc7dabd0
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/blockExclusion.js
@@ -0,0 +1,42 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2017 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var ts = require("typescript");
+var Lint = require("../../index");
+var completedDocsRule_1 = require("../completedDocsRule");
+var exclusion_1 = require("./exclusion");
+var BlockExclusion = /** @class */ (function (_super) {
+ tslib_1.__extends(BlockExclusion, _super);
+ function BlockExclusion() {
+ var _this = _super !== null && _super.apply(this, arguments) || this;
+ _this.visibilities = _this.createSet(_this.descriptor.visibilities);
+ return _this;
+ }
+ BlockExclusion.prototype.excludes = function (node) {
+ if (this.visibilities.has(completedDocsRule_1.ALL)) {
+ return false;
+ }
+ if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
+ return !this.visibilities.has(completedDocsRule_1.VISIBILITY_EXPORTED);
+ }
+ return !this.visibilities.has(completedDocsRule_1.VISIBILITY_INTERNAL);
+ };
+ return BlockExclusion;
+}(exclusion_1.Exclusion));
+exports.BlockExclusion = BlockExclusion;
diff --git a/node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts
new file mode 100644
index 000000000..a6f24bbe7
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/classExclusion.d.ts
@@ -0,0 +1,30 @@
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import { Location, Privacy } from "../completedDocsRule";
+import { Exclusion } from "./exclusion";
+export interface IClassExclusionDescriptor {
+ locations?: Location[];
+ privacies?: Privacy[];
+}
+export declare class ClassExclusion extends Exclusion<IClassExclusionDescriptor> {
+ readonly locations: Set<Location>;
+ readonly privacies: Set<Privacy>;
+ excludes(node: ts.Node): boolean;
+ private shouldLocationBeDocumented(node);
+ private shouldPrivacyBeDocumented(node);
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/classExclusion.js b/node_modules/tslint/lib/rules/completed-docs/classExclusion.js
new file mode 100644
index 000000000..4c8c8ec57
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/classExclusion.js
@@ -0,0 +1,59 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var ts = require("typescript");
+var Lint = require("../../index");
+var completedDocsRule_1 = require("../completedDocsRule");
+var exclusion_1 = require("./exclusion");
+var ClassExclusion = /** @class */ (function (_super) {
+ tslib_1.__extends(ClassExclusion, _super);
+ function ClassExclusion() {
+ var _this = _super !== null && _super.apply(this, arguments) || this;
+ _this.locations = _this.createSet(_this.descriptor.locations);
+ _this.privacies = _this.createSet(_this.descriptor.privacies);
+ return _this;
+ }
+ ClassExclusion.prototype.excludes = function (node) {
+ return !(this.shouldLocationBeDocumented(node)
+ && this.shouldPrivacyBeDocumented(node));
+ };
+ ClassExclusion.prototype.shouldLocationBeDocumented = function (node) {
+ if (this.locations.has(completedDocsRule_1.ALL)) {
+ return true;
+ }
+ if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) {
+ return this.locations.has(completedDocsRule_1.LOCATION_STATIC);
+ }
+ return this.locations.has(completedDocsRule_1.LOCATION_INSTANCE);
+ };
+ ClassExclusion.prototype.shouldPrivacyBeDocumented = function (node) {
+ if (this.privacies.has(completedDocsRule_1.ALL)) {
+ return true;
+ }
+ if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword)) {
+ return this.privacies.has(completedDocsRule_1.PRIVACY_PRIVATE);
+ }
+ if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.ProtectedKeyword)) {
+ return this.privacies.has(completedDocsRule_1.PRIVACY_PROTECTED);
+ }
+ return this.privacies.has(completedDocsRule_1.PRIVACY_PUBLIC);
+ };
+ return ClassExclusion;
+}(exclusion_1.Exclusion));
+exports.ClassExclusion = ClassExclusion;
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts
new file mode 100644
index 000000000..49c905491
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusion.d.ts
@@ -0,0 +1,25 @@
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import { All } from "../completedDocsRule";
+import { ExclusionDescriptor } from "./exclusionDescriptors";
+export declare abstract class Exclusion<TDescriptor extends ExclusionDescriptor> {
+ protected readonly descriptor: Partial<TDescriptor>;
+ constructor(descriptor?: Partial<TDescriptor>);
+ abstract excludes(node: ts.Node): boolean;
+ protected createSet<T extends All | string>(values?: T[]): Set<T>;
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusion.js b/node_modules/tslint/lib/rules/completed-docs/exclusion.js
new file mode 100644
index 000000000..ff22207c6
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusion.js
@@ -0,0 +1,33 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var completedDocsRule_1 = require("../completedDocsRule");
+var Exclusion = /** @class */ (function () {
+ function Exclusion(descriptor) {
+ if (descriptor === void 0) { descriptor = {}; }
+ this.descriptor = descriptor;
+ }
+ Exclusion.prototype.createSet = function (values) {
+ if (values === undefined || values.length === 0) {
+ values = [completedDocsRule_1.ALL];
+ }
+ return new Set(values);
+ };
+ return Exclusion;
+}());
+exports.Exclusion = Exclusion;
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts
new file mode 100644
index 000000000..9fa377421
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.d.ts
@@ -0,0 +1,28 @@
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { DocType } from "../completedDocsRule";
+import { IBlockExclusionDescriptor } from "./blockExclusion";
+import { IClassExclusionDescriptor } from "./classExclusion";
+import { ITagExclusionDescriptor } from "./tagExclusion";
+export declare type ExclusionDescriptor = IBlockExclusionDescriptor | IClassExclusionDescriptor | ITagExclusionDescriptor;
+export declare type InputExclusionDescriptor = boolean | ExclusionDescriptor;
+export interface IExclusionDescriptors {
+ [type: string]: ExclusionDescriptor;
+}
+export declare type IInputExclusionDescriptors = DocType | {
+ [type: string]: InputExclusionDescriptor;
+};
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js
new file mode 100644
index 000000000..1c258a5da
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusionDescriptors.js
@@ -0,0 +1,18 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts
new file mode 100644
index 000000000..aacf39d73
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.d.ts
@@ -0,0 +1,8 @@
+import { DocType } from "../completedDocsRule";
+import { Exclusion } from "./exclusion";
+import { IInputExclusionDescriptors } from "./exclusionDescriptors";
+export declare class ExclusionFactory {
+ constructExclusionsMap(ruleArguments: IInputExclusionDescriptors[]): Map<DocType, Array<Exclusion<any>>>;
+ private addRequirements(exclusionsMap, descriptors);
+ private createRequirementsForDocType(docType, descriptor);
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js
new file mode 100644
index 000000000..6b8f5f35a
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/exclusionFactory.js
@@ -0,0 +1,60 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var utils_1 = require("../../utils");
+var blockExclusion_1 = require("./blockExclusion");
+var classExclusion_1 = require("./classExclusion");
+var tagExclusion_1 = require("./tagExclusion");
+var ExclusionFactory = /** @class */ (function () {
+ function ExclusionFactory() {
+ }
+ ExclusionFactory.prototype.constructExclusionsMap = function (ruleArguments) {
+ var exclusionsMap = new Map();
+ for (var _i = 0, ruleArguments_1 = ruleArguments; _i < ruleArguments_1.length; _i++) {
+ var ruleArgument = ruleArguments_1[_i];
+ this.addRequirements(exclusionsMap, ruleArgument);
+ }
+ return exclusionsMap;
+ };
+ ExclusionFactory.prototype.addRequirements = function (exclusionsMap, descriptors) {
+ if (typeof descriptors === "string") {
+ exclusionsMap.set(descriptors, this.createRequirementsForDocType(descriptors, {}));
+ return;
+ }
+ for (var docType in descriptors) {
+ if (utils_1.hasOwnProperty(descriptors, docType)) {
+ exclusionsMap.set(docType, this.createRequirementsForDocType(docType, descriptors[docType]));
+ }
+ }
+ };
+ ExclusionFactory.prototype.createRequirementsForDocType = function (docType, descriptor) {
+ var requirements = [];
+ if (docType === "methods" || docType === "properties") {
+ requirements.push(new classExclusion_1.ClassExclusion(descriptor));
+ }
+ else {
+ requirements.push(new blockExclusion_1.BlockExclusion(descriptor));
+ }
+ if (descriptor.tags !== undefined) {
+ requirements.push(new tagExclusion_1.TagExclusion(descriptor));
+ }
+ return requirements;
+ };
+ return ExclusionFactory;
+}());
+exports.ExclusionFactory = ExclusionFactory;
diff --git a/node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts
new file mode 100644
index 000000000..d13121323
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.d.ts
@@ -0,0 +1,34 @@
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as ts from "typescript";
+import { Exclusion } from "./exclusion";
+export interface ITagExclusionDescriptor {
+ tags?: {
+ content: IContentTags;
+ existence: string[];
+ };
+}
+export interface IContentTags {
+ [i: string]: string;
+}
+export declare class TagExclusion extends Exclusion<ITagExclusionDescriptor> {
+ private readonly contentTags;
+ private readonly existenceTags;
+ excludes(node: ts.Node): boolean;
+ private getDocumentationNode(node);
+ private parseTagsWithContents(nodeText);
+}
diff --git a/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js
new file mode 100644
index 000000000..78e9babe7
--- /dev/null
+++ b/node_modules/tslint/lib/rules/completed-docs/tagExclusion.js
@@ -0,0 +1,82 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2013 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var ts = require("typescript");
+var exclusion_1 = require("./exclusion");
+var TagExclusion = /** @class */ (function (_super) {
+ tslib_1.__extends(TagExclusion, _super);
+ function TagExclusion() {
+ var _this = _super !== null && _super.apply(this, arguments) || this;
+ _this.contentTags = _this.descriptor.tags === undefined
+ ? {}
+ : _this.descriptor.tags.content;
+ _this.existenceTags = new Set(_this.descriptor.tags !== undefined && _this.descriptor.tags.existence !== undefined
+ ? _this.descriptor.tags.existence
+ : undefined);
+ return _this;
+ }
+ TagExclusion.prototype.excludes = function (node) {
+ var documentationNode = this.getDocumentationNode(node);
+ var tagsWithContents = this.parseTagsWithContents(documentationNode.getFullText());
+ for (var _i = 0, tagsWithContents_1 = tagsWithContents; _i < tagsWithContents_1.length; _i++) {
+ var tagWithContent = tagsWithContents_1[_i];
+ if (this.existenceTags.has(tagWithContent[0])) {
+ return true;
+ }
+ var matcherBody = this.contentTags[tagWithContent[0]];
+ if (matcherBody === undefined) {
+ continue;
+ }
+ if (new RegExp(matcherBody).test(tagWithContent[1])) {
+ return true;
+ }
+ }
+ return false;
+ };
+ TagExclusion.prototype.getDocumentationNode = function (node) {
+ if (node.kind === ts.SyntaxKind.VariableDeclaration) {
+ return node.parent;
+ }
+ return node;
+ };
+ TagExclusion.prototype.parseTagsWithContents = function (nodeText) {
+ if (nodeText === undefined) {
+ return [];
+ }
+ var docMatches = nodeText.match((/\/\*\*\s*\n([^\*]*(\*[^\/])?)*\*\//));
+ if (docMatches === null || docMatches.length === 0) {
+ return [];
+ }
+ var lines = docMatches[0].match(/[\r\n\s]*\*\s*@.*[\r\n\s]/g);
+ if (lines === null) {
+ return [];
+ }
+ return lines
+ .map(function (line) {
+ var body = line.substring(line.indexOf("@"));
+ var firstSpaceIndex = body.search(/\s/);
+ return [
+ body.substring(1, firstSpaceIndex),
+ body.substring(firstSpaceIndex).trim(),
+ ];
+ });
+ };
+ return TagExclusion;
+}(exclusion_1.Exclusion));
+exports.TagExclusion = TagExclusion;