GithubHelp home page GithubHelp logo

Comments (13)

rwjblue avatar rwjblue commented on May 22, 2024

I agree that this would be nice, but it is not obvious where a given error ends. For example, for an indentation error is the error with all text on that line or just the first char?

from ember-template-lint.

joukevandermaas avatar joukevandermaas commented on May 22, 2024

@rwjblue I know that e.g. jshint reports these as the whole line being wrong. Ultimately the decision for those cases is just bikeshedding. In other cases this would add a lot of value.

from ember-template-lint.

rwjblue avatar rwjblue commented on May 22, 2024

ya, I definitely want to end up using this for editor highlighting. I'll dig into how eslint does this a bit...

from ember-template-lint.

rwjblue avatar rwjblue commented on May 22, 2024

I believe that @binhums and @mmun were also thinking about adding range support. I'd definitely love their feedback....

from ember-template-lint.

 avatar commented on May 22, 2024

@MattEddy and I are working on an atom linter. We definitely agree with the motivation, e.g. in our first stab we had a go inferring ranges - it didn't go so well 😛

image

It would appear that ESLint does not provide ranges. There is code in the ESLint atom package about ranges but I believe this is actually about auto-fixing rule violations.

But the Atom plugin looks fine highlighting the entire line:

image

The question for me is, for what rules would highlighting a range be more useful than highlighting an entire line. E.g. an invalid attribute or an inappropriate MustacheStatement rather than a missing attribute.

@MattEddy anything I missed here?

from ember-template-lint.

 avatar commented on May 22, 2024

My concern is that this may be difficult for rule writers to provide. A rule writer is chiefly concerned with AST rather than the source code itself. The AST provides the start and end locations of the node.

I'd be interested in seeing a rule converted to return a meaning range. For example getting the block-indentation rule to return the range of the end block.

If we did provide ranges would we want to allow falling back to a [line, column] location if implementation a range is difficult for a given rule?

from ember-template-lint.

joukevandermaas avatar joukevandermaas commented on May 22, 2024

@binhums I understand and agree. I think it's better to have an approximate range for most rules than no range at all. In my opinion those rules can just report the whole line. It's always possible to improve later.

from ember-template-lint.

rwjblue avatar rwjblue commented on May 22, 2024

Having some rules with range and others without seems pretty annoying to me 😝 . I'd prefer to expose a single "results objects API" (which I have currently mostly stolen from ESLint). If we definitely want to support range values and a given rule cannot determine the "real" range then it should just use the full line as the range.

from ember-template-lint.

rwjblue avatar rwjblue commented on May 22, 2024

Also, I don't see folks having issues with editor integration with ESLint, and they do not provide range information. Am I just not paying attention to the right GitHub repos to see those issues, or is it a non-issue for them?

from ember-template-lint.

 avatar commented on May 22, 2024

It sounds like we're in agreement here, any comments @mmun, @MattEddy?

from ember-template-lint.

captain-enjoyable avatar captain-enjoyable commented on May 22, 2024

Nope. I'm not sure how the atom ESlint package manages to determine ranges, but having them on the result object seems ideal.

from ember-template-lint.

 avatar commented on May 22, 2024

I spoke with @mmun about this - he told me about the one true god that is Rust. There are linters that provide ranges which are very useful e.g.

<anon>:6:5: 6:12 error: re-assignment of immutable variable `foo` [E0384]
<anon>:6     foo = 3;
             ^~~~~~~
<anon>:6:5: 6:12 help: see the detailed explanation for E0384
<anon>:2:9: 2:12 note: prior assignment occurs here
<anon>:2     let foo = 1;
                 ^~~
error: aborting due to previous error
playpen: application terminated with error code 101

If I were designing this in a vacuum (e.g. without the precedent of ESLint) I'd have a range in the API.

To summarise from the point of view of the people involved:

  • Template authors benefit from having precise instructions over just highlighted lines
  • Rule authors suffer from having to write logic to determine ranges
  • ember-template-lint maintainers suffer from having to maintain an expanded API
  • Integrations (e.g. ember-cli / atom) benefit from having complete metadata available and potentially suffer from writing fallback logic for a single line-column location

I've ordered those groups by how important I think they are. I feel like similar arguments apply for other metadata in the rule API such as source and fix.

from ember-template-lint.

 avatar commented on May 22, 2024

After looking out for this more, I saw something that looks like a range in ESLint:

image

It's straight up inferred from the position of the error and fills to the end of the line...

from ember-template-lint.

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.