]> git.lizzy.rs Git - rust.git/commitdiff
Merge #2527
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Wed, 11 Dec 2019 16:14:41 +0000 (16:14 +0000)
committerGitHub <noreply@github.com>
Wed, 11 Dec 2019 16:14:41 +0000 (16:14 +0000)
2527: Enable tsc builtin lint options  for vscode/extension r=matklad a=saneyuki

* These options are not enabled by `--strict` option and these options make a code more solid.
    * https://www.typescriptlang.org/docs/handbook/compiler-options.html
* For `noUnusedParameters` , we need to tweak tslint option to allow `_bar` style.

Co-authored-by: Tetsuharu OHZEKI <tetsuharu.ohzeki@gmail.com>
editors/code/src/commands/analyzer_status.ts
editors/code/src/commands/expand_macro.ts
editors/code/src/commands/runnables.ts
editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts
editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts
editors/code/src/test/utils/diagnotics/rust.test.ts
editors/code/tsconfig.json
editors/code/tslint.json

index 9e4ce0eb3c00d802012fc5baef21c1835ba5d9fa..2777ced2479f5b14d3c4a618cb95baa90f4a47f5 100644 (file)
@@ -9,7 +9,7 @@ export class TextDocumentContentProvider
     public syntaxTree: string = 'Not available';
 
     public provideTextDocumentContent(
-        uri: vscode.Uri,
+        _uri: vscode.Uri,
     ): vscode.ProviderResult<string> {
         const editor = vscode.window.activeTextEditor;
         if (editor == null) {
index 842898020be01133390ed0453ae565a8751496c9..17c78280a89a5fc4c09973407090160bbfd342df 100644 (file)
@@ -11,7 +11,7 @@ export class ExpandMacroContentProvider
     public eventEmitter = new vscode.EventEmitter<vscode.Uri>();
 
     public provideTextDocumentContent(
-        uri: vscode.Uri,
+        _uri: vscode.Uri,
     ): vscode.ProviderResult<string> {
         async function handle() {
             const editor = vscode.window.activeTextEditor;
index 9b1c6643d40b24c115b91524b7222fd9be741a55..cf980e257854796d121765309238392c5c145ae3 100644 (file)
@@ -73,7 +73,7 @@ function createTask(spec: Runnable): vscode.Task {
 }
 
 let prevRunnable: RunnableQuickPick | undefined;
-export async function handle() {
+export async function handle(): Promise<vscode.TaskExecution | undefined> {
     const editor = vscode.window.activeTextEditor;
     if (editor == null || editor.document.languageId !== 'rust') {
         return;
@@ -105,12 +105,14 @@ export async function handle() {
         items.push(new RunnableQuickPick(r));
     }
     const item = await vscode.window.showQuickPick(items);
-    if (item) {
-        item.detail = 'rerun';
-        prevRunnable = item;
-        const task = createTask(item.runnable);
-        return await vscode.tasks.executeTask(task);
+    if (!item) {
+        return;
     }
+
+    item.detail = 'rerun';
+    prevRunnable = item;
+    const task = createTask(item.runnable);
+    return await vscode.tasks.executeTask(task);
 }
 
 export async function handleSingle(runnable: Runnable) {
@@ -178,7 +180,7 @@ export async function startCargoWatch(
         }
 
         const label = 'install-cargo-watch';
-        const taskFinished = new Promise((resolve, reject) => {
+        const taskFinished = new Promise((resolve, _reject) => {
             const disposable = vscode.tasks.onDidEndTask(({ execution }) => {
                 if (execution.task.name === label) {
                     disposable.dispose();
index 96ec8c614d093bdda55f1b3aa40e9ded332c2997..2b25eb705dd35743f432df559326249c34ba4244 100644 (file)
@@ -114,7 +114,8 @@ describe('SuggestedFix', () => {
 
             const edit = codeAction.edit;
             if (!edit) {
-                return assert.fail('Code Action edit unexpectedly missing');
+                assert.fail('Code Action edit unexpectedly missing');
+                return;
             }
 
             const editEntries = edit.entries();
index 4c1467b5760279e74917f8c9af169c2a88f1b33c..ef09013f413040e763c942dad1bc006a118a1312 100644 (file)
@@ -53,7 +53,8 @@ describe('SuggestedFixCollection', () => {
 
         const { diagnostics } = codeAction;
         if (!diagnostics) {
-            return assert.fail('Diagnostics unexpectedly missing');
+            assert.fail('Diagnostics unexpectedly missing');
+            return;
         }
 
         assert.strictEqual(diagnostics.length, 1);
@@ -114,7 +115,8 @@ describe('SuggestedFixCollection', () => {
         const { diagnostics } = codeAction;
 
         if (!diagnostics) {
-            return assert.fail('Diagnostics unexpectedly missing');
+            assert.fail('Diagnostics unexpectedly missing');
+            return;
         }
 
         // We should be associated with both diagnostics
index cee59061f3b529f1091edf5662401c49ead47c14..0222dbbaa0e69f94758d74946f8816c6c097161b 100644 (file)
@@ -120,7 +120,8 @@ describe('mapRustDiagnosticToVsCode', () => {
         // One related information for the original definition
         const relatedInformation = diagnostic.relatedInformation;
         if (!relatedInformation) {
-            return assert.fail('Related information unexpectedly undefined');
+            assert.fail('Related information unexpectedly undefined');
+            return;
         }
         assert.strictEqual(relatedInformation.length, 1);
         const [related] = relatedInformation;
@@ -154,7 +155,8 @@ describe('mapRustDiagnosticToVsCode', () => {
         // One related information for the lint definition
         const relatedInformation = diagnostic.relatedInformation;
         if (!relatedInformation) {
-            return assert.fail('Related information unexpectedly undefined');
+            assert.fail('Related information unexpectedly undefined');
+            return;
         }
         assert.strictEqual(relatedInformation.length, 1);
         const [related] = relatedInformation;
index 8cb1e90351a1876712353d38055749f96fab8598..5e11c37751201d2b8e57fa3e88293695cbd8b29a 100644 (file)
@@ -7,7 +7,10 @@
         "sourceMap": true,
         "rootDir": "src",
         "strict": true,
-        "noUnusedLocals": true
+        "noUnusedLocals": true,
+        "noUnusedParameters": true,
+        "noImplicitReturns": true,
+        "noFallthroughCasesInSwitch": true
     },
     "exclude": ["node_modules", ".vscode-test"]
 }
index bdeb4895eee6f9ba17b868ad431ed056d6789d2b..b69c5574d26535de4edf66c964acf115cecc2be9 100644 (file)
@@ -4,6 +4,8 @@
     "rules": {
         "quotemark": [true, "single"],
         "interface-name": false,
-        "object-literal-sort-keys": false
+        "object-literal-sort-keys": false,
+        // Allow `_bar` to sort with tsc's `noUnusedParameters` option
+        "variable-name": [true, "allow-leading-underscore"]
     }
 }