Comments (12)
- Here it is:
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.
// @flow import { Api } from 'services/api' // <- this one
- Indeed, commenting them out one-by-one shows that only
define-flow-type
breaksno-unused-vars
,use-flow-type
is ok.
from eslint-plugin-ft-flow.
^ Merged a fix. Please give a go with v3.0.3 and let me know if it works 🙏
from eslint-plugin-ft-flow.
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.
@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.
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.
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.
:/ 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
- Could you share the line or token that fails to be parsed causing this error?
- Is it when both rules are in use or only one?
- What happens if you only one of
define-flow-type
oruse-flow-type
?
from eslint-plugin-ft-flow.
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.
FWIW 3.0.4-alpha-0
resolves the issue for me.
from eslint-plugin-ft-flow.
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.
Works for me now. Awesome job, Brian! Thank you!
from eslint-plugin-ft-flow.
Thanks, @Brianzchen! Really appreciate it. 🙂
from eslint-plugin-ft-flow.
Related Issues (20)
- Suggested improvements to `no-flow-fix-me-in-strict-files` rule HOT 7
- Improve test runner HOT 1
- Consider renaming `no-flow-fix-me-in-strict-files` to something like `no-flow-suppressions-in-strict-files` HOT 1
- improve readme generator
- Function type parameters spacing issues HOT 2
- Recommended configuration not working with enums HOT 7
- Enums support consistent trailing comma
- Enums support unused value
- Switch to use `hermes-eslint` as the recommended parser HOT 14
- Q HOT 1
- Allow mixed type-import-style HOT 1
- Add meta.schema to rules
- Fix mapped types throwing eslint errors
- should depend on hermes-eslint with >=
- No sourceCode in context HOT 2
- Some rules don't work if @flow annotation is in a multiline comment HOT 2
- Support eslint 9 HOT 1
- Typo in peer dependency version causes npm error since 3.0.10 HOT 1
- context.getAllComments is not a function Error After upgrade esLint v9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-ft-flow.