rizowski / eslint-watch

ESLint with simple watching capabilities
https://www.npmjs.com/package/eslint-watch
MIT License
196 stars 29 forks source link

Formatter reverts from 3rd party module to simple-detail during watch #108

Closed glebec closed 7 years ago

glebec commented 7 years ago

Environment

Basic Description of the problem

ESLint watch seems to "forget" which formatter to use. I am trying to set the formatter to Sindre Sorhus's nice https://github.com/sindresorhus/eslint-formatter-pretty. It's a slightly different version of the simple-detail formatter baked into esw, based on earlier work by Sindre. However, while the formatter appears correctly for the first pass of the lint, it reverts to simple-detail thereafter.

How to reproduce it

node_modules/.bin/esw --ignore-path .gitignore -f node_modules/eslint-formatter-pretty --watch

Debug output:

Running with DEBUG=* produces thousands of lines. Are you sure you want them?

rizowski commented 7 years ago

@glebec Thanks for reporting this. Run the command with DEBUG=esw:* That should be all the debugging I need.

glebec commented 7 years ago

Here you go:

Click for debug output

``` esw:internal-settings Eslint installed locally node_modules/.bin/eslint +0ms esw:internal-settings { eslintPath: 'node_modules/.bin/eslint', esw:internal-settings platform: 'darwin', esw:internal-settings isWindows: false } +2ms esw:eslint-cli Loaded +40ms esw:eslint-help Loaded +19ms esw:options Loaded +0ms esw:eslint-help Executing help +0ms esw:eslint-cli eslint: '--help' +2ms esw:executor node_modules/.bin/eslint [ '--help' ] +2ms esw:eslint-cli { exitCode: 0, esw:eslint-cli message: 'eslint [options] file.js [file.js] [dir]\n\nBasic configuration:\n -c, --config path::String Use configuration from this file or shareable config\n --no-eslintrc Disable use of configuration from .eslintrc\n --env [String] Specify environments\n --ext [String] Specify JavaScript file extensions - default: .js\n --global [String] Define global variables\n --parser String Specify the parser to be used\n --parser-options Object Specify parser options\n\nCaching:\n --cache Only check changed files - default: false\n --cache-file path::String Path to the cache file. Deprecated: use --cache-location - default: .eslintcache\n --cache-location path::String Path to the cache file or directory\n\nSpecifying rules and plugins:\n --rulesdir [path::String] Use additional rules from this directory\n --plugin [String] Specify plugins\n --rule Object Specify rules\n\nIgnoring files:\n --ignore-path path::String Specify path of ignore file\n --no-ignore Disable use of ignore files and patterns\n --ignore-pattern [String] Pattern of files to ignore (in addition to those in .eslintignore)\n\nUsing stdin:\n --stdin Lint code provided on - default: false\n --stdin-filename String Specify filename to process STDIN as\n\nHandling warnings:\n --quiet Report errors only - default: false\n --max-warnings Int Number of warnings to trigger nonzero exit code - default: -1\n\nOutput:\n -o, --output-file path::String Specify file to write report to\n -f, --format String Use a specific output format - default: stylish\n --color, --no-color Force enabling/disabling of color\n\nMiscellaneous:\n --init Run config initialization wizard - default: false\n --fix Automatically fix problems\n --debug Output debugging information\n -h, --help Show help\n -v, --version Output the version number\n --no-inline-config Prevent comments from changing config or rules\n --print-config path::String Print the configuration for the given file\n' } +218ms esw:eslint-help Alias found: -c +2ms esw:eslint-help Parsing --config +1ms esw:eslint-help Parsing --no-eslintrc +0ms esw:eslint-help Parsing no option --no-eslintrc +0ms esw:eslint-help Parsing --env +1ms esw:eslint-help Parsing --ext +0ms esw:eslint-help Parsing --global +0ms esw:eslint-help Parsing --parser +0ms esw:eslint-help Parsing --parser-options +0ms esw:eslint-help Parsing --cache +0ms esw:eslint-help Parsing --cache-file +0ms esw:eslint-help Parsing --cache-location +0ms esw:eslint-help Parsing --rulesdir +0ms esw:eslint-help Parsing --plugin +0ms esw:eslint-help Parsing --rule +0ms esw:eslint-help Parsing --ignore-path +0ms esw:eslint-help Parsing --no-ignore +1ms esw:eslint-help Parsing no option --no-ignore +0ms esw:eslint-help Parsing --ignore-pattern +0ms esw:eslint-help Parsing --stdin +0ms esw:eslint-help Parsing --stdin-filename +0ms esw:eslint-help Parsing --quiet +0ms esw:eslint-help Parsing --max-warnings +0ms esw:eslint-help Alias found: -o +0ms esw:eslint-help Parsing --output-file +0ms esw:eslint-help Alias found: -f +1ms esw:eslint-help Parsing --format +0ms esw:eslint-help Parsing --init +0ms esw:eslint-help Parsing --fix +0ms esw:eslint-help Parsing --debug +0ms esw:eslint-help Alias found: -h +0ms esw:eslint-help Parsing --help +0ms esw:eslint-help Alias found: -v +0ms esw:eslint-help Parsing --version +1ms esw:eslint-help Parsing --no-inline-config +0ms esw:eslint-help Parsing no option --no-inline-config +0ms esw:eslint-help Parsing --print-config +0ms esw:simple-detail loaded +223ms esw:watcher Loaded +0ms esw:arg-parser Loaded +1ms esw:esw-cli Loaded +0ms esw:esw-cli Eslint-Watch: 3.0.0 +0ms esw:esw-cli Arguments passed: [ '/usr/local/bin/node', '/Users/glebec/Dev/fs/official-projects/bones-g/node_modules/.bin/esw', '--ignore-path', '.gitignore', '-f', 'node_modules/eslint-formatter-pretty', '--watch' ] +0ms esw:esw-cli Parsing args +2ms esw:arg-parser Directories to check: [] +0ms esw:arg-parser Args [ '--ignore-path', '.gitignore', '-f', 'node_modules/eslint-formatter-pretty', '--watch' ] +0ms esw:arg-parser Pushing item: --ignore-path +1ms esw:arg-parser Pushing item: .gitignore +0ms esw:arg-parser Pushing item: -f +0ms esw:arg-parser Pushing item: node_modules/eslint-formatter-pretty +0ms esw:arg-parser Setting default path: ./ +0ms esw:esw-cli Running initial lint +0ms esw:esw-cli [ '--ignore-path', esw:esw-cli '.gitignore', esw:esw-cli '-f', esw:esw-cli 'node_modules/eslint-formatter-pretty', esw:esw-cli './' ] +0ms esw:eslint-cli eslint: '--ignore-path .gitignore -f node_modules/eslint-formatter-pretty ./' +0ms esw:executor node_modules/.bin/eslint [ '--ignore-path', '.gitignore', '-f', 'node_modules/eslint-formatter-pretty', './' ] +1ms server/auth.filters.js:16:1 ⚠ 16:1 foo is not defined. no-undef ⚠ 16:4 Extra semicolon. semi ✖ 16:1 Expected an assignment or function call and instead saw an expression. no-unused-expressions db/models/index.js:12:24 ⚠ 12:24 Extra semicolon. semi ✖ 12:25 Unnecessary semicolon. no-extra-semi ✖ 12:26 Unnecessary semicolon. no-extra-semi 3 warnings 3 errors esw:eslint-cli { exitCode: 1, message: '' } +2s esw:esw-cli lint completed. Exit Code: 1 +0ms esw:esw-cli -w seen +0ms esw:watcher { useEslintrc: true, ignore: true, ignorePath: '.gitignore' } +3ms esw:watcher { ignorePath: '.gitignore', esw:watcher format: 'node_modules/eslint-formatter-pretty', esw:watcher watch: true, esw:watcher eslintrc: true, esw:watcher ignore: true, esw:watcher inlineConfig: true, esw:watcher _: [] } +0ms esw:watcher Watching: [ '/Users/glebec/Dev/fs/official-projects/bones-g' ] +11ms esw:watcher Changed: /Users/glebec/Dev/fs/official-projects/bones-g/db/models/index.js +14s esw:watcher /Users/glebec/Dev/fs/official-projects/bones-g/db/models/index.js undefined +12ms esw:watcher lintFile: /Users/glebec/Dev/fs/official-projects/bones-g +1ms esw:simple-detail [ { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/bin/mkapplink.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/db/index.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/db/models/index.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/db/models/oauth.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/db/models/user.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/db/models/user.test.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/db/seed.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/index.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/node_modules/APP/index.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/node_modules/APP/webpack.config.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/server/api.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/server/auth.filters.js', esw:simple-detail messages: [ [Object], [Object], [Object] ], esw:simple-detail errorCount: 1, esw:simple-detail warningCount: 2, esw:simple-detail source: '\'use strict\'; // eslint-disable-line semi\n\nconst mustBeLoggedIn = (req, res, next) => {\n if (!req.user) {\n return res.status(401).send(\'You must be logged in\')\n }\n next()\n}\n\nconst selfOnly = action => (req, res, next) => {\n if (req.params.id !== req.user.id) {\n return res.status(403).send(`You can only ${action} yourself.`)\n }\n next()\n}\nfoo;\nconst forbidden = message => (req, res, next) => {\n res.status(403).send(message)\n}\n\n// Feel free to add more filters here (suggested: something that keeps out non-admins)\n\nmodule.exports = {mustBeLoggedIn, selfOnly, forbidden}\n' }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/server/auth.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/server/auth.test.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/server/start.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/server/users.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/server/users.test.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 }, esw:simple-detail { filePath: '/Users/glebec/Dev/fs/official-projects/bones-g/webpack.config.js', esw:simple-detail messages: [], esw:simple-detail errorCount: 0, esw:simple-detail warningCount: 0 } ] +2s /Users/glebec/Dev/fs/official-projects/bones-g/server/auth.filters.js (1/2) ✖ 16:1 Expected an assignment or function call and instead saw an expression no-unused-expressions ⚠ 16:1 'foo' is not defined no-undef ⚠ 16:4 Extra semicolon semi ✖ 1 error ⚠ 2 warnings (1:15:12 AM) esw:esw-cli c was pressed +16s esw:esw-cli Exiting: 1 +0ms ```

rizowski commented 7 years ago

This is a bug. The watcher portion of ESW has it hard coded.

https://github.com/rizowski/eslint-watch/blob/v3.0.0/src/watcher.js#L7 https://github.com/rizowski/eslint-watch/blob/v3.0.0/src/watcher.js#L65

glebec commented 7 years ago

Thanks @rizowski. BTW, if you support 3rd-party linters in watch mode, it would be nice (albeit not critical) to somehow still output the ✔ clean report for when linting succeeds with no warnings or errors.

rizowski commented 7 years ago

A Fix was merged into master. I have a few things I am going to add with this release and publish the fix.

rizowski commented 7 years ago

This has been released with v3.0.1