Git Product home page Git Product logo

eslint_d.js's People

Contributors

aaronjensen avatar akoltun avatar amritk avatar asasinmode avatar bebraw avatar calbrecht avatar calebeby avatar christianalfoni avatar clessg avatar damiencassou avatar daradermody avatar dependabot[bot] avatar doctyper avatar dpinol avatar expelledboy avatar higherorderfunctor avatar ibuki2003 avatar jlhwung avatar josephfrazier avatar jpulec avatar kaste avatar mantoni avatar matz3 avatar mrnugget avatar orzechowskid avatar ruanyl avatar shannonmoeller avatar simenb avatar sqve avatar yuezk 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

eslint_d.js's Issues

How to use local eslint

I just want to use eslint_d like "./node_modules/.bin/eslint . --ext .vue"
Can you tell me how ?

--stdin using netcat

Hello,

I would like to use nc to pass stdin into eslint_d. Is this possible?

I tried using

cat file.js | cat <(echo "$TOKEN $PWD --stdin") - | nc -q 0 localhost $PORT

as seen here, but it only prints

RangeError: "size" argument must not be larger than 2147483647
# exit 1

Thanks

Does this only work on Cloud 9 created instances?

I tried using this with a SSH Box (pretty plain Ubuntu 16.04 setup) but it doesn't seem to be triggering. Is there anything special about getting it working on something other than the default Cloud 9 EC2 instance?

Improve documentation on configuration handling

I am missing some documentation on how this thing works. Specifically:

  • what happens if I supply a different config file between invocations? Will it restart the process?
  • what happens if I change the working directory?
  • is there a way of listing which files are touched/being done something with? --debug did not really show anything.

eslint_d could not connect

Hi,
I installed eslint_d globally npm i eslint_d -g and tried to lint a file but when i run eslint_d app.js nothing happens(more than 2min without anything) while the eslint app.js cmd display the lint errors.
I tried eslint_d status and i have this message could not connect.
image

I checked the ~/.eslint_d and the file has one line 53288 59a364a04c2ec7b5.

The eslint_d --version give me this v3.14.1 (eslint_d v4.2.1), the help cmd for eslint_d works also(the same output of eslint --help).

Is there a log file that i can take a look to understand why eslint_d could not connect ?
Thanks

Add information about --cache in the readme

As your software was created to improve eslint speed, you could maybe specify that to get an even better speed improvement, you can use --cache (which is an eslint option).

What do you think ?

Eslint_d tries to lint config file

It looks like bug with options

eslint_d src/1.js --config ./.eslintrc

... // some errors
/Users/roadhump/Projects/xx/src/1.js: line 5, col 1, Error - Multiple blank lines not allowed. (no-multiple-empty-lines)
/Users/roadhump/Projects/xx/.eslintrc: line 2, col 13, Error - Line X: Unexpected token

7 problems

Support --print-config

flycheck-eslint now uses --print-config to verify that a file has a config. This doesn't work in eslint_d, effectively disabling it.

ES7 decorators parsing fail

Having something like this, fails with eslint_d but works with eslint.

@observer
export default class MyComponent extends Component {
   ...
}
// throws
error  Parsing error: Unexpected character '@'

I am using the babel-eslint parser.

// .babelrc
{
  "presets": ["es2015", "react", "stage-1"],
  "plugins": ["transform-decorators-legacy"]
}

I am a bit confused why eslint works but eslint_d does not.

Improve READEME

Hey man, thanks for making sublime linting great again! Your eslint_d.js is a joy to use.

However while testing, i was playing with moar speed, it works and it's great but I get a performance hit when i use that option.

Since i have no clue how to use nc, i can't revert back to previous state. Can you please update your README detailing how to revert back . Thanks anyways!

Screenshots:
screenshot from 2016-09-28 14-09-31

In the screenshot, it shows 1.3GB RAM consumption but i have seen it's memory consumption way above.

Parsing error: ecmaVersion must be 3, 5, 6, or 7

I have the following options in my .eslintrc

{
  "parserOptions": {
    "ecmaVersion": 2016
  }
}

This is valid when I use the eslint command directly. My eslint --version is v3.19.0. It is correctly linting my files.

However, when I use eslint_d instead, I get this error instead:

/Users/andy/Desktop/ipmask.js
  0:0  error  Parsing error: ecmaVersion must be 3, 5, 6, or 7

โœ– 1 problem (1 error, 0 warnings)

The eslint_d --version says v3.19.0 (eslint_d v4.2.5). So the eslint version is the same but parsing fails when it should be valid. I tried reinstalling eslint_d and I ran eslint_d restart but no luck.

Error on space-containing config path

eslint_d --config "c:\space-containing path\.eslintrc"

gives

Error: Cannot read config file: c:\space-containing
Error: ENOENT, no such file or directory 'c:\space-containing'

At least on Windows.

Output format

First of all, this project is really usually to me, so, thanks! I've been testing it and faced the following issues:

  • Couldn't get it to work by installing the modules locally (in the root of my project), only globally
  • Had to add --format compact to the command line options, otherwise it wouldn't highlight the problematic chunks

If it's a misconfiguration from my side, sorry.

Support --fix to stdout?

At the moment, --fix writes to the file. This makes it difficult to add as a pre-save hook in editors. There is no official support for writing the fixed output to stdout via the cli (see eslint/eslint#6612) but it can be done w/ the api.

It'd be great to have eslint_d support that for the added speed boost, but it'd be a non-standard flag. Would you be up for having that in eslint_d?

autofix config in vim

here is my vimrc file ,i wanna to autofix eslint file

" settings for Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_check_on_w = 1
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_eslint_exec = 'eslint_d'
"let g:syntastic_javascript_eslint_args = '--fix-to-stdout' 

g:syntastic_javascript_eslint_args g:syntastic_javascript_eslint_tail seems not work

Not reading the right config files

I have a .eslintrc.json in my home directory and a package.json in my project directory with eslint configs, but when running eslint_d test.js for some file in the project directory eslint_d ignores package.json and proceeds to use the config from the home directory. eslint doesn't have this problem.

Support for prettier

Hey @mantoni I've recently started trying out prettier along with prettier-eslint. It'd be great to somehow be able to have eslint_d run code through prettier before passing it to fix.

I could build it in as an explicit feature (is it weird to couple eslint_d to a completely different tool?) or I could make some sort of prefilter plugin interface... Ideally I could use something like eslint-plugin-prettier but I have rules that disagree w/ prettier, so it won't work int hat way.

Thoughts?

Support `--fix-dry-run`

ESLint now offers a --fix-dry-run option. I think it would be a good idea to alias --fix-dry-run to the existing --fix-to-stdout option in eslint_d. Then it will be easier to swap out ESLint commands with eslint_d for use in various editor plugins.

Support IPv6 Connections

My machine was, by default, attempting to connect to eslint_d over IPv6 before trying IPv4, which caused a considerable slowdown. It'd be nice if this ran, by default, on both 127.0.0.1 and ::1

Start server using compact format

Hi @mantoni, first of all, many thanks for the brilliant work on eslint_d ๐Ÿ˜Š

I have stumbled upon an issue when working on eslintme that is the default value for the format option. The problem is that vim and probably other editors will expect a non-styled output, e.g. compact format.

To work around that limitation, my quick n'dirt solution was to point to a forked branch that replaces the default value of the compact option, as you can see here: ruyadorno@f7d4746

While the solution is working well for me, I don't feel like it's a proper solution in the long term. What I think would be a much better solution is to add the format option to eslint_d start command and store this value for every subsequent linting.

I would like to hear your thoughts about it, is it something that you would like to see on eslint_d? Would you be open to merge a PR introducing these changes? There could be better ways to achieve the same functionality?

sorry for the long message ๐Ÿ˜… thanks again!

flow-bin executes in visible command window in Windows

When using eslint-plugin-flowtype-errors in Windows, eslint executes flow to determine FlowJS errors. When running eslint_d, this causes a visible command window to appear and steal focus from the editor. This happens when executing eslint_d from a command window also.

This behavior does not happen when executing eslint from the command line.

I would be happy to send a PR, but I need a pointer in the right direction. I glanced through the code and the solution was not obvious to me.

Add support of local plugins

eslint_d does not resolve local plugins in project's node_modules as eslint does

It means

npm install eslint eslint_d babel-eslint --save-dev

// .eslintrc
{"parser": "babel-eslint"}

$ ./node_modules/.bin/eslint_d src/1.js 

/Users/roadhump/Projects/xx/src/1.js
  0:0  error  Cannot find module 'babel-eslint'

$ ./node_modules/.bin/eslint_d src/1.js 
// no errors

running eslint_d from parent directory is slower

Hi! I'm a vim user and experience blocking lag with eslint, and still do with eslint_d. I've noticed that my project setup seems to be part of the problem, but since changing my project directory organization isn't an option I'm looking for a solution.

The problem is that I have two javascript projects, an api in node and a react app that consumes that api. So I have a structure like:

- project
-- api 
-- frontend

I open vim and and run eslint_d from the project directory but there are unique .eslintrc and node_modules files in the api/react directories. I'm guessing that eslint_d is having to do some work to reconcile the fact that it's one directory above the node_modules and figure out which eslint bin to use?

Idea: Garbage collect eslint instances after long inactivity

This tool is fairly stable which leads to a situation where the daemon process is running for several weeks or even month. It keeps all instances of eslint cached in memory that have been used with no eviction mechanism, leading to quite a bit of ram being "wasted".

It should be fairly straight forward to implement a periodic check for instances that have not been used for a couple of hours and remove those.

Just putting this out as an idea. If you feel like implementing, go for it! ๐Ÿ˜„

eslint_d does not respect NODE_PATH

Hi,

linter.js in eslint_d does not pass the directories from NODE_PATH into resolve.sync, so it's running into browserify/resolve#39

This is manifested in the form of

Error: Cannot find module 'eslint' from '$eslint_d_parent/eslint_d/lib'

where $eslint_d_parent is eslint_d's parent directory and eslint is present elsewhere in $NODE_PATH.

Problematic lines in linter.js:

module.exports = function (cwd, args, text) {
  process.chdir(cwd);
  var cwdDeps = eslintMap[cwd];
  if (!cwdDeps) {
    var eslintPath;
    try {
      eslintPath = resolve.sync('eslint', { basedir: cwd });
    } catch (e) {
      // module not found
      eslintPath = resolve.sync('eslint');
    }
    cwdDeps = eslintMap[cwd] = {
      eslint: require(eslintPath),
      // use chalk from eslint
      chalk: require(resolve.sync('chalk', {
        basedir: path.dirname(eslintPath)
      }))
    };
  }

Suggested fix -- looking up NODE_PATH from Module.globalPaths and passing that as resolve.sync's paths option:

var globalPaths = require('module').globalPaths;

module.exports = function (cwd, args, text) {
  process.chdir(cwd);
  var cwdDeps = eslintMap[cwd];
  if (!cwdDeps) {
    var eslintPath;
    try {
      eslintPath = resolve.sync('eslint', { basedir: cwd, paths: globalPaths });
    } catch (e) {
      // module not found
      eslintPath = require.resolve('eslint');
    }
    cwdDeps = eslintMap[cwd] = {
      eslint: require(eslintPath),
      // use chalk from eslint
      chalk: require(resolve.sync('chalk', {
        basedir: path.dirname(eslintPath),
        paths: globalPaths,
      }))
    };
  }

Detect other "Engines"?

Hi! Love this thing.
So, I've been running into lots of projects that use standard, which means there's no eslint config files in the project, which means eslint_d doesn't know what rules to use. ( you run the linter with standard foo.js instead of eslint foo.js )

I was bugging the nice people at eslintd-fix about it and trying to figure out how to get emacs to use the right linter, but then I got to thinking, maybe here would be a better place to address?

Curious what you'all think about detecting standard in package.json or node_modules, and spinning that up instead of eslint? I guess it's awkward to special-case stuff in like this, but on the other hand, standard is so widely used.

Fallback to global eslint

Right now the order to find eslint is

  1. local node_modules
  2. bundled version

I prefer to use a global eslint installation to save space and avoid updating micromanagement. Would it be possible to have a loading order like this?

  1. local node_modules
  2. global node_modules
  3. bundled version

--fix option doesnt work

Take this .eslintrc

{
  "rules": {
    "space-infix-ops": 2
  }
}

and this js

var foo=function (bar) {
  return bar;
};

eslint . and eslint_d . both produce the same output :

/tmp/eslint_t/bootstrap.js
  1:8  error  Infix operators must be spaced  space-infix-ops

However

eslint . --fix does modify the file
eslint_d . --fix doesn't modify the file

problem of eslint_d with vim

eslint_d doesn't work with vim if eslint and eslint plugins like 'eslint-plugin-react' are not installed locally. While use eslint, the linting works even eslint and it's plugins are installed globally.

Move lengthy auto-fixing setup for Emacs out of README

I think the emacs section about auto-fixing grabs too much land in the README. I would like that to live elsewhere and be cross-linked into the README to have this as one or two line bullet point.

@aaronjensen You mentioned you would like to move this into a separate project, but we can also just enable the Wiki for this project. Alternatively, it could be a snippet that lives in a separate file in this repository if we find a good place for it. What do you think?

Add Mocha test cases

This project needs test cases. It started off as a quick hack, but as more features are added and bugs are fixed, test cases would be great to ensure the existing functionality does not break.

I prefer Mocha tests with simple not asserts. The implementation is already split up into testable units.

Exit code is always 0

Currently eslint_d cannot be used as a drop-in replacement for eslint because the return status is always 0 ๐Ÿ˜ข

eslint_d does not seem to support "no-prototype-builtins" even though it is included in eslint

Hello,

I am seeing a strange problem in eslint_d v3.1.0. It does not seem to include the rule "no-prototype-builtins" which is included in the same version of eslint (v2.11.1, http://eslint.org/docs/rules/no-prototype-builtins)

Please note I also tried to include debug information for you (eslint_d --debug index.js) but the --debug command line argument does not seem to do anything.

Environment

> node --version
v4.4.4

> npm --version
3.9.5

> eslint_d --version
v2.11.1 (eslint_d v3.1.0)

Configuration

module.exports = {
  "extends": "eslint:recommended",
  "env": {
    "es6": true
  },
  "rules": {
    // Disallow use of Object.prototypes builtins directly
    "no-prototype-builtins": [
      "error"
    ]
  }
};

Error

> eslint_d index.js

/Users/bruces/Projects/eslint-config-blacksun1/index.js
  1:1  error  Definition for rule 'no-prototype-builtins' was not found  no-prototype-builtins

โœ– 1 problem (1 error, 0 warnings)

I was able to see this error in Sublime text using the Sublime Linter plugin and from the command line.

Thanks in advance,

Does it support VSCode?

Hi, I am impressed by eslint_d's performance, can I use it on VSCode? I couldn't find anything related from the doc.

Problem with global installed eslint

Hi, I still the problem of eslint which is installed globally. Currently, if eslint_d cannot found eslint under working dir, it will load the eslint which installed under eslint_d.

Everything works just fine until I need to load eslint-plugin-*. these plugins are installed globally also. And they are loaded by eslint.

eslint seems not looking for global plugins if it's installed and loaded as a local module. An issue may relevant to this: eslint/eslint#4472

I am just thinking that would it makes more sense for eslint_d to load global eslint instead of local eslint under eslint_d?

I made a small change to the way of loading eslint, and I tested it with eslint_d cli and vim. It works just fine.

I will make a pull request for this :)

Intermittent issues with eslint_d

I've been having some intermittent issues with eslint_d, and I had a couple questions.

  • Does eslint_d resolve local project eslint-config modules automatically?

I didn't know if eslint_d needed to be supplemented with a config similar to mtscout6/syntastic-local-eslint.vim to ensure it always resolves the local project config modules.

  • What's the best way to debug eslint_d?

I'm encountering intermittent issues where I have to run eslint_d restart in order to get eslint_d to work again with Syntastic. After enabling g:syntastic_debug and determining the eslint_d command being used, I found there were errors similar to this:

eslint_d -f compact src/config/env.js
Error: standard:
    Configuration for rule "no-labels" is invalid:
    Value "2,[object Object]" has more items than allowed.

Referenced from: tribou
Referenced from: /Users/tribou/dev/project/.eslintrc

The error is from the eslint-config-standard module, but it's associated with using eslint v1.x, so I'm not sure what to do with that. However, after running eslint_d restart in the project directory, the issue appears to resolve itself. Any ideas?

v2.8.0 (eslint_d v3.1.0)

eslint_d using a different node_modules folder than eslint

Hi!
Awesome work, love the speed =)

Let me first specify the version I get when running eslint_d -v:
v2.10.2 (eslint_d v3.1.0)

Say I have a folder which contains a node_modules folder with eslint installed.

  • myProject
    • node_modules
      • eslint
    • src/ with bunch of js files

There is no .eslintrc in that folder, but there is one in my home directory ~/myHome/.eslintrc
The .eslintrc extends some config, or uses a certain plugin, lets say eslint-config-angular that is installed globally but not in myProject.

Now, if I would run eslint src/**/*js inside myProject, it all works fine. It searches up the tree to my home, finds the .eslintrc and tries to find eslint and its plugins etc from the global installed packages. So basicly it seems to search relative to the .eslinrc, and since its in home it uses global installed packages.

If I run eslint_d src/**/*.js however I get an error Error: Cannot find module 'eslint-config-angular' from '/home/myHome/myProject/node_modules'. It seems that eslint_d searches for eslint and companions relative to the folder its executed in, not relative to the .eslintrc it uses.

Add support of eslint options

It would be nice to have all possible options of eslint in eslint_d call: config, format, no-ignore, etc.

E.g

eslint_d lint --config some/config file.js

eslint version as peerDependency?

I'd like to use eslint 2.7.0 -- it seems that because it's specified in dependencies here, that's not possible when using eslint_d?
What would speak against putting it into peerDeps?

Change config node_modules to current project

While I'm trying

" Autofix entire buffer with eslint_d:
nnoremap <leader><leader>f mF:%!eslint_d --stdin --fix-to-stdout<CR>`F
" Autofix visual selection with eslint_d:
vnoremap <leader><leader>f :!eslint_d --stdin --fix-to-stdout<CR>gv

I got the errors of some modules or plugins can't find
"Error: Failed to load plugin react: Cannot find module 'eslint-plugin-react' โ€

So I know it means I need change the config to locale instead of global

But I don't know how

Here is my eslintrc.json :

{
    "extends": "airbnb"
}

Initialization Cannot Find Module

After installing and selecting eslint_d as eslint, webstorm throws error looking for the cli. There is no cli option in the package that i could tell. What am I missing here to get this to work with webstorm? Thank you.

screen shot 2017-04-18 at 13 16 56

screen shot 2017-04-18 at 13 20 53

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.