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

Commit

Permalink
fixup! fixup! Update prettier + fix new lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rrdelaney committed Feb 28, 2020
1 parent bd4c5fb commit d0e9c25
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 86 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@
"mocha": "^6.1.4",
"npm-run-all": "^4.0.2",
"nyc": "^14.1.1",
"prettier": "~1.16.4",
"prettier": "^1.19.1",
"rimraf": "^2.5.4",
"ts-node": "^3.3.0",
"tslint": "~5.13.0",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
"tslint-plugin-prettier": "^2.1.0",
"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative",
"typescript": "~3.8.2",
"yarn-deduplicate": "^1.1.1"
Expand Down
6 changes: 5 additions & 1 deletion src/files/resolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ export function resolveFilesAndProgram(
filesFound = filterFiles(Linter.getFileNames(program), exclude, false);
} else {
files = files.map(f => path.resolve(f));
filesFound = filterFiles(program.getSourceFiles().map(f => f.fileName), files, true);
filesFound = filterFiles(
program.getSourceFiles().map(f => f.fileName),
files,
true,
);
filesFound = filterFiles(filesFound, exclude, false);

// find non-glob files that have no matching file in the project and are not excluded by any exclude pattern
Expand Down
10 changes: 4 additions & 6 deletions src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,10 @@ export class Linter {

// add rule severity to failures
const ruleSeverityMap = new Map(
enabledRules.map(
(rule): [string, RuleSeverity] => [
rule.getOptions().ruleName,
rule.getOptions().ruleSeverity,
],
),
enabledRules.map((rule): [string, RuleSeverity] => [
rule.getOptions().ruleName,
rule.getOptions().ruleSeverity,
]),
);

for (const failure of fileFailures) {
Expand Down
6 changes: 5 additions & 1 deletion src/rules/arrayTypeRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export class Rule extends Lint.Rules.AbstractRule {
type: "string",
enum: [OPTION_ARRAY, OPTION_GENERIC, OPTION_ARRAY_SIMPLE],
},
optionExamples: [[true, OPTION_ARRAY], [true, OPTION_GENERIC], [true, OPTION_ARRAY_SIMPLE]],
optionExamples: [
[true, OPTION_ARRAY],
[true, OPTION_GENERIC],
[true, OPTION_ARRAY_SIMPLE],
],
type: "style",
typescriptOnly: true,
};
Expand Down
6 changes: 5 additions & 1 deletion src/rules/commentTypeRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export class Rule extends Lint.Rules.AbstractRule {
},
uniqueItems: true,
},
optionExamples: [[true, "doc", "singleline"], [true, "singleline"], [true, "multiline"]],
optionExamples: [
[true, "doc", "singleline"],
[true, "singleline"],
[true, "multiline"],
],
hasFix: false,
type: "style",
typescriptOnly: false,
Expand Down
14 changes: 6 additions & 8 deletions src/rules/completed-docs/tagExclusion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ export class TagExclusion extends Exclusion<ITagExclusionDescriptor> {
return [];
}

return lines.map(
(line): [string, string] => {
const body = line.substring(line.indexOf("@"));
const firstSpaceIndex = body.search(/\s/);

return [body.substring(1, firstSpaceIndex), body.substring(firstSpaceIndex).trim()];
},
);
return lines.map((line): [string, string] => {
const body = line.substring(line.indexOf("@"));
const firstSpaceIndex = body.search(/\s/);

return [body.substring(1, firstSpaceIndex), body.substring(firstSpaceIndex).trim()];
});
}
}
39 changes: 18 additions & 21 deletions src/rules/importBlacklistRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
ImportKind,
isExportDeclaration,
isImportDeclaration,
isNamedImports,
isNamedExports,
isNamedImports,
} from "tsutils";
import * as ts from "typescript";

Expand Down Expand Up @@ -119,25 +119,22 @@ function walk(ctx: Lint.WalkContext<Options>) {
// Merge/normalize options.
// E.g., ["a", { "b": ["c"], "d": ["e", "e"] }, "f", { "f": ["g"] }]
// becomes { "a": true, "b": Set(["c"]), "d": Set(["e"]), "f": true }.
const bannedImports = ctx.options.reduce<BannedImports>(
(acc, it) => {
if (typeof it === "string") {
acc[it] = true;
} else if (!Array.isArray(it)) {
Object.keys(it).forEach(moduleName => {
if (acc[moduleName] instanceof Set) {
it[moduleName].forEach(bannedImport => {
(acc[moduleName] as Set<string>).add(bannedImport);
});
} else if (acc[moduleName] !== true) {
acc[moduleName] = new Set(it[moduleName]);
}
});
}
return acc;
},
Object.create(null) as BannedImports,
);
const bannedImports = ctx.options.reduce<BannedImports>((acc, it) => {
if (typeof it === "string") {
acc[it] = true;
} else if (!Array.isArray(it)) {
Object.keys(it).forEach(moduleName => {
if (acc[moduleName] instanceof Set) {
it[moduleName].forEach(bannedImport => {
(acc[moduleName] as Set<string>).add(bannedImport);
});
} else if (acc[moduleName] !== true) {
acc[moduleName] = new Set(it[moduleName]);
}
});
}
return acc;
}, Object.create(null) as BannedImports);

const regexOptions = [];
for (const option of ctx.options) {
Expand Down Expand Up @@ -238,7 +235,7 @@ function walk(ctx: Lint.WalkContext<Options>) {
toExportName,
)
: []),
...(exportClause && isNamedExports(exportClause)
...(exportClause !== undefined && isNamedExports(exportClause)
? exportClause.elements.map(toExportName)
: []),
];
Expand Down
5 changes: 4 additions & 1 deletion src/rules/interfaceNameRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export class Rule extends Lint.Rules.AbstractRule {
type: "string",
enum: [OPTION_ALWAYS, OPTION_NEVER],
},
optionExamples: [[true, OPTION_ALWAYS], [true, OPTION_NEVER]],
optionExamples: [
[true, OPTION_ALWAYS],
[true, OPTION_NEVER],
],
type: "style",
typescriptOnly: true,
};
Expand Down
5 changes: 4 additions & 1 deletion src/rules/linebreakStyleRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export class Rule extends Lint.Rules.AbstractRule {
type: "string",
enum: [OPTION_LINEBREAK_STYLE_LF, OPTION_LINEBREAK_STYLE_CRLF],
},
optionExamples: [[true, OPTION_LINEBREAK_STYLE_LF], [true, OPTION_LINEBREAK_STYLE_CRLF]],
optionExamples: [
[true, OPTION_LINEBREAK_STYLE_LF],
[true, OPTION_LINEBREAK_STYLE_CRLF],
],
type: "formatting",
typescriptOnly: false,
hasFix: true,
Expand Down
5 changes: 4 additions & 1 deletion src/rules/maxClassesPerFileRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export class Rule extends Lint.Rules.AbstractRule {
minLength: 1,
maxLength: 2,
},
optionExamples: [[true, 1], [true, 5, OPTION_EXCLUDE_CLASS_EXPRESSIONS]],
optionExamples: [
[true, 1],
[true, 5, OPTION_EXCLUDE_CLASS_EXPRESSIONS],
],
type: "maintainability",
typescriptOnly: false,
};
Expand Down
4 changes: 1 addition & 3 deletions src/rules/memberAccessRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ export class Rule extends Lint.Rules.AbstractRule {
if (noPublic) {
if (checkAccessor || checkConstructor || checkParameterProperty) {
showWarningOnce(
`Warning: ${
this.ruleName
} - If 'no-public' is present, it should be the only option.`,
`Warning: ${this.ruleName} - If 'no-public' is present, it should be the only option.`,
);
return [];
}
Expand Down
12 changes: 6 additions & 6 deletions src/rules/noUnsafeAnyRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ class NoUnsafeAnyWalker extends Lint.AbstractWalker {
}
case ts.SyntaxKind.VariableDeclaration:
case ts.SyntaxKind.Parameter:
return this.checkVariableOrParameterDeclaration(node as
| ts.VariableDeclaration
| ts.ParameterDeclaration);
return this.checkVariableOrParameterDeclaration(
node as ts.VariableDeclaration | ts.ParameterDeclaration,
);
case ts.SyntaxKind.BinaryExpression:
return this.checkBinaryExpression(node as ts.BinaryExpression, anyOk);
case ts.SyntaxKind.AwaitExpression:
Expand Down Expand Up @@ -424,9 +424,9 @@ function isPropertyAnyOrUnknown(node: ts.PropertyDeclaration, checker: ts.TypeCh
) {
return false;
}
for (const base of checker.getBaseTypes(checker.getTypeAtLocation(
node.parent,
) as ts.InterfaceType)) {
for (const base of checker.getBaseTypes(
checker.getTypeAtLocation(node.parent) as ts.InterfaceType,
)) {
const prop = base.getProperty(node.name.text);
if (prop !== undefined && prop.declarations !== undefined) {
return isAny(checker.getTypeOfSymbolAtLocation(prop, prop.declarations[0]), true);
Expand Down
5 changes: 4 additions & 1 deletion src/rules/objectLiteralKeyQuotesRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export class Rule extends Lint.Rules.AbstractRule {
enum: [OPTION_ALWAYS, OPTION_AS_NEEDED, OPTION_CONSISTENT, OPTION_CONSISTENT_AS_NEEDED],
// TODO: eslint supports "keywords", "unnecessary" and "numbers" options.
},
optionExamples: [[true, OPTION_AS_NEEDED], [true, OPTION_ALWAYS]],
optionExamples: [
[true, OPTION_AS_NEEDED],
[true, OPTION_ALWAYS],
],
type: "style",
typescriptOnly: false,
};
Expand Down
12 changes: 6 additions & 6 deletions src/rules/objectLiteralSortKeysRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ export class Rule extends Lint.Rules.OptionallyTypedRule {
if (options.matchDeclarationOrder && options.matchDeclarationOrderOnly) {
showWarningOnce(
`"${OPTION_MATCH_DECLARATION_ORDER}" will be ignored since ` +
`"${OPTION_MATCH_DECLARATION_ORDER_ONLY}" has been enabled for ${
this.ruleName
}.`,
`"${OPTION_MATCH_DECLARATION_ORDER_ONLY}" has been enabled for ${this.ruleName}.`,
);
return [];
}
Expand Down Expand Up @@ -214,9 +212,11 @@ function walk(ctx: Lint.WalkContext<Options>, checker?: ts.TypeChecker): void {
m.kind === ts.SyntaxKind.MethodSignature,
)
) {
checkMatchesDeclarationOrder(node, type, type.members as ReadonlyArray<
ts.PropertySignature | ts.MethodSignature
>);
checkMatchesDeclarationOrder(
node,
type,
type.members as ReadonlyArray<ts.PropertySignature | ts.MethodSignature>,
);
return;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/rules/preferReadonlyRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ function walk(context: Lint.WalkContext<Options>, typeChecker: ts.TypeChecker) {

case ts.SyntaxKind.PostfixUnaryExpression:
case ts.SyntaxKind.PrefixUnaryExpression:
handleParentPostfixOrPrefixUnaryExpression(parent as
| ts.PostfixUnaryExpression
| ts.PrefixUnaryExpression);
handleParentPostfixOrPrefixUnaryExpression(
parent as ts.PostfixUnaryExpression | ts.PrefixUnaryExpression,
);
}

ts.forEachChild(node, visitNode);
Expand Down
8 changes: 4 additions & 4 deletions src/rules/whitespaceRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,10 @@ function walk(ctx: Lint.WalkContext<Options>) {
const nextPos = range.pos + 1;
if (
options.postbrace &&
(sourceFile.text[nextPos] !== " " &&
sourceFile.text[nextPos] !== "\r" &&
sourceFile.text[nextPos] !== "\t" &&
sourceFile.text[nextPos] !== "\n")
sourceFile.text[nextPos] !== " " &&
sourceFile.text[nextPos] !== "\r" &&
sourceFile.text[nextPos] !== "\t" &&
sourceFile.text[nextPos] !== "\n"
) {
addMissingWhitespaceErrorAt(nextPos);
}
Expand Down
4 changes: 1 addition & 3 deletions src/verify/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ export function parseErrorsFromMarkup(text: string): LintError[] {
for (let nextLineNo = lineNo + 1; ; ++nextLineNo) {
if (!isValidErrorMarkupContinuation(errorLinesForCodeLines, nextLineNo)) {
throw lintSyntaxError(
`Error mark starting at ${errorStartPos.line}:${
errorStartPos.col
} does not end correctly.`,
`Error mark starting at ${errorStartPos.line}:${errorStartPos.col} does not end correctly.`,
);
} else {
const nextErrorLine = errorLinesForCodeLines[nextLineNo].shift();
Expand Down
29 changes: 12 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"

minimist@0.0.8:
minimist@0.0.8, minimist@~0.0.1:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=
Expand All @@ -1133,11 +1133,6 @@ minimist@^1.2.0:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=

minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=

mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
Expand Down Expand Up @@ -1465,10 +1460,10 @@ pkg-dir@^3.0.0:
dependencies:
find-up "^3.0.0"

prettier@~1.16.4:
version "1.16.4"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717"
integrity sha512-ZzWuos7TI5CKUeQAtFd6Zhm2s6EpAD/ZLApIhsF9pRvRtM1RFo61dM/4MSRUA0SuLugA/zgrZD8m0BaY46Og7g==
prettier@^1.19.1:
version "1.19.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==

ps-tree@^1.0.1:
version "1.1.0"
Expand Down Expand Up @@ -1821,19 +1816,19 @@ tsconfig@^6.0.0:
strip-json-comments "^2.0.0"

tslib@^1.10.0, tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
version "1.11.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==

tslint-config-prettier@^1.18.0:
version "1.18.0"
resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz#75f140bde947d35d8f0d238e0ebf809d64592c37"
integrity sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==

tslint-plugin-prettier@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/tslint-plugin-prettier/-/tslint-plugin-prettier-2.0.1.tgz#95b6a3b766622ffc44375825d7760225c50c3680"
integrity sha512-4FX9JIx/1rKHIPJNfMb+ooX1gPk5Vg3vNi7+dyFYpLO+O57F4g+b/fo1+W/G0SUOkBLHB/YKScxjX/P+7ZT/Tw==
tslint-plugin-prettier@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tslint-plugin-prettier/-/tslint-plugin-prettier-2.1.0.tgz#e2522d273cb9672d93d0e68f2514fe3c19698c3a"
integrity sha512-nMCpU+QSpXtydcWXeZF+3ljIbG/K8SHVZwB7K/MtuoQQFXxXN6watqTSBpVXCInuPFvmjiWkhxeMoUW4N0zgSg==
dependencies:
eslint-plugin-prettier "^2.2.0"
lines-and-columns "^1.1.6"
Expand Down

0 comments on commit d0e9c25

Please sign in to comment.