{"action":"created","comment":{"url":"https://api.github.com/repos/palantir/tslint/pulls/comments/134051024","pull_request_review_id":57307174,"id":134051024,"diff_hunk":"@@ -0,0 +1,83 @@\n+/**\n+ * @license\n+ * Copyright 2017 Palantir Technologies, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+import * as ts from \"typescript\";\n+import * as Lint from \"../index\";\n+\n+import { getChildOfKind,\n+        hasModifier,\n+        isClassDeclaration,\n+        isConstructorDeclaration,\n+        isParameterProperty } from \"tsutils\";\n+\n+export class Rule extends Lint.Rules.AbstractRule {\n+    /* tslint:disable:object-literal-sort-keys */\n+    public static metadata: Lint.IRuleMetadata = {\n+        ruleName: \"no-static-only-classes\",\n+        description: Lint.Utils.dedent`\n+            Disallows classes containing only static members. Classes\n+            with non-empty constructors are ignored.`,\n+        rationale: Lint.Utils.dedent`\n+            Users who come from a Java-style OO language may wrap\n+            their utility functions in an extra class, instead of\n+            putting them at the top level.`,\n+        optionsDescription: \"Not configurable.\",\n+        options: null,\n+        optionExamples: [true],\n+        type: \"functionality\",\n+        typescriptOnly: false,\n+    };\n+\n+    public static FAILURE_STRING = \"Classes containing only static members are disallowed.\";\n+\n+    public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {\n+        return this.applyWithWalker(new NoStaticOnlyClassesWalker(sourceFile, this.ruleName, this.ruleArguments));\n+    }\n+}\n+\n+class NoStaticOnlyClassesWalker extends Lint.AbstractWalker<string[]> {\n+    public walk(sourceFile: ts.SourceFile) {\n+        const checkIfStaticOnlyClass = (node: ts.Node): void => {\n+            if (isClassDeclaration(node) && !isEmptyClass(node) && !hasExtendsClause(node)) {\n+                for (const member of node.members) {\n+                    if (isConstructorWithShorthandProps(member) ||\n+                       (!isConstructorDeclaration(member) && !hasModifier(member.modifiers, ts.SyntaxKind.StaticKeyword))) {\n+                        return;","path":"src/rules/noStaticOnlyClassesRule.ts","position":59,"original_position":59,"commit_id":"5012ae6fac661f01ceee04b0cc34706ef0712ae0","original_commit_id":"5012ae6fac661f01ceee04b0cc34706ef0712ae0","user":{"login":"aervin","id":13973880,"avatar_url":"https://avatars0.githubusercontent.com/u/13973880?v=4","gravatar_id":"","url":"https://api.github.com/users/aervin","html_url":"https://github.com/aervin","followers_url":"https://api.github.com/users/aervin/followers","following_url":"https://api.github.com/users/aervin/following{/other_user}","gists_url":"https://api.github.com/users/aervin/gists{/gist_id}","starred_url":"https://api.github.com/users/aervin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aervin/subscriptions","organizations_url":"https://api.github.com/users/aervin/orgs","repos_url":"https://api.github.com/users/aervin/repos","events_url":"https://api.github.com/users/aervin/events{/privacy}","received_events_url":"https://api.github.com/users/aervin/received_events","type":"User","site_admin":false},"body":"Working on a fix but could use your input:\r\n\r\nCurrently this code is passing in the test file:\r\n`\r\nclass Foo {\r\n  constructor() {\r\n    class Bar {\r\n      private a: SomeType;\r\n      static PROP = 2;\r\n    }\r\n  }\r\n}\r\n`\r\n\r\nPersonally, I would not want `class Foo` in my codebase, but should it throw an error?","created_at":"2017-08-18T20:40:29Z","updated_at":"2017-08-18T20:40:29Z","html_url":"https://github.com/palantir/tslint/pull/3119#discussion_r134051024","pull_request_url":"https://api.github.com/repos/palantir/tslint/pulls/3119","_links":{"self":{"href":"https://api.github.com/repos/palantir/tslint/pulls/comments/134051024"},"html":{"href":"https://github.com/palantir/tslint/pull/3119#discussion_r134051024"},"pull_request":{"href":"https://api.github.com/repos/palantir/tslint/pulls/3119"}}},"pull_request":{"url":"https://api.github.com/repos/palantir/tslint/pulls/3119","id":135365489,"html_url":"https://github.com/palantir/tslint/pull/3119","diff_url":"https://github.com/palantir/tslint/pull/3119.diff","patch_url":"https://github.com/palantir/tslint/pull/3119.patch","issue_url":"https://api.github.com/repos/palantir/tslint/issues/3119","number":3119,"state":"open","locked":false,"title":"new-rule: no-static-only-classes","user":{"login":"aervin","id":13973880,"avatar_url":"https://avatars0.githubusercontent.com/u/13973880?v=4","gravatar_id":"","url":"https://api.github.com/users/aervin","html_url":"https://github.com/aervin","followers_url":"https://api.github.com/users/aervin/followers","following_url":"https://api.github.com/users/aervin/following{/other_user}","gists_url":"https://api.github.com/users/aervin/gists{/gist_id}","starred_url":"https://api.github.com/users/aervin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aervin/subscriptions","organizations_url":"https://api.github.com/users/aervin/orgs","repos_url":"https://api.github.com/users/aervin/repos","events_url":"https://api.github.com/users/aervin/events{/privacy}","received_events_url":"https://api.github.com/users/aervin/received_events","type":"User","site_admin":false},"body":"#### PR checklist\r\n\r\n- [x] Addresses an existing rule suggestion: #[3111](https://github.com/palantir/tslint/issues/3111)\r\n- [x] New feature, bugfix, or enhancement\r\n  - [x] Includes tests\r\n- [ ] Documentation update\r\n\r\n#### Overview of change:\r\nAdds the \"no-static-only-classes\" rule as outlined in the suggestion post. \r\n\r\nThis rule ignores a class which:\r\n- extends an existing class\r\n- implements an interface\r\n- has anything other than whitespace in its constructor\r\n\r\n#### Is there anything you'd like reviewers to focus on?\r\n- Does this rule need to take constructor parameters into account? \r\n- Still learning the different APIs--is there a better way to detect empty block scopes (see isEmptyConstructor function)? \r\n- Help w/ description/rationale\r\n","created_at":"2017-08-11T15:50:14Z","updated_at":"2017-08-18T20:40:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"77602b00217a909e6bcba9ab2b6ad9d115d60553","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/palantir/tslint/pulls/3119/commits","review_comments_url":"https://api.github.com/repos/palantir/tslint/pulls/3119/comments","review_comment_url":"https://api.github.com/repos/palantir/tslint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/palantir/tslint/issues/3119/comments","statuses_url":"https://api.github.com/repos/palantir/tslint/statuses/5012ae6fac661f01ceee04b0cc34706ef0712ae0","head":{"label":"aervin:no-static-only-classes","ref":"no-static-only-classes","sha":"5012ae6fac661f01ceee04b0cc34706ef0712ae0","user":{"login":"aervin","id":13973880,"avatar_url":"https://avatars0.githubusercontent.com/u/13973880?v=4","gravatar_id":"","url":"https://api.github.com/users/aervin","html_url":"https://github.com/aervin","followers_url":"https://api.github.com/users/aervin/followers","following_url":"https://api.github.com/users/aervin/following{/other_user}","gists_url":"https://api.github.com/users/aervin/gists{/gist_id}","starred_url":"https://api.github.com/users/aervin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aervin/subscriptions","organizations_url":"https://api.github.com/users/aervin/orgs","repos_url":"https://api.github.com/users/aervin/repos","events_url":"https://api.github.com/users/aervin/events{/privacy}","received_events_url":"https://api.github.com/users/aervin/received_events","type":"User","site_admin":false},"repo":{"id":99744643,"name":"tslint","full_name":"aervin/tslint","owner":{"login":"aervin","id":13973880,"avatar_url":"https://avatars0.githubusercontent.com/u/13973880?v=4","gravatar_id":"","url":"https://api.github.com/users/aervin","html_url":"https://github.com/aervin","followers_url":"https://api.github.com/users/aervin/followers","following_url":"https://api.github.com/users/aervin/following{/other_user}","gists_url":"https://api.github.com/users/aervin/gists{/gist_id}","starred_url":"https://api.github.com/users/aervin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aervin/subscriptions","organizations_url":"https://api.github.com/users/aervin/orgs","repos_url":"https://api.github.com/users/aervin/repos","events_url":"https://api.github.com/users/aervin/events{/privacy}","received_events_url":"https://api.github.com/users/aervin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aervin/tslint","description":":vertical_traffic_light: An extensible linter for the TypeScript language","fork":true,"url":"https://api.github.com/repos/aervin/tslint","forks_url":"https://api.github.com/repos/aervin/tslint/forks","keys_url":"https://api.github.com/repos/aervin/tslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aervin/tslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aervin/tslint/teams","hooks_url":"https://api.github.com/repos/aervin/tslint/hooks","issue_events_url":"https://api.github.com/repos/aervin/tslint/issues/events{/number}","events_url":"https://api.github.com/repos/aervin/tslint/events","assignees_url":"https://api.github.com/repos/aervin/tslint/assignees{/user}","branches_url":"https://api.github.com/repos/aervin/tslint/branches{/branch}","tags_url":"https://api.github.com/repos/aervin/tslint/tags","blobs_url":"https://api.github.com/repos/aervin/tslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aervin/tslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aervin/tslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/aervin/tslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aervin/tslint/statuses/{sha}","languages_url":"https://api.github.com/repos/aervin/tslint/languages","stargazers_url":"https://api.github.com/repos/aervin/tslint/stargazers","contributors_url":"https://api.github.com/repos/aervin/tslint/contributors","subscribers_url":"https://api.github.com/repos/aervin/tslint/subscribers","subscription_url":"https://api.github.com/repos/aervin/tslint/subscription","commits_url":"https://api.github.com/repos/aervin/tslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/aervin/tslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/aervin/tslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/aervin/tslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/aervin/tslint/contents/{+path}","compare_url":"https://api.github.com/repos/aervin/tslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aervin/tslint/merges","archive_url":"https://api.github.com/repos/aervin/tslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aervin/tslint/downloads","issues_url":"https://api.github.com/repos/aervin/tslint/issues{/number}","pulls_url":"https://api.github.com/repos/aervin/tslint/pulls{/number}","milestones_url":"https://api.github.com/repos/aervin/tslint/milestones{/number}","notifications_url":"https://api.github.com/repos/aervin/tslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aervin/tslint/labels{/name}","releases_url":"https://api.github.com/repos/aervin/tslint/releases{/id}","deployments_url":"https://api.github.com/repos/aervin/tslint/deployments","created_at":"2017-08-08T23:24:56Z","updated_at":"2017-08-08T23:24:59Z","pushed_at":"2017-08-17T17:46:37Z","git_url":"git://github.com/aervin/tslint.git","ssh_url":"git@github.com:aervin/tslint.git","clone_url":"https://github.com/aervin/tslint.git","svn_url":"https://github.com/aervin/tslint","homepage":"http://palantir.github.io/tslint/","size":13001,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"palantir:master","ref":"master","sha":"03c488685b2880140ae20186f9562f01fa25654b","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars0.githubusercontent.com/u/303157?v=4","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":11672345,"name":"tslint","full_name":"palantir/tslint","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars0.githubusercontent.com/u/303157?v=4","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/tslint","description":":vertical_traffic_light: An extensible linter for the TypeScript language","fork":false,"url":"https://api.github.com/repos/palantir/tslint","forks_url":"https://api.github.com/repos/palantir/tslint/forks","keys_url":"https://api.github.com/repos/palantir/tslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/tslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/tslint/teams","hooks_url":"https://api.github.com/repos/palantir/tslint/hooks","issue_events_url":"https://api.github.com/repos/palantir/tslint/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/tslint/events","assignees_url":"https://api.github.com/repos/palantir/tslint/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/tslint/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/tslint/tags","blobs_url":"https://api.github.com/repos/palantir/tslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/tslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/tslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/tslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/tslint/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/tslint/languages","stargazers_url":"https://api.github.com/repos/palantir/tslint/stargazers","contributors_url":"https://api.github.com/repos/palantir/tslint/contributors","subscribers_url":"https://api.github.com/repos/palantir/tslint/subscribers","subscription_url":"https://api.github.com/repos/palantir/tslint/subscription","commits_url":"https://api.github.com/repos/palantir/tslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/tslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/tslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/tslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/tslint/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/tslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/tslint/merges","archive_url":"https://api.github.com/repos/palantir/tslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/tslint/downloads","issues_url":"https://api.github.com/repos/palantir/tslint/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/tslint/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/tslint/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/tslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/tslint/labels{/name}","releases_url":"https://api.github.com/repos/palantir/tslint/releases{/id}","deployments_url":"https://api.github.com/repos/palantir/tslint/deployments","created_at":"2013-07-25T22:19:18Z","updated_at":"2017-08-18T09:50:33Z","pushed_at":"2017-08-18T18:14:47Z","git_url":"git://github.com/palantir/tslint.git","ssh_url":"git@github.com:palantir/tslint.git","clone_url":"https://github.com/palantir/tslint.git","svn_url":"https://github.com/palantir/tslint","homepage":"http://palantir.github.io/tslint/","size":12973,"stargazers_count":2220,"watchers_count":2220,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":449,"mirror_url":null,"open_issues_count":409,"forks":449,"open_issues":409,"watchers":2220,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/palantir/tslint/pulls/3119"},"html":{"href":"https://github.com/palantir/tslint/pull/3119"},"issue":{"href":"https://api.github.com/repos/palantir/tslint/issues/3119"},"comments":{"href":"https://api.github.com/repos/palantir/tslint/issues/3119/comments"},"review_comments":{"href":"https://api.github.com/repos/palantir/tslint/pulls/3119/comments"},"review_comment":{"href":"https://api.github.com/repos/palantir/tslint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/palantir/tslint/pulls/3119/commits"},"statuses":{"href":"https://api.github.com/repos/palantir/tslint/statuses/5012ae6fac661f01ceee04b0cc34706ef0712ae0"}}}}
{"actor":{"display_login":"aervin"}}