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

Cloud version not finding typescript types #524

Open
1 task
nmkataoka opened this issue Apr 1, 2021 · 0 comments
Open
1 task

Cloud version not finding typescript types #524

nmkataoka opened this issue Apr 1, 2021 · 0 comments

Comments

@nmkataoka
Copy link

nmkataoka commented Apr 1, 2021

Bug Template

Actual Behavior

Cloud code climate eslint does not seem to be picking up typescript types from packages for my config. Kind of at wit's end with this on since local code climate works fine. When I have a file with the following code:

import { createContext } from 'react';

export const context = createContext(undefined);

I expect to get no errors, but I'm getting a violation of the rule typescript-eslint/no-unsafe-call (shows up in code climate as Unsafe call of an any typed value). I think this means the eslint running on cloud code climate is not finding the types from React for some reason.

When I run eslint locally and code climate locally, they both show no error as expected.

Expected Behavior

There should not be a rule violation here.

Steps to reproduce

  1. _Include configurations used in your:

    (1) .codeclimate.yml
version: "2"
plugins:
  eslint:
    enabled: true
    channel: "eslint-7"
    config:
      config: ./.eslintrc.js
      extensions:
        - .js
        - .jsx
        - .ts
        - .tsx
    checks:
      import/extensions:
        enabled: false
  duplication:
    enabled: false

(2) config files for the oss analysis tool._

tsconfig.json
{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve"
  },
  "include": [
    "**/*.ts",
    "**/*.tsx",
    "**/*.js",
    "**/*.jsx"
  ],
  "exclude": [
    "node_modules"
  ]
}
.eslintrc.js
module.exports = {
  extends: [
    'plugin:react/recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
  ],
  ignorePatterns: ['.eslintrc.js'],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 2020,
    project: './tsconfig.json',
  },
  plugins: [
    '@typescript-eslint',
    'react',
    'react-hooks',
    'jest',
    'jsx-a11y',
    'import',
  ],
  rules: {
    'react/react-in-jsx-scope': 0,
  }
};
package.json
{
  "name": "codeclimate-typescript-test2",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "eslint . --ignore-path .gitignore --ext .js,.jsx,.tsx,.ts",
    "lint:fix": "eslint --fix --ignore-path .gitignore . --ext .js,.jsx,.tsx,.ts"
  },
  "dependencies": {
    "next": "10.1.2",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },
  "devDependencies": {
    "@types/classnames": "2.2.11",
    "@types/jest": "24.0.14",
    "@types/pdfjs-dist": "2.7.0",
    "@types/react": "^17.0.3",
    "@types/react-bootstrap": "0.32.25",
    "@types/react-dom": "16.9.10",
    "@types/react-redux": "7.1.16",
    "@types/redux-mock-store": "1.0.2",
    "@typescript-eslint/eslint-plugin": "4.18.0",
    "@typescript-eslint/parser": "4.18.0",
    "eslint": "7.6.0",
    "eslint-import-resolver-typescript": "2.4.0",
    "eslint-plugin-eslint-comments": "3.2.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jest": "23.13.2",
    "eslint-plugin-jsx-a11y": "6.4.1",
    "eslint-plugin-postcss-modules": "1.2.1",
    "eslint-plugin-react": "7.21.0",
    "eslint-plugin-react-hooks": "1.6.0",
    "typescript": "3.9.7"
  }
}
  1. If possible, use our CLI with the debug option to provide additional info, including any stderr produced by the engine. CODECLIMATE_DEBUG=1 codeclimate analyze -e eslint

Local code climate does not have the issue so I'm not sure if this is helpful, but here's the output from running code climate locally:

Local code climate output
➜  codeclimate-typescript-test2 git:(diagnose_ts_issue_2) CODECLIMATE_DEBUG=1 codeclimate analyze -e eslint
Starting analysis
I, [2021-04-01T22:11:11.510648 #1]  INFO -- : starting engine eslint
D, [2021-04-01T22:11:36.914651 #1] DEBUG -- : /config.json content: {"enabled"=>true, "channel"=>"eslint-7", "config"=>{"config"=>"./.eslintrc.js", "extensions"=>[".js", ".jsx", ".ts", ".tsx"]}, "checks"=>{"import/extensions"=>{"enabled"=>false}}, "include_paths"=>[".next/", "README.md", "styles/", "components/", "public/", ".gitignore", "package-lock.json", "package.json", ".eslintrc.js", "tsconfig.json", "pages/", ".codeclimate.yml"], "debug"=>"1"}
D, [2021-04-01T22:11:36.928891 #1] DEBUG -- : docker run: ["docker", "run", "--name", "cc-engines-eslint-eslint-7-24547312-c89b-411c-adf4-816493eec76a", "--cap-drop", "all", "--label", "com.codeclimate.label=1765eca0-e4d0-4ac8-a679-76b80cb1f1f6", "--log-driver", "none", "--memory-swap", "-1", "--net", "none", "--rm", "--volume", "/Users/nolankataoka/FormSwift/codeclimate-typescript-test2:/code:ro", "--volume", "/tmp/cc/a40b5139-206e-4b54-9ecc-ae721e5dcabe:/config.json:ro", "--user", "9000:9000", "--memory", "1024000000", "codeclimate/codeclimate-eslint:eslint-7"]
D, [2021-04-01T22:11:50.540542 #1] DEBUG -- : engine stderr: Warning: React version not specified in eslint-plugin-react settings. See https://github.com/yannickcr/eslint-plugin-react#configuration .
D, [2021-04-01T22:11:51.213804 #1] DEBUG -- : engine stdout: {"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/explicit-module-boundary-types","description":"Missing return type on function.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/_app.js","positions":{"begin":{"line":3,"column":1},"end":{"line":3,"column":1}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.229471 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/explicit-module-boundary-types","description":"Object pattern argument should be typed.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/_app.js","positions":{"begin":{"line":3,"column":16},"end":{"line":3,"column":16}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.234758 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"react/prop-types","description":"'Component' is missing in props validation","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/_app.js","positions":{"begin":{"line":3,"column":18},"end":{"line":3,"column":18}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.240352 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"react/prop-types","description":"'pageProps' is missing in props validation","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/_app.js","positions":{"begin":{"line":3,"column":29},"end":{"line":3,"column":29}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.245808 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/explicit-module-boundary-types","description":"Missing return type on function.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/api/hello.js","positions":{"begin":{"line":3,"column":16},"end":{"line":3,"column":16}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.252195 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/explicit-module-boundary-types","description":"Argument 'req' should be typed.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/api/hello.js","positions":{"begin":{"line":3,"column":17},"end":{"line":3,"column":17}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.257548 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/explicit-module-boundary-types","description":"Argument 'res' should be typed.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/api/hello.js","positions":{"begin":{"line":3,"column":22},"end":{"line":3,"column":22}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.263641 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/no-unsafe-member-access","description":"Unsafe member access .json on an any value.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/api/hello.js","positions":{"begin":{"line":4,"column":3},"end":{"line":4,"column":3}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.268596 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/no-unsafe-call","description":"Unsafe call of an any typed value.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/api/hello.js","positions":{"begin":{"line":4,"column":3},"end":{"line":4,"column":3}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.275227 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/no-unsafe-member-access","description":"Unsafe member access .status on an any value.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/api/hello.js","positions":{"begin":{"line":4,"column":3},"end":{"line":4,"column":3}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.280892 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/no-unsafe-call","description":"Unsafe call of an any typed value.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/api/hello.js","positions":{"begin":{"line":4,"column":3},"end":{"line":4,"column":3}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.287051 #1] DEBUG -- : engine stdout:

{"type":"issue","categories":["Style"],"check_name":"@typescript-eslint/explicit-module-boundary-types","description":"Missing return type on function.","content":{"body":"For more information visit Source: http://eslint.org/docs/rules/\n"},"location":{"path":"pages/index.js","positions":{"begin":{"line":4,"column":16},"end":{"line":4,"column":16}}},"remediation_points":50000}
D, [2021-04-01T22:11:51.326510 #1] DEBUG -- : engine stderr: Ignoring the following rules that rely on module resolution:
D, [2021-04-01T22:11:51.326641 #1] DEBUG -- : engine stderr: 	 * import/extensionsimport/named
D, [2021-04-01T22:11:51.326705 #1] DEBUG -- : engine stderr: 	 * import/namespace
D, [2021-04-01T22:11:51.326777 #1] DEBUG -- : engine stderr: 	 * import/no-absolute-path
D, [2021-04-01T22:11:51.327335 #1] DEBUG -- : engine stderr: 	 * import/no-cycle
D, [2021-04-01T22:11:51.327452 #1] DEBUG -- : engine stderr: 	 * import/no-duplicates
D, [2021-04-01T22:11:51.327520 #1] DEBUG -- : engine stderr: 	 * import/no-extraneous-dependencies
D, [2021-04-01T22:11:51.327613 #1] DEBUG -- : engine stderr: 	 * import/no-named-as-default
D, [2021-04-01T22:11:51.328224 #1] DEBUG -- : engine stderr: 	 * import/no-named-as-default-member
D, [2021-04-01T22:11:51.328369 #1] DEBUG -- : engine stderr: 	 * import/no-restricted-paths
D, [2021-04-01T22:11:51.328499 #1] DEBUG -- : engine stderr: 	 * import/no-unresolved
D, [2021-04-01T22:11:51.328593 #1] DEBUG -- : engine stderr: 	 * node/no-hide-code-modules
D, [2021-04-01T22:11:51.329138 #1] DEBUG -- : engine stderr: 	 * node/no-missing-require
D, [2021-04-01T22:11:51.329265 #1] DEBUG -- : engine stderr: Ignoring the following settings that rely on module resolution:
D, [2021-04-01T22:11:51.329355 #1] DEBUG -- : engine stderr: 	 * undefined
D, [2021-04-01T22:11:51.329447 #1] DEBUG -- : engine stderr: Skipped modules
D, [2021-04-01T22:11:51.330020 #1] DEBUG -- : engine stderr: 	 * undefined
D, [2021-04-01T22:11:51.493391 #1] DEBUG -- : engine stdout:


I, [2021-04-01T22:11:51.495024 #1]  INFO -- : finished engine eslint

Relevant links

I created an example repo starting with defaults provided by Next.js and have been paring down the config files. So far haven't figured out what part of the config is causing this issue: https://github.com/nmkataoka/codeclimate-typescript-test2. You can check the file components/Page.tsx for the same example line with createContext. If anyone has an idea of where to go from here I'd be happy to keep working on this.


  • 4-6 word issue title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants