Incorrect behaviour with operations in .js/.ts files
See original GitHub issueDescribe the bug
The @graphql-eslint/unique-fragment-name
, @graphql-eslint/unique-operation-name
, and @graphql-eslint/known-fragment-names
rules seem to incorrectly report errors when operations are defined in .js/.ts files.
To Reproduce Steps to reproduce the behavior:
https://github.com/mikew/graphql-eslint-woes
Expected behavior There should be no issues in the repo above.
Environment:
- OS: macOS
@graphql-eslint/...
: latest- NodeJS: 14
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Documentation - Type Checking JavaScript Files - TypeScript
In a .js file, the compiler infers properties from property assignments inside the class body. The type of a property is the type...
Read more >Configuration For Treating JS/TS Files as Independent Units ...
Actual behavior: The files are treated as a single unit. foo either has a string or number type in both files.
Read more >The 10 Most Common JavaScript Issues Developers Face
JavaScript Issue #1: Incorrect References to this. There's no shortage of confusion among JavaScript developers regarding JavaScript's this keyword.
Read more >JavaScript .JS file is not included or nested under my ...
I am running Visual Studio 2017, and I have a fine Typescript .TS file. I have made the following very advanced Typescript code:...
Read more >PhpStorm - Code Inspections in JavaScript and TypeScript
Inaccurate platform detection. Reports a common JavaScript pattern for detecting the browser or operating system in which the script is run.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The false positive issue with
known-fragment-names
- currently it’s not possible to handle string interpolation because graphql-tag-pluck doesn’t support it (we usegraphql-tag-pluck
under the hood for extract documents fromjs/ts
files)And the issue with
unique-fragment-name
andunique-operation-name
I’ll fix this weekWe have 3 different kinds of files loaded in this plugin:
.graphql
file - loaded with ESLint core using the plugin, and then we parse it with GraphQL and convert it to ESTree.The snippet @B2o5T mentioned is the one that compares file paths while loading siblings. When it’s loaded against while linting a virtual file, we probably compare it in the wrong way (maybe we should use the original file path, not the virtual?).