Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why I'm getting suggestions based on dom.d.ts lib in VSCode? #343

Closed
mohsen1 opened this issue Mar 9, 2019 · 1 comment · Fixed by #347
Closed

Why I'm getting suggestions based on dom.d.ts lib in VSCode? #343

mohsen1 opened this issue Mar 9, 2019 · 1 comment · Fixed by #347
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look

Comments

@mohsen1
Copy link
Contributor

mohsen1 commented Mar 9, 2019

I confirmed that none of the configurations include "lib: ["dom"] but still I'm getting autocomplete results for window and such:

Screen Shot 2019-03-09 at 11 17 27 AM

For completeness here is TSServer logs:

[Info  - 11:15:03 AM] Using tsserver from: /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib
[Info  - 11:15:03 AM] TSServer log file: /Users/mohsen_nabiloo-azimi/Library/Application Support/Code/logs/20190302T212625/exthost26/vscode.typescript-language-features/tsserver-log-Nmu0P2/tsserver.log
[Info  - 11:15:03 AM] Forking TSServer
[Info  - 11:15:03 AM] Started TSServer
[Trace  - 11:15:03 AM] Sending request: configure (0). Response expected: no. Current queue length: 0
Arguments: {
    "hostInfo": "vscode",
    "preferences": {
        "providePrefixAndSuffixTextForRename": true,
        "allowRenameOfImportPath": true
    }
}
[Trace  - 11:15:03 AM] Sending request: compilerOptionsForInferredProjects (1). Response expected: no. Current queue length: 0
Arguments: {
    "options": {
        "module": "commonjs",
        "target": "es2016",
        "jsx": "preserve",
        "allowJs": true,
        "allowSyntheticDefaultImports": true,
        "allowNonTsExtensions": true
    }
}
[Trace  - 11:15:03 AM] Sending request: open (2). Response expected: no. Current queue length: 0
Arguments: {
    "file": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts",
    "fileContent": "import ts from 'typescript';\nimport * as util from '../util';\nimport { TSESTree } from '@typescript-eslint/typescript-estree';\n\nexport default util.createRule({\n  name: 'no-enum-literal-comparison',\n  meta: {\n    type: 'suggestion',\n    docs: {\n      description: 'Disallows usage of literals instead of enums',\n      category: 'Best Practices',\n      recommended: 'error',\n    },\n    messages: {\n      noLiterals: 'Do not use literal values instead of enums',\n    },\n    schema: [],\n  },\n  defaultOptions: [],\n  create(context) {\n    const parserServices = util.getParserServices(context);\n    const checker = parserServices.program.getTypeChecker();\n\n    /**\n     * is node an identifier with type of an enum\n     * @param node identifier node\n     */\n    function isNodeEnumIdentifier(node: TSESTree.Node): boolean {\n      const originalNode = parserServices.esTreeNodeToTSNodeMap.get<\n        ts.Identifier\n      >(node);\n      const type = checker.getTypeAtLocation(originalNode);\n\n      if (!type.symbol) {\n        return false;\n      }\n\n      const { name } = type.symbol;\n\n      return !['Number', 'String'].includes(name);\n    }\n\n    function isNumberOrStringLiteral(\n      node: TSESTree.Node,\n    ): node is TSESTree.Literal {\n      return (\n        node.type === 'Literal' &&\n        ['number', 'string'].includes(typeof node.value)\n      );\n    }\n\n    return {\n      AssignmentExpression(node) {\n        if (\n          isNodeEnumIdentifier(node.left) &&\n          isNumberOrStringLiteral(node.right)\n        ) {\n          context.report({\n            node: node.right,\n            messageId: 'noLiterals',\n          });\n        }\n      },\n      BinaryExpression(node) {\n        if (\n          isNodeEnumIdentifier(node.left) &&\n          isNumberOrStringLiteral(node.right)\n        ) {\n          context.report({\n            node: node.right,\n            messageId: 'noLiterals',\n          });\n        }\n\n        if (\n          isNumberOrStringLiteral(node.left) &&\n          isNodeEnumIdentifier(node.right)\n        ) {\n          context.report({\n            node: node.left,\n            messageId: 'noLiterals',\n          });\n        }\n      },\n      VariableDeclarator(node) {\n        if (\n          isNodeEnumIdentifier(node.id) &&\n          node.init &&\n          isNumberOrStringLiteral(node.init)\n        ) {\n          context.report({\n            node: node.init,\n            messageId: 'noLiterals',\n          });\n        }\n      },\n      CallExpression(node) {\n        const originalNode = parserServices.esTreeNodeToTSNodeMap.get<\n          ts.CallExpression\n        >(node);\n        const callExpressionType = checker.getTypeAtLocation(originalNode);\n\n        if (node.arguments) {\n          for (const argument of node.arguments) {\n            const argumentType = checker.getTypeAtLocation(originalNode);\n          }\n        }\n      },\n    };\n  },\n});\n",
    "scriptKindName": "TS",
    "projectRootPath": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint"
}
[Trace  - 11:15:03 AM] Sending request: configurePlugin (3). Response expected: no. Current queue length: 0
Arguments: {
    "pluginName": "typescript-tslint-plugin",
    "configuration": {}
}
[Trace  - 11:15:03 AM] Sending request: geterr (4). Response expected: yes. Current queue length: 0
Arguments: {
    "delay": 0,
    "files": [
        "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts"
    ]
}
[Trace  - 11:15:06 AM] Event received: projectLoadingStart (0).
Data: {
    "projectName": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/tsconfig.json",
    "reason": "Creating possible configured project for /Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts to open"
}
[Trace  - 11:15:06 AM] Event received: projectLoadingFinish (0).
Data: {
    "projectName": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/tsconfig.json"
}
[Trace  - 11:15:06 AM] Event received: telemetry (0).
Data: {
    "telemetryEventName": "projectInfo",
    "payload": {
        "projectId": "be4f0629ce1820bbc419f3b4760e7537b7c2df2fc1726bbbe022c8c939631991",
        "fileStats": {
            "js": 0,
            "jsSize": 0,
            "jsx": 0,
            "jsxSize": 0,
            "ts": 108,
            "tsSize": 714247,
            "tsx": 0,
            "tsxSize": 0,
            "dts": 134,
            "dtsSize": 2726497,
            "deferred": 0,
            "deferredSize": 0
        },
        "compilerOptions": {
            "allowSyntheticDefaultImports": true,
            "allowUnreachableCode": false,
            "allowUnusedLabels": false,
            "declaration": false,
            "declarationMap": false,
            "esModuleInterop": true,
            "module": "commonjs",
            "moduleResolution": "node",
            "noImplicitReturns": true,
            "noUnusedLocals": true,
            "noUnusedParameters": true,
            "pretty": true,
            "sourceMap": true,
            "strict": true,
            "target": "es2017",
            "outDir": "",
            "resolveJsonModule": true
        },
        "typeAcquisition": {
            "enable": false,
            "include": false,
            "exclude": false
        },
        "extends": true,
        "files": false,
        "include": true,
        "exclude": false,
        "compileOnSave": false,
        "configFileName": "tsconfig.json",
        "projectType": "configured",
        "languageServiceEnabled": true,
        "version": "3.3.1"
    }
}
[Trace  - 11:15:06 AM] Event received: configFileDiag (0).
Data: {
    "triggerFile": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts",
    "configFile": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/tsconfig.json",
    "diagnostics": []
}
[Trace  - 11:15:06 AM] Event received: projectsUpdatedInBackground (0).
Data: {
    "openFiles": [
        "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts"
    ]
}
[Trace  - 11:15:06 AM] Event received: typingsInstallerPid (0).
Data: {
    "pid": 51161
}
[Trace  - 11:15:06 AM] Event received: projectsUpdatedInBackground (0).
Data: {
    "openFiles": [
        "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts"
    ]
}
[Trace  - 11:15:06 AM] Event received: syntaxDiag (0).
Data: {
    "file": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts",
    "diagnostics": []
}
[Trace  - 11:15:07 AM] TypeScript Server: trying to cancel ongoing request with sequence number 4
[Trace  - 11:15:07 AM] Sending request: geterr (5). Response expected: yes. Current queue length: 0
Arguments: {
    "delay": 0,
    "files": [
        "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts"
    ]
}
[Trace  - 11:15:07 AM] Event received: semanticDiag (0).
Data: {
    "file": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts",
    "diagnostics": [
        {
            "start": {
                "line": 101,
                "offset": 15
            },
            "end": {
                "line": 101,
                "offset": 33
            },
            "text": "'callExpressionType' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        },
        {
            "start": {
                "line": 104,
                "offset": 22
            },
            "end": {
                "line": 104,
                "offset": 30
            },
            "text": "'argument' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        },
        {
            "start": {
                "line": 105,
                "offset": 19
            },
            "end": {
                "line": 105,
                "offset": 31
            },
            "text": "'argumentType' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        }
    ]
}
[Trace  - 11:15:07 AM] Event received: syntaxDiag (0).
Data: {
    "file": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts",
    "diagnostics": []
}
[Trace  - 11:15:07 AM] Event received: semanticDiag (0).
Data: {
    "file": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts",
    "diagnostics": [
        {
            "start": {
                "line": 101,
                "offset": 15
            },
            "end": {
                "line": 101,
                "offset": 33
            },
            "text": "'callExpressionType' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        },
        {
            "start": {
                "line": 104,
                "offset": 22
            },
            "end": {
                "line": 104,
                "offset": 30
            },
            "text": "'argument' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        },
        {
            "start": {
                "line": 105,
                "offset": 19
            },
            "end": {
                "line": 105,
                "offset": 31
            },
            "text": "'argumentType' is declared but its value is never read.",
            "code": 6133,
            "category": "error",
            "reportsUnnecessary": true
        }
    ]
}
[Trace  - 11:15:07 AM] Event received: suggestionDiag (0).
Data: {
    "file": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts",
    "diagnostics": []
}
@mohsen1 mohsen1 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Mar 9, 2019
@bradzacher
Copy link
Member

Because we haven't configured the targets or libraries at all.
TS just defaults to what the majority use case is - which is web.

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants