Giter VIP home page Giter VIP logo

Comments (13)

vstefanovic97 avatar vstefanovic97 commented on May 27, 2024 2

@patricklx, @NullVoxPopuli seems like the only reason why even direct linting of a gts file works, is because typescript-eslint internally overrides the readFile method of it's CompilerHost to use the code we provide as the first argument to its parseForEslint method, instead of the actual file on disk.

See https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-estree/src/create-program/getWatchProgramsForProjects.ts#L273

But unfortunatelly this means it will only treat that one file like that, and for the rest it will read from disk, which means it will try to import gts files which it doesn't know how to read.

Maybe asking typescript-eslint repo for a feature to provide an option as an argument where we could provide our own readFile implementation will be enough?

Such feature might be beneficial not only to us, but seems like vue has same issue right now
vuejs/vue-eslint-parser#104

from eslint-plugin-ember.

bmish avatar bmish commented on May 27, 2024

@patricklx @NullVoxPopuli

from eslint-plugin-ember.

patricklx avatar patricklx commented on May 27, 2024

@NullVoxPopuli i remember you tried something with glint ts program? Maybe that would work for this?

from eslint-plugin-ember.

NullVoxPopuli avatar NullVoxPopuli commented on May 27, 2024

well, to use type-are lints, you may not use @typescript-eslint/parser on gts files, you must use the parser provided by eslint-plugin-ember

@patricklx for the glint ts program thing, I don't recall if that was for linting or not

from eslint-plugin-ember.

vstefanovic97 avatar vstefanovic97 commented on May 27, 2024

@NullVoxPopuli in my reproduction, I am using gjs-gts-parser for the gts files, see here.

But still there is the issue, unless I am missing something

from eslint-plugin-ember.

patricklx avatar patricklx commented on May 27, 2024

The issue is when gts is imported, not linted directly. But for typed linting the parser also needs to load the imported files. Internally that is done by typescript-eslint parser

? typescriptParser.parseForESLint(jsCode, { ...options, ranges: true })

from eslint-plugin-ember.

patricklx avatar patricklx commented on May 27, 2024

Maybe we need a small ts plugin for this? Like for vue
https://github.com/sandersn/vue-ts-plugin/blob/master/lib/index.ts

from eslint-plugin-ember.

vstefanovic97 avatar vstefanovic97 commented on May 27, 2024

@patricklx, @NullVoxPopuli seems like the only reason why even direct linting of a gts file works, is because typescript-eslint internally overrides the readFile method of it's CompilerHost to use the code we provide as the first argument to its parseForEslint method, instead of the actual file on disk.

See https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-estree/src/create-program/getWatchProgramsForProjects.ts#L273

But unfortunatelly this means it will only treat that one file like that, and for the rest it will read from disk, which means it will try to import gts files which it doesn't know how to read.

Maybe asking typescript-eslint repo for a feature to provide an option as an argument where we could provide our own readFile implementation will be enough?

from eslint-plugin-ember.

NullVoxPopuli avatar NullVoxPopuli commented on May 27, 2024

If we could tell it to use glint instead of tsc of 'the program', i think that could help, as it also has its own read file ...

If it weren't for this

internally overrides the readFile method of it's CompilerHost

🙈

from eslint-plugin-ember.

vstefanovic97 avatar vstefanovic97 commented on May 27, 2024

If we could tell it to use glint instead of tsc of 'the program', i think that could help, as it also has its own read file ...

If it weren't for this

internally overrides the readFile method of it's CompilerHost

🙈

@NullVoxPopuli well if we pass it glints TS program, then it won't override anything it just uses the program as it's given

from eslint-plugin-ember.

vstefanovic97 avatar vstefanovic97 commented on May 27, 2024

Glint just maybe seems a bit overkill for this, if we could just override readFile that typescript-eslint is using by asking them to provide a new option for it, we can the just use transformForEslint method as the override, it would solve the problem I think and not have us depend on glint.

But it is just a theory, I can test it out tomorrow and if it works I can raise a feature request to typescript-eslint. Wdyt?
But in case they won't be willing to let us override it we probably will need to use glint or something

from eslint-plugin-ember.

patricklx avatar patricklx commented on May 27, 2024

Maybe we can use this?
https://github.com/typescript-eslint/typescript-eslint/blob/fadc7940b456f1903a282a4b5085daf1b8367b16/packages/parser/src/index.ts#L7
Patch it and pass it as program parser option? but it would be better to transform directly with content tag,

from eslint-plugin-ember.

vstefanovic97 avatar vstefanovic97 commented on May 27, 2024

Glint just maybe seems a bit overkill for this, if we could just override readFile that typescript-eslint is using by asking them to provide a new option for it, we can the just use transformForEslint method as the override, it would solve the problem I think and not have us depend on glint.

But it is just a theory, I can test it out tomorrow and if it works I can raise a feature request to typescript-eslint. Wdyt? But in case they won't be willing to let us override it we probably will need to use glint or something

I tried a few things, but for now I just can't seem to get it to work :(, I'll keep trying next couple of days, but maybe someone else will have more luck with this

from eslint-plugin-ember.

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.