Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

member-access: add fixer #2969

Merged
merged 5 commits into from
Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use getModifier from tsutils
  • Loading branch information
ajafff committed Jul 10, 2017
commit 8848aecd750a2086c3024b98050951bba14b9145
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.7.1",
"tsutils": "^2.3.0"
"tsutils": "^2.6.0"
},
"peerDependencies": {
"typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev"
Expand Down
14 changes: 2 additions & 12 deletions src/rules/memberAccessRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { getChildOfKind, getNextToken, isClassLikeDeclaration } from "tsutils";
import { getChildOfKind, getModifier, getNextToken, isClassLikeDeclaration } from "tsutils";
import * as ts from "typescript";

import { showWarningOnce } from "../error";
Expand Down Expand Up @@ -118,17 +118,7 @@ function walk(ctx: Lint.WalkContext<Options>) {
if (Lint.hasModifier(node.modifiers, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword)) {
return;
}

let publicKeyword: ts.Node | undefined;
if (node.modifiers !== undefined) {
for (const modifier of node.modifiers) {
if (modifier.kind === ts.SyntaxKind.PublicKeyword) {
publicKeyword = modifier;
break;
}
}
}

const publicKeyword = getModifier(node, ts.SyntaxKind.PublicKeyword);
if (noPublic && publicKeyword !== undefined) {
const start = publicKeyword.end - "public".length;
ctx.addFailure(
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,12 @@ tsutils@^2.3.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.4.0.tgz#ad4ce6dba0e5a3edbddf8626b7ca040782189fea"

tsutils@^2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.6.0.tgz#e5e99c79a8accd3977ce18d83fdf1d235a6c2ebb"
dependencies:
tslib "^1.7.1"

type-detect@0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"
Expand Down