GithubHelp home page GithubHelp logo

Consume Linter-Plus about nuclide HOT 7 CLOSED

facebookarchive avatar facebookarchive commented on May 27, 2024
Consume Linter-Plus

from nuclide.

Comments (7)

bolinfest avatar bolinfest commented on May 27, 2024

One objection I have to the linter-plus API is that it requires providers to use linter-plus's object model, which is awkward. Looking at https://github.com/steelbrain/Atom-Hack/blob/rewrite/lib/atom-hack.coffee, I'm not comfortable with how Trace or Error is injected. This makes it very hard to write an apm test for your provider.

By comparison, autocomplete-plus does not use inheritance or class-based types. It requires providers to return objects with properties of specific types. I think that is much cleaner.

from nuclide.

steelbrain avatar steelbrain commented on May 27, 2024

I fail to think of a reason to choose {type:"Error", file:Message.File, position: Message.Position, message: Message.desc} over new Error(Message.desc, Message.File, Message.Position).
that Error class however at some points make the codebase of linter-plus simpler.

from nuclide.

bolinfest avatar bolinfest commented on May 27, 2024

I should be able to write a unit test for my linter provider that does not depend on the consumer. If I were to do that today, I would have to mock out constructors for Error and Trace, which makes the test more tedious to write.

This is a real issue. Note that today we have to disable our tests for our FlowLinter because we have observed that tests that have to call activatePackage('linter') in beforeEach() are flaky:

https://github.com/facebook/nuclide/blob/9ed0ce4571baa7ba987118903f7ba3d46692191a/pkg/nuclide/flow/spec/FlowLinter-spec.js#L13-L14

This is because linter requires you to get a superclass from the Atom package itself:

https://github.com/facebook/nuclide/blob/9ed0ce4571baa7ba987118903f7ba3d46692191a/pkg/nuclide/flow/lib/FlowLinter.js#L13

The build flakiness is not worth it.

Also, passing in constructor functions is not the cleanest thing to do, IMHO. You could just as easily pass in some sort of factory with methods like createError(), etc., that would be cleaner. At least those would be easier to mock.

Further, your current contracts are not future-proof. That is, what happens when you want to start adding more parameters, more of which are optional? Your param list will become a mess. It would be easiest to represent each type as an object literal (at least from the provider's perspective) so that the consumer can recognize more properties over time, but older providers will still work.

In sum, let providers return object literals, and internally, you can convert them to Error, Trace, etc. Things will be more loosely coupled that way.

from nuclide.

steelbrain avatar steelbrain commented on May 27, 2024

Thank you for providing a valid reason. I agree that Error and Trace constructors are not future proof, It would introduce complications when we add new parameters to constructors.

On a side note, createError isn't really the cleanest way to do this, so I am gonna make linter-plus accept Error like Objects very soon after the PR mentioned above has been accepted.

from nuclide.

steelbrain avatar steelbrain commented on May 27, 2024

@bolinfest That new API has landed in the master branch. You can check out the new API in README. It's right according to what you suggested.

from nuclide.

steelbrain avatar steelbrain commented on May 27, 2024

@bolinfest The original linter has been depreciated and will be removed soon, all packages are advised to switch to plus API.

from nuclide.

bolinfest avatar bolinfest commented on May 27, 2024

Fixed in 1fc2358.

Though please take note of https://github.com/AtomLinter/linter-plus/issues/87.

from nuclide.

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.