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

Results of weekly scheduled smoke test #3178

Closed
github-actions bot opened this issue Jan 16, 2022 · 2 comments
Closed

Results of weekly scheduled smoke test #3178

github-actions bot opened this issue Jan 16, 2022 · 2 comments

Comments

@github-actions
Copy link

Detected 1 ESLint reports and/or crashes.
Scanned 2818 repositories.

Rules:

  • react/hook-use-state
Click to expand

Rule: react/hook-use-state

  • Message: Cannot read property 'defs' of null Occurred while linting /github/workspace/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/maxim-andrews/setup-app-suite/packages/setup-app-templates/templates/react/src/Components/ServerFetch/index.js:143 Rule: "react/hook-use-state"
  • Path: maxim-andrews/setup-app-suite/packages/setup-app-templates/templates/react/src/Components/ServerFetch/index.js
  • Link
  141 | } else {
  142 |   function ServerFetch () {
> 143 |     const [ state, dispatch ] = useReducer(reducer, initStore());
  144 |
  145 |     function fetchServerData () {
  146 |       if (state.fetching) {
TypeError: Cannot read property 'defs' of null
Occurred while linting /github/workspace/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/maxim-andrews/setup-app-suite/packages/setup-app-templates/templates/react/src/Components/ServerFetch/index.js:143
Rule: "react/hook-use-state"
    at Object.isReactHookCall (/github/workspace/lib/util/Components.js:845:90)
    at Object.CallExpression (/github/workspace/lib/rules/hook-use-state.js:39:38)
    at updatedRuleInstructions.<computed> (/github/workspace/lib/util/Components.js:1039:45)
    at ruleErrorHandler (/github/workspace/node_modules/eslint/lib/linter/linter.js:1079:28)
    at /github/workspace/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/github/workspace/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/github/workspace/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/github/workspace/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/github/workspace/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
@ljharb
Copy link
Member

ljharb commented Jan 17, 2022

Hmm, that particular file isn't valid JS at all, because import statements must only ever appear at the top level. @AriPerkkio this doesn't seem like a reasonable file to lint to me. thoughts?

@AriPerkkio
Copy link
Contributor

That's right - this file should not be passed to rules by ESLint. It should crash at parsing step before ESLint passes the sources to rules. eslint-remote-tester simply ignores errors thrown by parsers and skips the file. This is typically what happens when randomly picked target repository contains unexpected syntax, e.g. flow-typed files and we don't have flow-parser set up. This is accepted from smoke tests since we are testing rules, not the parser.

When testing this file at ASTExplorer it seems that @typescript-eslint/parser does not crash - likely related to typescript-eslint/typescript-eslint#1852. espree is throwing 'import' and 'export' may only appear at the top level and not outputting AST.

We should exclude the maxim-andrews/setup-app-suite project from eslint-remote-tester-repositories. But I think more appropriate solution would be to use espree on .js files.

https://github.com/yannickcr/eslint-plugin-react/blob/151bb2b13892969bea17b334e882eb422152c30a/test/eslint-remote-tester.config.js#L19-L24

  eslintrc: {
    ...
-    parser: '@typescript-eslint/parser',
+    overrides: [
+        {
+            files: ['*.ts', '*.tsx'],
+            parser: '@typescript-eslint/parser',
+        }, 
+    ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants