Coder Social home page Coder Social logo

Comments (12)

e1cb4ac37s avatar e1cb4ac37s commented on July 20, 2024 2
  1. Here it is:
    // @flow
    
    import { Api } from 'services/api' // <- this one
    this looks like it breaks on a first line of the first flow-tagged file, as deleting this line moves an error to the next non-empty one, deleting the file moves error to the next file, first non-empty line.
  2. Indeed, commenting them out one-by-one shows that only define-flow-type breaks no-unused-vars, use-flow-type is ok.

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 20, 2024 1

^ Merged a fix. Please give a go with v3.0.3 and let me know if it works 🙏

from eslint-plugin-ft-flow.

e1cb4ac37s avatar e1cb4ac37s commented on July 20, 2024 1

Thank you for a very fast response and fix! ft-flow now does not throw, although eslint's no-unused-vars broke (which was not the case before). But it seems I have to go with this issue to eslint repo now - ft-flow's part works now. Thank you again.

Oops! Something went wrong! :(

ESLint: 8.56.0

TypeError: Cannot read properties of null (reading 'scope')
Occurred while linting PATH/client/src/core/api/some-js-file.js
Rule: "no-unused-vars"
    at getRhsNode (PATH/client/node_modules/eslint/lib/rules/no-unused-vars.js:356:43)
    at PATH/client/node_modules/eslint/lib/rules/no-unused-vars.js:541:27
    at Array.some (<anonymous>)
    at isUsedVariable (PATH/client/node_modules/eslint/lib/rules/no-unused-vars.js:534:40)
    at collectUnusedVariables (PATH/client/node_modules/eslint/lib/rules/no-unused-vars.js:658:26)
    at Program:exit (PATH/client/node_modules/eslint/lib/rules/no-unused-vars.js:677:36)
    at ruleErrorHandler (PATH/client/node_modules/eslint/lib/linter/linter.js:1076:28)
    at PATH/client/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (PATH/client/node_modules/eslint/lib/linter/safe-emitter.js:45:38)

Edit: in fact, I ran eslint without any recommendations (except ft-flow's one with 3 rules:

module.exports = {
  parser: 'hermes-eslint',
  parserOptions: {
    ecmaVersion: 9,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true,
    },
    babelOptions: {
      configFile: path.resolve(__dirname, './babel.config.js'),
    },
  },
  extends: ['plugin:ft-flow/recommended'],
  plugins: [
    'ft-flow',
  ],
  env: {
    browser: true,
    jquery: true,
    node: true,
    jest: true,
    es6: true,
  },
  root: true,
  globals: {
    globalThis: 'readonly',
  },
  rules: {
    'ft-flow/define-flow-type': 1, // (1)
    'ft-flow/use-flow-type': 1, // (2)
    'no-unused-vars': ['error', { argsIgnorePattern: '^_', ignoreRestSiblings: true }],
  },
  settings: {
    'import/resolver': {
      node: {
        paths: ['.'],
        extensions: ['.js', '.ts', '.jsx', '.tsx'],
      },
      'babel-module': {
        cwd: 'babelrc',
        root: ['./src/'],
        alias: babelAliases,
      },
    },
    'import/external-module-folders': [path.resolve(__dirname, './node_modules/')],
    'import/internal-regex': '^@+foxford',
    react: {
      version: '17',
    },
    flowtype: {
      onlyFilesWithFlowAnnotation: true,
    },
  },
  ignorePatterns: ['.eslintrc.js', '/docs', '/build', '/flow-typed', '**/node_modules/**', '*/*.sass'],
}

commenting out lines (1) and (2) makes `no-unused-vars' work, while keeping them leads to an error above

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 20, 2024 1

@e1cb4ac37s can you try 3.0.4-alpha-0. I removed something that seemed unnecessary and was causing issues. It's throwing the unused errors correctly but need to spend more time getting the tests to play nicely together before I can merge and make an official release

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 20, 2024

Thanks for raising this issue. At first glance it seems to be because __defineGeneric object does not exist in the hermes-eslint parser so I expect it should work with @babel/eslint-parser and as a result it's throwing.

But because with flow you should use hermes-eslint to parse the syntax correctly we'll have to find a solution for you. I'll keep digging to find what the equivalent with hermes would be.

Do note that flow team recommended that this rule isn't necessary anymore hence why we didn't test for this case

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 20, 2024

Have raised an issue with hermes team. Lets see if they come back with anything useful before I cont my investigation. Otherwise I'll need to understand what that function did in the beginning to find a suitable replacement function

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 20, 2024

:/ hmm I'll need to reproduce it in tests to find a solution. The change I made was to define-flow-type only and I suspect that when I inject the global variable it's missing something causing the next rule to fail.

    'ft-flow/define-flow-type': 1, // (1)
    'ft-flow/use-flow-type': 1, // (2)

For some more info

  1. Could you share the line or token that fails to be parsed causing this error?
  2. Is it when both rules are in use or only one?
  3. What happens if you only one of define-flow-type or use-flow-type?

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 20, 2024

Great I was able to reproduce this, turns out we never had a test against no-unused-vars and only tested no-undef and no-use-before-define.

from eslint-plugin-ft-flow.

short-dsb avatar short-dsb commented on July 20, 2024

FWIW 3.0.4-alpha-0 resolves the issue for me.

from eslint-plugin-ft-flow.

Brianzchen avatar Brianzchen commented on July 20, 2024

Thanks for validating @short-dsb. I'll work on getting my tests working and publish an official release this weekend... Unless someone finds more problems 😨

from eslint-plugin-ft-flow.

e1cb4ac37s avatar e1cb4ac37s commented on July 20, 2024

Works for me now. Awesome job, Brian! Thank you!

from eslint-plugin-ft-flow.

short-dsb avatar short-dsb commented on July 20, 2024

Thanks, @Brianzchen! Really appreciate it. 🙂

from eslint-plugin-ft-flow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.