Giter VIP home page Giter VIP logo

linters's Introduction

linters

Linters for https://github.com/rxi/lite

Available linters

  • linter_ameba - Uses ameba for crystal files
  • linter_dscanner - Uses dscanner for d files
  • linter_eslint - Uses eslint for javascript files
  • linter_flake8 - Uses flake8 for python files
  • linter_gocompiler - Uses the go vet command to display compilation errors in golang files
  • linter_golint - Uses golint for golang files
  • linter_jshint - Uses jshint linter for javascript files
  • linter_luacheck - Uses luacheck for lua files
  • linter_teal - Uses tl check for teal files
  • linter_nim - Uses nim check for nim files
  • linter_php - Uses built-in php binary -l flag for php files
  • linter_pylint - Uses pylint for python files
  • linter_revive - Uses revive for golang files (golint modern alt)
  • linter_selene - Uses selene for lua files
  • linter_shellcheck - Uses shellcheck linter for shell script files
  • linter_standard - Uses standard linter for javascript files
  • linter_zig - Uses zig ast-check for linting zig files

Demo

Example of linting a file.

Linter demo

Instructions

  1. To install any linter first copy the linter.lua file to the folder data/plugins/ of the lite editor which has the needed foundation for the linters.
  2. Copy the specific linters you want to use to the same folder.
  3. Make sure you have the commands needed for each linter to use them.
  4. If you want to configure options in some of the linters you can edit your data/user/init.lua
local config = require "core.config"
local insert = table.insert

-- [[ Each linter will load the arguments from a table in config.<linter_name>_args ]]

-- Mark global as known to the linter
insert(config.luacheck_args, "--new-globals=love")

-- Add error reporting in fuctions which exceed cyclomatic complexity
insert(config.luacheck_args, "--max-cyclomatic-complexity=4")

-- Add warnings if lines pass a maximum length
insert(config.luacheck_args, "--max-line-length=80")

Linter Fields

file_patterns {String} - List of patterns to match the files to which the linter is run.

warning_pattern String | Function - Matches the line, column and the description for each warning(In this order). If the matching is complex and cannot be addressed with a pattern directly a function can be used.

warning_pattern_order {line=Int, col=Int, message=Int} [optional] - Allows us to change what is expected from the pattern when the order of the elements in the warning is not line -> col -> message.

column_starts_at_zero Bool [optional] - Is useful for some linters which have the column number starting at zero instead of starting at one.

command String - Command that is run to execute the linter. It can receive a $FILENAME name in the middle of the command which will be replaced with the name of the file which is being edited when the linter is run.

deduplicate Bool [optional] - Prevent duplicated warnings. Only needed in specific cases because some linters work with whole packages instead of a specific file and report the same warning for the same file multiple times.

args {String} - Arguments to be passed to the linter in the command line call. Will replace the $ARGS in the command. Usually this table comes from config.<linter>_args. This is done so the user can add it's own specific configurations to the linter in his own user file.

expected_exitcodes {Int} - Exit codes expected when the linter doesn't crash so we can report when there is an unexpected crash.

Configurations

The base linter code also allows some configurations that apply to all linters. You can set them in you user file - data/user/init.lua.

The available configurations are:

  • linter_box_line_limit - Number of columns in the warning box. (default: 80)
  • linter_scan_interval - Seconds between checks for results in the linter file. (default: 0.1)
  • warning_font - Font to be used inside the warning box. (default: style.font)
  • linter_trigger - Select how the linter is activated. (default: "save", options: ["save", "keypress"])

Example configuration:

config.warning_font = renderer.font.load(EXEDIR .. "/data/fonts/monospace.ttf", 13.5 * SCALE)
config.linter_trigger = "keypress"

linters's People

Contributors

catgirlinspace avatar doczi-dominik avatar drmargarido avatar gohryt avatar jgmdev avatar konsumer avatar mierenhoop avatar mundusnine avatar pkars avatar rxi avatar takase1121 avatar theking0x9 avatar varlad avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

linters's Issues

standard

I am trying to make a standardjs plugin, for a PR.

I looked at the sublime plugin for this, and translated the regex into this, in JS:

^ (.+):(\d+):(\d+): (.+)

which I guess is this in lua, but it doesn't seem to pick up warnings:

local config = require "core.config"
local linter = require "plugins.linter"

config.standard_args = {}

linter.add_language {
  file_patterns = {"%.js$"},
  warning_pattern = "^  (.+):(%d+):(%d+): (.+)",
  command = "standard --verbose $ARGS $FILENAME",
  args = config.standard_args
}

Is my regex wrong?

Interface questions

A couple of UI questions:
This issue will be about eslint, but it may concern other linters too.

  1. How can I enable 'autofix on save'? That stuff is usually super handy to fix indentation
  2. How can I do manual fix? I tried to find a command for that using ctrl+shift-p, but the fix command was missing
  3. How can I list all the linter errors for the file? I see 'warnings: 4' message, but when I click on it, I see nothing.

Thanks!

on_mouse_moved override not propagating all arguments

local on_mouse_moved = DocView.on_mouse_moved
function DocView:on_mouse_moved(px, py)
  on_mouse_moved(self, px, py)

in lint.lua isn't propagating the delta arguments after the absolute positions. Specifically this breaks the scrollbar, and should thus be:

local on_mouse_moved = DocView.on_mouse_moved
function DocView:on_mouse_moved(px, py, ...)
  on_mouse_moved(self, px, py, ...)

Command not found doesn't show up in vanilla editor

When we have the linter plugin installed without the console plugin we don't get feedback that the command of the plugin failed unless we look at the terminal spawned by lite on boot.

I don't know if it would be possible to show a small error message at the bottom of the window, similar to how lite shows that the file was saved:

image

Issue with ctrl latching while saving

Whenever I save a file, the linter runs and after the console window closes, the CTRL key is held down. I would need to press CTRL again to "unlatch" it.

Command failure reporting is broken

After the last changes to make the linter not blocking, the results of the commands are now sent to temporary files. The implementation that was done is discarding the errors which is a problem to help users identify when the linters are not working.

eslint do not work

I have:

  • cloned linter repo to /data/plugins.
  • copied eslinter to the same folder
  • restarted lite
  • added some stuff that should raise warnings and errors to the .js file
  • saved file
  • got 'linter found no warnings' message

Instructions Unclear

I can't figure out how to lint a file.

The only option when hitting ctrl + shift + p is "Linter: Move To Next Warning"

Instructions say: "Make sure you have the commands needed for each linter to use them."

If I have both linter.lua and linter_standard.lua in the plugins directory, and I have a javascript file open how do I run the linter?

Project wide linting creates linter lines at unexpected places

Describe the problem
When using linters with a linter that does project-wide linting, linted lines turn up in files other than which contain the error/warning.

Steps to reproduce

  • Install linters
  • modify a specific linter to lint . instead of $FILENAME
  • See the error that warning pops up in places where it should not have

Additional Information

  • Tested on Windows
  • With a custom linter designed to work with Cppcheck

Screenshots
stack.c is the file where the error should have originally come, but it also shows up in parser.c. Same for other errors that you can see with yellow/green lines.

Screenshot (89)
Screenshot (88)

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.