Code Monkey home page Code Monkey logo

sublimelinter-flow's Introduction

SublimeLinter

tests

The code linting framework for Sublime Text. No linters included: get them via Package Control.

Installation

Note

The current stable version of Sublime Text, Build 4169, has a bug and cannot install SublimeLinter without requiring a restart. You're fine if you have a later dev build, e.g. build 4173.

Note

We're in a transition phase to the newer ST4 plugin host. Unless we have more experience for the process, it may be necessary to restart Sublime Text after installing or upgrading helper packages. Just check if everything works or if the console shows permanent errors. On my machine, no restarts were necessary.

Probably don't get fancy and just install SublimeLinter via Package Control. Refer https://www.sublimelinter.com/en/latest/installation.html for further information, but, spoiler!, usually you install SublimeLinter, the plugin you're currently looking at, some command line tools, these are the actual linters (e.g. eslint or flake8), and then some plugins/adapters between both. These are typically named after the linter and should be installed via Package Control as well, examples would be SublimeLinter-eslint or SublimeLinter-flake8.

By default, SublimeLinter will run in the background and most linters support this mode so you should get squiggles immediately.

Note that you find all commands we're installing using the Command Palette (ctrl+shift+p). Just search for SublimeLinter. You may find https://github.com/kaste/SublimeLinter-addon-toggler and/or https://github.com/kaste/SublimeLinter-addon-goto-flash useful.

Settings

Settings are documented in the default settings. Open the settings using the Command Palette (ctrl+shift+p) searching for Preferences: SublimeLinter Settings (mnemonic: sls).

When you open the SublimeLinter settings you'll see the defaults on the left or top. Usually that's all that is needed for end-users but some additional information is in our docs at sublimelinter.com.

Key Bindings

SublimeLinter comes with some pre-defined keyboard shortcuts. You can customize these via the Package Settings menu.

Command Linux & Windows MacOS
Lint this view Ctrl + k, l Ctrl + + l
Open diagnostics panel Ctrl + k, a Ctrl + + a
Goto next error Ctrl + k, n Ctrl + + e
Goto prev error Ctrl + k, p Ctrl + + Shift + e

Take also a look at the default bindings because we document other commands and have usually some tricks in there too.

For example, it is very advisable to bind sublime_linter_quick_actions, e.g.

    // To trigger a quick action
    // { "keys": ["ctrl+k", "ctrl+f"],
    //   "command": "sublime_linter_quick_actions"
    // },

Quick Actions/Fixers

As we do just linting SublimeLinter naturally does not come with fixers and/or code formatters. However, we have a fixer API, see the Command Palette: SublimeLinter: Quick Action, and ship (mostly) "fix by ignoring" actions. These allow you to quickly ignore specific error messages inline and ad hoc.[1]

SublimeLinter currently ships actions for eslint, stylelint, flake8, mypy, shellcheck, codespell and phpcs.

Want to see actions for your favourite linter? Please open a PR with your addition to quick_fix.py. We have tests for them!

[1] Why this limitation though? Well it is usually easy to add a semicolon here and a space there, but the inline ignore rules and syntaxes are very cumbersome to type and to remember. And there is basically no project of any size where you don't have to ignore ad-hoc something somewhere once.

Support & Bugs

Yeah, totally! Often if it doesn't work, Sublime will have something in the console (View -> Show Console). Warnings will go there by default.

You can enable debug mode in the settings to get much more information about what's going on. Especially seeing the exact command and working dir SublimeLinter will use should be noted and helpful.

As some code only runs on startup, it is good practice to restart Sublime Text and to examine the console output for anything odd.

If your issue is specific to a particular linter, please report it on that linter's repository, otherwise open it right here.

Hack on it

Sure, you're welcome! Just clone the repository into your Packages folder (Preferences -> Browse Packages).

> git clone https://github.com/SublimeLinter/SublimeLinter.git
> subl SublimeLinter

This will overrule the installed package straight away. Just delete the folder to reverse the process. The dev requirements can be read in the pyproject.toml file. Just use rye and install them:

> rye sync

Creating a linter plugin

Use the template to get started on your plugin. It contains a how-to with all the information you need. Refer to https://www.sublimelinter.com/en/master/linter_plugin.html for more detailed information. Of course, take a look at a similar linter plugin and let it inspire you.

Also Support ❤️

SublimeLinter is the kind of software that needs active maintenance all the time. If you find SublimeLinter helpful and would like to show your appreciation, you can support its development by buying me a coffee! 😄☕ https://paypal.me/herrkaste

😏

sublimelinter-flow's People

Contributors

abrenneke avatar alexkuz avatar braver avatar ckaznocha avatar davidaurelio avatar frantic avatar groteworld avatar kaste avatar namuol avatar nicosantangelo avatar nsfmc avatar ntwb avatar pavelloz avatar smirea avatar strml avatar tomasbarry avatar xinchaobeta avatar yuppy 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  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  avatar  avatar  avatar  avatar  avatar

sublimelinter-flow's Issues

Linter hangs the editor when building

When a build is started (ctrl+b) the linter will sometimes hang. It doesn't always happen and it happens more the longer Sublime Text is running to the point where every build hangs. Normal linting, through "Lint this View", works flawlessly. The other linters I have installed (javac and eslint) do not hang.

The editor will hang until flow.exe is killed. This sometimes causes the plugin host to crash.

OS: Windows
Sublime Version: Build 3175

errors `message` may not correspond to `operation` path

i recently found a flow error that looks like this:

{
  "passed": false,
  "errors": [
    {
      "operation": {
        "descr": "call of method `event`",
        "path": "/Users/marcos/foo.js",
        "line": 27,
        "endline": 27,
        "start": 16,
        "end": 44
      },
      "message": [
        {
          "descr": "property `meta`",
          "level": "error",
          "path": "/Users/marcos/bar.js",
          "line": 183,
          "endline": 183,
          "start": 19,
          "end": 26
        },
        {
          "descr": "Property not found in",
          "level": "error",
          "path": "",
          "line": 0,
          "endline": 0,
          "start": 1,
          "end": 0
        },
        {
          "descr": "object type",
          "level": "error",
          "path": "/Users/marcos/foo.js",
          "line": 27,
          "endline": 27,
          "start": 36,
          "end": 43
        }
      ],
      "kind": "infer"
    }
  ],
  "version": " Mar  2 2016 14:35:05"
}

this ends up linting on the command-line with the following:

 27:     something = a.b.c(d);
                     ^^^^^^^^ call of method `event`
181:     else: (blarg: BaazQuux): Blarg => ({
                       ^^^^^^^^ property `meta`. Property not found in. See: bar.js:181

what's errorful about this is that this single flow output is referring to two separate files and the bounds for foo (less than 181 lines, in this case) cause sublime linter to freak out when it encounters errors[0].message[0].line and discovers that this line may not even exist in the current file being linted.

i ran into this with the tempfile linting set up, so i don't know for sure that this refers to an existing bug, but i am 100% certain that i had never encountered the errors[0].operation field (and that it should take precedence when evaluating lint output.

please feel free to assign this to me (i intend to fix this in any case), but i wanted to record this here in case anybody is running into this problem and is flummoxed as to why sublimelinter-flow is giving up the ghost in this case.

apologies for not considering this case where the paths do not match the current file being linted!

No visible markers

I have two linters enabled: standard and flow.

standard's linter errors show up just fine, but flow's don't at all, although both get displayed in the console.

Reinstalling SublimeLinter, SublimeLinter-flow, restarting ST3, toggling the standard linter all didn't seem to work.

SublimeLinter-Flow doesn't find '.flowconfig' between the open file and the directory root.

Until one of the latest releases, it would appear that SublimeLinter-Flow checked recursively checked all of the currently-opened-file's parent directories for presence of a .flowconfig file, which meant that the following directory structure would work:

- project-root
    - foo
        - .flowconfig
        - bar
            - the-open-file.js

Now, it does not. The error message suggests that it only starts looking from the project-root, rather than from the currently-opened-file. This means that I can no longer use SublimeLinter-Flow with a project whose .flowconfig is not at the project root.

Flow Comment Type support?

Does SublimeLinter-flow support Flow's comment-based syntax?

I'm finding that it's giving me "Missing Type Annotation" errors for code like this:

// @flow
import React from "react";
import type { Element } from "react";

const InputField = (value /*: string */)/*: Element<*> */ => <input value={ value } />;

But if I remove the comments from the annotations, it passes Flow validation just fine.

`all` option doesn't work

Apart from advertised way of calling flow check the linter calls flow to which --all is an invalid option, so when all is set to true in linter configuration the linter fails because flow binary fails in background with error message that --all is not an correct parameter

Linter doesn't work with 'all' config option

With the creation of flow-typed, it's now reasonable to turn on the all option in .flowconfig. In combination with ignoring <PROJECT_ROOT>/node_modules, the number of input files is dramatically lower than it would otherwise be.

Commit 348e513 turned off linting of files without a @flow pragma, which means that I still need to annotate all my files in order to get linting, which defeats the purpose of the all option!

Would a smarter check be reasonable to determine if a file should actually be linted?

Eslint ignore flow types

let fooMaker = (foo: string) => {
  console.log(foo);
};

unexpected Token :

Anyway to let Eslint know to not report Flow stuff?

question: separating flow-bin initialization from subsequent calls to flow

starting the flow server can take a minute or two (depending on the size of the codebase). nuclide and vscode sort of address this by hooking into flow's LSP server to run lint checks, but sublime linter just fires up the process and waits for a response (for however many views could be linted).

is there a way to have sublimelinter spawn the flow process separately from its subsequent calls to lint individual views (i looked at SublimeLinter/SublimeLinter#1250 and it seems like there was movement in this direction, but it seems like it was addressed differently as SublimeLinter/SublimeLinter#1234) I think the latter's approach is pretty sensible, but the initial flow startup time is a fairly deceptive metric.

it could also be that this isn't an issue in practice, that it eventually washes out, but i noticed sublimelinter crashing the plugin host in sublime text with this plugin and suspcted this might be the reason (there is no other logged information which might suggest the problem)

feel free to close, just wanted to ask if maybe there was some infra in place to do this efficiently.

Linter not matching command line?

I'm running flow via the command line:

Found 10 errors

c:\source\mood\visualizations>flow
src/d3/ContextMap/NodeLayer.js:2
  2: import d3 from "d3";
                    ^^^^ d3. Required module not found

src/d3/ContextMap/NodeLayer.js:3
  3: import * as core from "@mood/javascript-core";
                           ^^^^^^^^^^^^^^^^^^^^^^^ @mood/javascript-core. Required module not found

src/d3/ContextMap/NodeLayer.js:104
104:     get layerType() { return LAYER_TYPE.DATA; }
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Potentially unsafe get/set usage. Getters and setters with side effects are potentially unsafe and disabled by default. You may opt-in to using them anyway by putting `unsafe.enable_getters_and_setters=true` into the [options] section of your .flowconfig.

But within the Sublime IDE I'm getting additional errors - I can't work out the disparity:

image

Trouble with SublimeLinter-flow

I can't get sublimelinter-flow to show errors in the gutter. Yet the flow executable is in my $PATH, sublimelinter debug mode says that the plugin is successfully loading and running, and reporting errors, but they don't show up in the editor view. sublimelinter-eslint, etc. all work without a glitch. Again, my path is configured correctly (in .bash_profile, as per the sublimelinter docs) and the plugin is correctly finding the flow executable.

Here's what the gutter looks like next to a line with a known Flow error (line 49)
image

Here's what the console says is going on:
image

Any help appreciated. Thanks for such an awesome product. <3

PS the yellow square is marking a change viz. my git history, ignore it.

error in SublimeLinter daemon

I have installed the flow linter in SublimeText 3 together with the latest version of flow (0.22.0) and am running into the following issue. When the linter runs, i save a file with the /* @flow */ directive added, it simply throws the error below.

I made sure i don't have any other flow plugins installed. Flow runs fine from the command line. No sure what else this could be.

SublimeLinter: flow activated: /usr/local/bin/flow 
SublimeLinter: error in SublimeLinter daemon: 
SublimeLinter: -------------------- 
SublimeLinter: Traceback (most recent call last):
  File "/Users/tijs/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/queue.py", line 57, in loop
    item = self.q.get(block=True, timeout=self.MIN_DELAY)
  File "./queue.py", line 175, in get
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tijs/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/queue.py", line 65, in loop
    self.lint(view_id, timestamp)
  File "/Users/tijs/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/queue.py", line 111, in lint
    self.callback(view_id, timestamp)
  File "/Users/tijs/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/sublimelinter.py", line 119, in lint
    Linter.lint_view(view, filename, code, hit_time, callback)
  File "/Users/tijs/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/linter.py", line 924, in lint_view
    linter.lint(hit_time)
  File "/Users/tijs/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/linter.py", line 1367, in lint
    cmd = self.get_cmd()
  File "/Users/tijs/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/linter.py", line 1112, in get_cmd
    cmd = self.cmd()
  File "linter in /Users/tijs/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-flow.sublime-package", line 52, in cmd
KeyError: 'use-server'

SublimeLinter: -------------------- 

Incorrect multiline error highlight

When the linter tries to highlight a multiline error it fails and only marks the first column, including all characters after the error.

Example:

/* @flow */

module.exports.invalid_export = class test{ // Multilne error. (This whole line gets maked as an error, not only the error itself)
    num:number; // Not highlighted
    str:string; // Not highlighted
} // Not highlighted

The error from flow looks like:

.../test_required.js:3:33,6:1: 
not (sup)ported

Doesn't display any error if one of the error's doesn't have a main message

In sublime text, the linter fully fails to highlight the file if there is an error without a main message.

/* @flow */

var str = "a string" * 2; // Should be an error: can't multiply a string an a number.

: // Not showing any error due to there not being any main message here, only a header message. this somehow makes the parsing of the linted error fail.

Error message:

.../test_main.js:5:2,2: Unexpected token :

Cannot get this to work

I am on Mac and SE3.
I have flow installed globally in "/usr/local/bin/flow"
I have package installed in Sublime

Running flow in my project directory produces correct output in console
This is my config:

"flow": {
                "@disable": false,
                "all": true,
                "args": [],
                "excludes": [],
                "lib": "",
                "show-all-errors": true
            },

Yet, there is nothing in SE3 ;/

Error in SublimeLinter daemon

Hello.
I use Sublime Text 3 (build 3083) with the latest versions of flow (0.33.0), SublimeLinter, SublimeLinter-contrib-eslint and SublimeLinter-flow installed correctly.

This plugin works well for most files I'd like to validate. But it crashes with some huge files that contain over 600 lines of code (not for all of them)

My SublimeLinter configuration file:

{
    "user": {
        "debug": false,
        "delay": 0.25,
        "error_color": "D02000",
        "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
        "gutter_theme_excludes": [],
        "lint_mode": "background",
        "linters": {
            "eslint": {
                "@disable": false,
                "args": [],
                "excludes": []
            },
            "flow": {
                "@disable": false,
                "args": [],
                "excludes": [],
                "libs": [
                    "./src/definitions/lib"
                ],
                "show-all-errors": false
            }
        },
        "mark_style": "squiggly underline",
        "no_column_highlights_line": false,
        "passive_warnings": false,
        "paths": {
            "linux": [
                "/home/unexpected/.nvm/versions/node/v6.5.0/bin"
            ],
            "osx": [],
            "windows": []
        },
        "python_paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "rc_search_limit": 3,
        "shell_timeout": 5,
        "show_errors_on_save": false,
        "show_marks_in_minimap": true,
        "syntax_map": {
            "JavaScript (Babel)": "javascript",
            "html (django)": "html",
            "html (rails)": "html",
            "html 5": "html",
            "magicpython": "python",
            "php": "html",
            "python django": "python",
            "pythonimproved": "python"
        },
        "use-server": false,
        "warning_color": "DDB700",
        "wrap_find": true
    }
}

Error log in Sublime's console:

SublimeLinter: -------------------- 
reloading Packages/User/SublimeLinter.sublime-settings
SublimeLinter: error in SublimeLinter daemon: 
SublimeLinter: -------------------- 
SublimeLinter: Traceback (most recent call last):
  File "/home/unexpected/.config/sublime-text-3/Packages/SublimeLinter/lint/queue.py", line 57, in loop
    item = self.q.get(block=True, timeout=self.MIN_DELAY)
  File "./queue.py", line 175, in get
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/unexpected/.config/sublime-text-3/Packages/SublimeLinter/lint/queue.py", line 65, in loop
    self.lint(view_id, timestamp)
  File "/home/unexpected/.config/sublime-text-3/Packages/SublimeLinter/lint/queue.py", line 111, in lint
    self.callback(view_id, timestamp)
  File "/home/unexpected/.config/sublime-text-3/Packages/SublimeLinter/sublimelinter.py", line 119, in lint
    Linter.lint_view(view, filename, code, hit_time, callback)
  File "/home/unexpected/.config/sublime-text-3/Packages/SublimeLinter/lint/linter.py", line 929, in lint_view
    linter.lint(hit_time)
  File "/home/unexpected/.config/sublime-text-3/Packages/SublimeLinter/lint/node_linter.py", line 77, in lint
    super(NodeLinter, self).lint(hit_time)
  File "/home/unexpected/.config/sublime-text-3/Packages/SublimeLinter/lint/linter.py", line 1410, in lint
    for match, line, col, error, warning, message, near in self.find_errors(output):
  File "linter in /home/unexpected/.config/sublime-text-3/Installed Packages/SublimeLinter-flow.sublime-package", line 125, in _error_to_tuple
  File "linter in /home/unexpected/.config/sublime-text-3/Installed Packages/SublimeLinter-flow.sublime-package", line 125, in <listcomp>
  File "linter in /home/unexpected/.config/sublime-text-3/Installed Packages/SublimeLinter-flow.sublime-package", line 159, in _format_message
TypeError: object of type 'NoneType' has no len()

SublimeLinter: -------------------- 

What can be the reason of this error?
Thank you.

missing gutter marker

I can see expected error msg in console, but no gutter marker between code lines.

SublimeLinter: flow: hello.js ['/usr/local/bin/flow', 'check', '--show-all-errors'] 
SublimeLinter: flow output:
../hello.js:8
  8: 
     ^ Unexpected end of input

However, when I use sublimelinter-eslint, everything looks good.

SublimeLinter: chdir not set or invalid, using /Users/zhenyong/Downloads/flow-master/examples/01_HelloWorld 
SublimeLinter: eslint: hello.js ['/usr/local/bin/eslint', '--format', 'compact', '--stdin', '--stdin-filename', '__RELATIVE_TO_FOLDER__'] 
SublimeLinter: eslint output:
/Users/zhenyong/Downloads/flow-master/examples/01_HelloWorld/hello.js: line 8, col 1, Error - Parsing error: Unexpected token

queue.Empty and KeyError: ''

The linter is throwing these exceptions at me whenever it's linting. Looking in the console, it seems like everything was parsed correctly... though I'm not too sure with how SublimeLinter works (you'll probably have a better idea).

I'm running at all default settings, latest Flow.

Here are the console errors:

SublimeLinter: -------------------- 
SublimeLinter: flow: test.js ['/usr/local/bin/flow', '--show-all-errors', '--json'] 
SublimeLinter: flow output:
{"flowVersion":"0.24.2","errors":[{"kind":"infer","level":"error","message":[{"context":"function add(a: int, b: int): int {","descr":"identifier `int`","type":"Blame","loc":{"source":"/Users/alfredxing/Desktop/test/test.js","type":"SourceFile","start":{"line":7,"column":17,"offset":49},"end":{"line":7,"column":19,"offset":52}},"path":"/Users/alfredxing/Desktop/test/test.js","line":7,"endline":7,"start":17,"end":19},{"context":null,"descr":"Could not resolve name","type":"Comment","path":"","line":0,"endline":0,"start":1,"end":0}]}],"passed":false} 
SublimeLinter: flow 1 errors. passed: False 
SublimeLinter: flow line: 6, col: 16, level: error, message: identifier `int` Could not resolve name 
SublimeLinter: error in SublimeLinter daemon: 
SublimeLinter: -------------------- 
SublimeLinter: Traceback (most recent call last):
  File "/Users/alfredxing/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/queue.py", line 57, in loop
    item = self.q.get(block=True, timeout=self.MIN_DELAY)
  File "./python3.3/queue.py", line 175, in get
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/alfredxing/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/queue.py", line 65, in loop
    self.lint(view_id, timestamp)
  File "/Users/alfredxing/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/queue.py", line 111, in lint
    self.callback(view_id, timestamp)
  File "/Users/alfredxing/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/sublimelinter.py", line 119, in lint
    Linter.lint_view(view, filename, code, hit_time, callback)
  File "/Users/alfredxing/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/linter.py", line 962, in lint_view
    callback(cls.get_view(vid), linters, hit_time)
  File "/Users/alfredxing/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/sublimelinter.py", line 167, in highlight
    highlights.draw(other_view)
  File "/Users/alfredxing/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/highlight.py", line 98, in draw
    all.draw(view)
  File "/Users/alfredxing/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/highlight.py", line 390, in draw
    self.set_mark_style()
  File "/Users/alfredxing/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/highlight.py", line 377, in set_mark_style
    self.mark_flags = MARK_STYLES[self.mark_style]
KeyError: ''

SublimeLinter: --------------------

SublimeLinter-flow doesn't respect a @FlowFixMe comment

If the following line is in a file, you'll see a flow error warning about userSelect not existing on the style object

var es = (document.documentElement) ? document.documentElement.style.userSelect : null;

The following change should cause the error to go away...

// $FlowFixMe: Flow is wrong.  userSelect exists.  At least in Chrome world.
var es = (document.documentElement) ? document.documentElement.style.userSelect : null;

Error when Flow returns an extra, empty error

For some reason flow is returning two error messages for a file:

{'path': 'D:\\dev\\timer\\app\\containers\\App.js', 'context': '    {this.props.children}', 'line': 6, 'descr': 'property `props`', 'loc': {'end': {'line': 6, 'column': 15, 'offset': 106}, 'start': {'line': 6, 'column': 11, 'offset': 101}, 'source': 'D:\\dev\\timer\\app\\containers\\App.js', 'type': 'SourceFile'}, 'end': 15, 'endline': 6, 'start': 11, 'type': 'Blame'}

and

{'path': '', 'context': None, 'line': 0, 'descr': 'global object', 'end': 0, 'endline': 0, 'start': 1, 'type': 'Blame'}

Could very well be a bug in Flow, but it has a simple fix here so I'll submit a pull request to fix it...

For reference the file is just:

// @flow
import React, { Component, PropTypes } from 'react';

const App = () => {
  <div>
    {this.props.children}
  </div>
};

App.propTypes = {
  children: PropTypes.element.isRequired
}

export default App

Too many open files

I'm trying to use flow with SublimeLinter and it's working.

However after awhile I get this error and have to restart sublime.

SublimeLinter: #219 flow UpdateHelpers.mjs ERROR:

 could not launch ['{app}/node_modules/.bin/flow', 'check-contents', '{app}/src/responsive-editor/js/store/template-helpers/UpdateHelpers.mjs', '--show-all-errors', '--json']
Reason: [Errno 24] Too many open files
PATH: /Users/daniel/.yarn/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/sbin:/usr/local/share/npm/bin:/Users/daniel/Library/Android/sdk/platform-tools

Is there a way to fix this?

Flow not updating / detecting errors

Hi there,

Sublimelinter flow doesn't seem to detect when there are errors, even when i have introduced them.

Here is the console

SublimeLinter: flow: test.js ['/usr/local/bin/flow', 'check', '--show-all-errors']
SublimeLinter: flow output:

Found 0 errors

but there is clearly an error, at some point it suddenly detects an error usually when i am playing around with changing the sublime linter theme. Then once the error is shown I correct the error but sublimelinter flow doesn't detect that its fixed. It still says there is an error. I have saved the file also.

Of course running it in the shell always works .. heres the details of the shell

Flow server launched for /Users/ian/Desktop/start/flight
Spawned flow server (child pid=1267)
Logs will go to /var/folders/wp/7fvln53n0zzbnqply2rp7_bh0000gn/T/flow_ian/ian-zSUserszSianzSDesktopzSstartzSflight.log
The flow server will be ready in a moment.

/Users/ian/Desktop/start/flight/test.js:7:5,11: string
This type is incompatible with
/Users/ian/Desktop/start/flight/test.js:4:10,15: number

Found 1 error

I do have jshint and also jscs installed via sublimelinter and they work ok.

Any reason why flow isn't picking / detecting changes ?

Thanks

heres my standard .flowconfig

[ignore]

[include]

[libs]

[options]

How can once specify include_warnings for only SublimeLinter-flow?

Flow has an option include_warnings. The linter appears to only show warnings if this is set to true in the .flowconfig, but I would rather not do that for the entire project. Is there a way I can have the linter show warnings without setting the entry in the .flowconfig file?

Linter outputs error on files without @flow

Hi,
Thanks in advance.
I am new with this, so if this is an answered question, please point me to the thread.
I am using sublimeLinter-flow 4.2.0.
The linter is linting the files without @flow on the top. So I get flow errors on files I haven't implemented @flow on.
I read in one of the closed issues that the linter only works for files with @flow annotation by default.
What am I doing wrong?
Thanks

KeyError: 'level' - error in SublimeLinter daemon

This is what I get in ST3 console:

SublimeLinter: error in SublimeLinter daemon: 
SublimeLinter: -------------------- 
SublimeLinter: Traceback (most recent call last):
  File "/Users/damian/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/queue.py", line 57, in loop
    item = self.q.get(block=True, timeout=self.MIN_DELAY)
  File "./queue.py", line 175, in get
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/damian/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/queue.py", line 65, in loop
    self.lint(view_id, timestamp)
  File "/Users/damian/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/queue.py", line 111, in lint
    self.callback(view_id, timestamp)
  File "/Users/damian/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/sublimelinter.py", line 119, in lint
    Linter.lint_view(view, filename, code, hit_time, callback)
  File "/Users/damian/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/linter.py", line 924, in lint_view
    linter.lint(hit_time)
  File "/Users/damian/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/node_linter.py", line 77, in lint
    super(NodeLinter, self).lint(hit_time)
  File "/Users/damian/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/linter.py", line 1397, in lint
    for match, line, col, error, warning, message, near in self.find_errors(output):
  File "linter in /Users/damian/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-flow.sublime-package", line 80, in _error_to_tuple
KeyError: 'level'

SublimeLinter: -------------------- 

I have flow installed globally in "/usr/local/bin/flow"
Running flow in my project directory produces correct output in console
This is my config:

"flow": {
    "@disable": false,
    "args": [],
    "excludes": [],
    "show-all-errors": true
},

I’d like to help: `flow coverage`

I’d love to add optional support for flow coverage to SublimeLinter-flow. The problem is that we have to run an flow coverage --path @ --json as an additional command.

As far as I understand the SublimeLinter developer docs, there is no generic support for this. would it be feasible to override run() in a way that calls super().run() twice?

Thanks!

Support project-local flow binary

Currently users are required to have flow in their PATH, which usually means a global install of flow:

npm install -g flow-bin

However, it's possible to use the project-local flow binary (i.e. ./node_modules/bin/flow) by extending NodeLinter and supplying npm_name, as seen here in SublimeLinter-eslint.

Any reason not to do it this way? Seems like a good convention.

CFLint not working

Hi,

I've packages:

  • CFML: 0.27.4
  • Sublime​Linter: 4.8.0
  • Sublime​Linter-contrib-CFLint: 3.0.0

And CFLint-1.4.0-all.jar ("jar_file": "CFLint-1.4.0-all.jar") in my settings of SublimeLinter

But it doesn't seems to work. If i do a wrong syntax error or whatever i don't see any messages in sublime.

When i open the console in sublime and open a CFC i get the following message, and its not working (See below)
Also if i open the Sublimelinter output (you can find this leftbottom of sublime) it only says: No lint results.

SublimeLinter: sublime_linter.py:250: Delay buffer 69 for 0.0s
SublimeLinter: sublime_linter.py:250: Delay buffer 76 for 0.0s
SublimeLinter: linter.py:887: Checking lint mode load_save vs lint reason on_load
SublimeLinter: #1 linter.py:907: 'cflint' is linting 'test.cfc'

SublimeLinter: #1 linter.py:1191: The @ symbol in cmd has been deprecated. Use $file, $temp_file or $file_on_disk instead.
SublimeLinter: #1 linter.py:1263: Running ...

C:\websites\test (working dir)

"C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe" -file test.cfc -q -text

SublimeLinter: sublime_linter.py:444: Linting buffer 76 took 0.64s

On save:

SublimeLinter: linter.py:887: Checking lint mode load_save vs lint reason on_save
SublimeLinter: #2 linter.py:907: 'cflint' is linting 'test.cfc'
SublimeLinter: #2 linter.py:1191: The @ symbol in cmd has been deprecated. Use $file, $temp_file or $file_on_disk instead.
SublimeLinter: #2 linter.py:1263: Running ...

C:\websites\test (working dir)

"C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe" -file test.cfc -q -text

SublimeLinter: sublime_linter.py:444: Linting buffer 76 took 0.09s

Inconsistent highlighting of errors.

I've found the error highlighting quite inconsistent.

Examples:

test_main.js:

/* @flow */

// FAIL: requried an invalid path. (Only the first letter is highlighted)
var require_invalid = require('./test_invalid.js');
// SUCCESS: require a valid path
var test_required = require('./test_required.js');

// FAIL: Multiplying a string with a number, not valid in javascript. (The whole line gets maked as an error, not only the error itself)
var thisIsAnError = a*b; // Also highlighted

// Doesn't get highlighted, since the values originate from test_reguested.js.
thisIsAnError = test_required.num*test_required.str;

// SUCCESS: A simple function with a non optional string and an optionan number as it's input. 
function lengthOfString(name:string, someNumber?:number){
    someNumber = someNumber || 5;
    return name + "'s length is " + name.length + " & " + someNumber;
}

// FAIL: invalid input. (Only the first letter is highlighted)
size("user","te");

// Error: can't multiply a string an a number. Correctly highlighted.
var str = "a string" * 2;

test_requested.js

/* @flow */

// For testing in main file. 
module.exports.num = 1;

// For testing in main file. Displays an error even though the error originated from test_main.js and should be highlighted there.
module.exports.str = "a string";

Flow output

.../test_main.js:4:23,50: ./test_invalid.js
Required module not found

.../test_main.js:9:21,21: identifier a
Unknown global name

.../test_main.js:9:23,23: identifier b
Unknown global name

.../test_main.js:21:1,4: identifier size
Unknown global name

.../test_main.js:24:11,20: string
This type is incompatible with
.../test_main.js:24:11,24: number

.../test_required.js:7:22,31: string
This type is incompatible with
  .../test_main.js:12:16,50: number

Show full error message

Hello. From this error I can't understand what exactly I should fix. I don't know what is type [1] and type [2] without context and can't goto their definitions. How I can expand error message?

image

Not seeing any error messages except in the console

I was expecting to see an error pop down like it does for ESLint, but am not.

I saw this in the console...

Here's my Linter settings...

{
    "user": {
        "debug": true,
        "delay": 0.25,
        "error_color": "D02000",
        "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
        "gutter_theme_excludes": [],
        "lint_mode": "load/save",
        "linters": {
            "coffeelint": {
                "@disable": false,
                "args": [],
                "excludes": []
            },
            "eslint": {
                "@disable": false,
                "args": [],
                "excludes": []
            },
            "flow": {
                "@disable": false,
                "args": [],
                "excludes": [],
                "show-all-errors": true
            },
            "jshint": {
                "@disable": true,
                "args": [],
                "excludes": []
            },
            "rubocop": {
                "@disable": false,
                "args": [],
                "excludes": []
            }
        },
        "mark_style": "outline",
        "no_column_highlights_line": false,
        "passive_warnings": false,
        "paths": {
            "linux": [],
            "osx": [
                "/Users/jonathanc/.nvm/versions/node/v4.1.1/bin/",
                "/opt/boxen/rbenv/shims/"
            ],
            "windows": []
        },
        "python_paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "rc_search_limit": 3,
        "shell_timeout": 10,
        "show_errors_on_save": true,
        "show_marks_in_minimap": true,
        "syntax_map": {
            "JavaScript (Babel)": "javascript",
            "html (django)": "html",
            "html (rails)": "html",
            "html 5": "html",
            "php": "html",
            "python django": "python"
        },
        "warning_color": "DDB700",
        "wrap_find": true
    }
}

Let me know if I might be missing something!

The highlighting gets left "behind".

The highlighting gets left behind when a new character is inserted on a line other than the last.

Example

/* @flow */

var error1 = "error" * "1";

var error2 = "error" - "2";

Steps to replecate

Put the marker on line 2.
Press ENTER.
Watch the linter missing the change and highlighting the lines over the real errors.

Fix

Save the file.
Press SPACE.

update linter to no longer use `@` to refer to file

when debugging an error where sublimelinter-flow can bring down the plugin host, i noticed the following:

SublimeLinter: #2 linter.py:1087: The `@` symbol in cmd has been deprecated. Use $file, $temp_file or $file_on_disk instead.
[2018-05-10 14:38:47,006 - INFO     - SublimeLinter.lint.linter] The `@` symbol in cmd has been deprecated. Use $file, $temp_file or $file_on_disk instead.

i can take this small patch on in the next week or so as i debug whatever it is that bringing down the plugin host

`flow check-contents` causes funny errors

Flow reports errors differently between flow and flow check-contents in some specific cases! I've started seeing ghost errors reported from SublimeLinter-flow because of it. See facebook/flow#2235 for the upstream issue.

Are there any options available to allow SublimeLinter-flow to work around this? One comment on the linked issue mentions a proposal for better IDE integration. One other comment mentioned that there's an IDE that uses flow for files that have been saved and flow check-contents for unsaved files.

esproposal.optional_chaining=enable

sublimelinter-flow is keeping telling me that the code is incorrect "o.toto?.titi" although the .flowconfig is having "esproposal.optional_chaining=enable"

(it works in webstorm)

what should I do for it to work in sublime text?

`React.Fragment` is a valid return type, even though it is not a type declared by React

The following code is deemed ok by SublimeLinter-flow:

// @flow

import * as React from 'react'

const X = (): React.Fragment => (
  <React.Fragment>
    <p>
      { 'Hello :)' }
    </p>
  </React.Fragment>
)

export default X

However, React.Fragment is a function, not a type. As such, SublimeLinter-flow should warn against using React.Fragment as a return type of X.

This is further highlighted by using the same code snippet on Flow's online test editor.

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.