GithubHelp home page GithubHelp logo

check.fnl's Introduction

check.fnl

A linter for Fennel

tests

Dependencies

  • Fennel interpreter
  • Fennel Lua module (fennel.lua)
  • Lua interpreter:
    • Compiling check.fnl is only tested with Fennel on PUC Lua 5.4.
    • Running the built Lua file is possible with either luajit or PUC Lua, but:
    • Luajit (and Lua without the utf8 module) counts line lengths by bytes instead of unicode codepoints.

It is recommended that you install Fennel using your package manager, this should take care of all dependencies. If you don't have Fennel properly installed, you might need to download the Fennel Lua module and place it in the same directory as check.fnl.

Usage

Clone this repository and run

make
./check.fnl file1.fnl file2.fnl …

A configuration file can be specified with the -c option. This allows you to change the enabled checks, as well as their behaviour.

./check.fnl -c config.fnl file1.fnl file2.fnl …

Use the -s option to show a list of all checks.

Features

The analysed code is not executed, only parsed by the Fennel parser.

Currently check.fnl finds:

  • deprecated forms
  • bad style
    • wrong characters in names
    • lines that exceed 80 columns
    • wrong number of semicolons in comments
    • closing delimiters on their own line
    • missing docstrings
  • useless forms
  • if replacable with when
  • uses of not that can be replaced
  • lists that don't begin with an identifier
  • uses of local that can be replaced with let
  • syntax errors
    • let
    • when
    • if
  • redefined and shadowed symbols

Not all checks are enabled by default, and some are likely to produce false positives.

Directives

A line with a comment containing no-check will suppress all errors for that line:

(+ 1) ; no-check

References

check.fnl's People

Contributors

dokutan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mathisto

check.fnl's Issues

misleading suggestion for if->when

Thanks for making this tool; it looks neat!

Most of the suggestions are quite helpful. However, I noticed it will flag code like this:

(collect [k v (pairs (or ?source [])) :into ["..."]]
  (if (= (type k) :string) (values k v)))
;; 208: this if can be replaced with when

While this is technically true (the code will still work if you replace if with when), it's better to leave it as an if since when is specifically meant for cases where side-effects are involved: https://fennel-lang.org/reference#when-single-side-effecting-conditional

If it were wrong to make an if call with a single branch, it would be a compiler error in Fennel, like it is in Racket. There's no reason to catch this in linting, because the compiler allows it for a good reason. =)

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.