uber / neal Goto Github PK
View Code? Open in Web Editor NEW๐๐ A language-agnostic linting platform
Home Page: https://uber.github.io/NEAL/
License: MIT License
๐๐ A language-agnostic linting platform
Home Page: https://uber.github.io/NEAL/
License: MIT License
Right now, the grammar requires that you have a rule
, and within a rule
you can have multiple provider_matcher
s. A provider matcher is a combination of the provider
to be used and a first matcher
, e.g.
rule "example" {
Swift::ClassDeclaration {
// ...
}
}
However, this doesn't allow matching multiple top-level siblings, e.g. in #9 where a rule is needed to match both a top-level protocol and a top-level class.
I think the most straight forward solution is to make the top level matcher optional, e.g.
rule "example" {
Swift {
var top_level_var := false
ClassDeclaration {
// ...
}
ProtocolDeclaration {
// ...
}
}
}
I tried NEAL today and in short time I had a "working" rule. I wanted to provide some feedback on the issues I hit
.rules
so I tried that, but it didn't work. At first I thought NEAL was crazy fast but it turns out it just wasn't running any rules.>
and >>
which I found info on through the source and commits. There's one example that uses them, and not many tests that use them.var
and condition
which I noticed in a test, and eventually found more info on in #9.match()
to work, and I wasn't able to debug my use of it since I didn't know what the (generated) string it was matching against would look like.property.access
syntax, but it's not documented so I'm not clear what it's used for.SyntaxError}: satisfy
.where
clauses with properties that are lists of nodes, or conversely, how properties mix with matchers..rules
file, only a line and column number are shown. It would be nice to show the line and a ^
label just like how warnings/errors in source files are shown.Are you planning on publishing NEAL to OPAM?
When running make
, this gets run:
make -C docs build
python -msphinx -M build "." "_build"
and fails:
Running Sphinx v1.6.4
Sphinx error:
Builder name build not registered or available through entry point
Catch-all on this line is causing it https://github.com/uber/NEAL/blob/master/docs/Makefile#L20
I'd like to apply a rule only to ConstantDeclarations which are class properties.
I'd hoped I could achieve this by nesting the ConstantDeclaration directly within the ClassDeclaration (as below) but this matches all ConstantDeclarations within the class (as it should!).
rule NoSelfCapturingConstantDeclaration {
Swift::ClassDeclaration {
ConstantDeclaration {
This is a feature request for a child combinator, to allow me to target only direct decedents of a ClassDeclaration. (Perhaps in the style of the CSS child selector https://developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors)
The following code and rule incorrectly result in a NEAL failure.
public class MyObject {
public func myFunc(_ object: Any) -> Bool {
return object as? Dictionary<AnyHashable, Any> != nil
}
}
rule Bang {
Swift::TypeIdentifier where ImplicitlyUnwrappedOptional == true {
fail("No forced unwrapping allowed")
}
}
Since there is no force unwrap the test should not fail.
When parens are added the rule no longer results in a NEAL failure.
public class MyObject {
public func myFunc(_ object: Any) -> Bool {
return (object as? Dictionary<AnyHashable, Any>) != nil
}
}
The lexer should:
\"
)My use case is I want to warn when a Swift ImportDeclaration with a particular identifier is in a file that also contains a class that conforms to a particular protocol. I'm not sure how to declare that this rule should match an ImportDeclaration and ClassDeclaration that are siblings. I've tried a few things and none of them seem to work (syntax errors). Can you clarify if this is currently possible and maybe provide a small example? I could try to submit a PR with some docs if I got that far.
I see Add support for sibling patterns through conditional variables
in the changelog and the closest I can find to something about this is this in a rule. It probably doesn't help that I'm not familiar with OCaml either ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.