New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Linter
to reduce API surface
#9161
Labels
archived due to age
This issue has been archived; please open a new issue for any further discussion
chore
This change is not user-facing
Comments
not-an-aardvark
added a commit
that referenced
this issue
Aug 27, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
This updates `RuleTester` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
This updates the tests for `ast-utils` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
This updates the tests for `SourceCode` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
This updates the tests for `Linter` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
This updates `RuleTester` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
This updates the tests for `ast-utils` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
This updates the tests for `SourceCode` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
This updates the tests for `Linter` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
… (#9174) This updates the tests for `SourceCode` to use the public `Linter#defineRule` API rather than the private `Linter#on` API.
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 28, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
not-an-aardvark
added a commit
that referenced
this issue
Aug 30, 2017
The `currentScopes` property is undocumented, and is redundant with the `scopeManager` property. This commit removes it.
not-an-aardvark
added a commit
that referenced
this issue
Sep 8, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 8, 2017
This updates `Linter` to remove the `Linter#getDeclaredVariables` method. The `context.getDeclaredVariables` method is still available to rules -- this just removes the version of the method on `Linter`.
not-an-aardvark
added a commit
that referenced
this issue
Sep 8, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 8, 2017
This updates `Linter` to remove the `Linter#getDeclaredVariables` method. The `context.getDeclaredVariables` method is still available to rules -- this just removes the version of the method on `Linter`.
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
This updates `Linter` to remove the `Linter#getDeclaredVariables` method. The `context.getDeclaredVariables` method is still available to rules -- this just removes the version of the method on `Linter`.
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
#9264) This updates `Linter` to remove the `Linter#getDeclaredVariables` method. The `context.getDeclaredVariables` method is still available to rules -- this just removes the version of the method on `Linter`.
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
This removes the undocumented `traverser`, `scopeManager`, and `currentConfig` properties from `Linter` instances.
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 9, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 10, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 11, 2017
not-an-aardvark
added a commit
that referenced
this issue
Sep 27, 2017
kaicataldo
pushed a commit
that referenced
this issue
Sep 29, 2017
Status of this issue:
|
@not-an-aardvark are you still working on this? |
Not really, I'll close it. |
not-an-aardvark
added a commit
that referenced
this issue
Jan 30, 2019
This removes the undocumented `rules` property from `Linter` instances, as part of the effort to remove undocumented API surface from `Linter` (also see #9161). Config processing now exclusively uses `Linter`'s public API when defining rules. As a side-effect, the rule map utility in `lib/rules.js` no longer needs to access the filesystem, so we can remove the odd code generation logic from the browserify build.
not-an-aardvark
added a commit
that referenced
this issue
Jan 30, 2019
This removes the undocumented `rules` property from `Linter` instances, as part of the effort to remove undocumented API surface from `Linter` (also see #9161). Config processing now exclusively uses `Linter`'s public API when defining rules. As a side-effect, the rule map utility in `lib/rules.js` no longer needs to access the filesystem, so we can remove the odd code generation logic from the browserify build.
eslint-deprecated
bot
added
the
archived due to age
This issue has been archived; please open a new issue for any further discussion
label
Apr 21, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
archived due to age
This issue has been archived; please open a new issue for any further discussion
chore
This change is not user-facing
I think it would be a good idea to refactor
Linter
in the near future. The goal is to reduce the amount of undocumented API surface area, and simplify the interactions between core modules to make them easier to maintain. Node.js API users frequently handleLinter
instances, and having too much API surface area makes it more likely that users will rely on undocumented behavior, and then have their integrations break when we change the implementation details in the future.Specific action items:
Don't make
Linter
a subclass ofEventEmitter
.Linter
happens to use theEventEmitter
API internally, but there's no reason it has to expose the entireEventEmitter
API by being a subclass. We don't want users to useLinter
instances in the same way that they would use genericEventEmitters
(for example, we don't want API users to do something likelinter.emit("foo", node)
orlinter.on("foo", listener)
directly). Instead, one option would be to store an instance ofEventEmitter
as a private property. Another (possibly better) option would be to use a newEventEmitter
for eachverify
call.Don't give
RuleContext
objects access to the underlyingLinter
instance.Currently, rules can call methods on the
Linter
instance by accessingcontext.eslint
. This allows them to interfere with other rules, or report problems as other rules (e.g. withcontext.eslint.report("some-other-rule", ...)
.I think it would be better to have the
RuleContext
constructor accept areport
function as an argument. That way, it wouldn't need a reference toLinter
at all -- it would just be able to emit reports.Make
Linter#verify
be side-effect-free.Instances of
Linter
are mutable, and it's probably too late to change that. However, I think it would be good to preventLinter#verify
from having side-effects. To do this, we would get rid of properties likelinter.messages
,linter.currentConfig
,linter.sourceCode
, etc. and pass the values around internally instead. We would also remove methods likegetAncestors
fromLinter
(and provide an equivalent replacement elsewhere to avoid changing the rule API), sincegetAncestors
necessarily involves some hidden state about the current traversal point, and it doesn't make sense for users of ESLint's Node API to callgetAncestors
directly.The text was updated successfully, but these errors were encountered: