rizowski / eslint-watch

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

Not watch in docker #134

Closed HsuTing closed 6 years ago

HsuTing commented 6 years ago

Environment

Basic Description of the problem

Does not watch when using in node image of docker.

How to reproduce it

  1. Command: esw ./ --cache --ext .js -w --color

Debug output:

// to grab debug output set DEBUG=esw:*
  esw:internal-settings Eslint installed locally node_modules/.bin/eslint +0ms
  esw:internal-settings { eslintPath: 'node_modules/.bin/eslint',
  esw:internal-settings   platform: 'linux',
  esw:internal-settings   isWindows: false } +2ms
  esw:eslint-cli Loaded +0ms
  esw:eslint-help Loaded +0ms
  esw:options Loaded +0ms
  esw:eslint-help Executing help +1ms
  esw:eslint-cli eslint: '--help' +18ms
  esw:executor node_modules/.bin/eslint [ '--help' ] +0ms
  esw:eslint-cli { exitCode: 0,
  esw:eslint-cli   message: 'eslint [options] file.js [file.js] [dir]\n\nBasic configuration:\n  --no-eslintrc                  Disable use of configuration from .eslintrc.*\n  -c, --config path::String      Use this configuration, overriding .eslintrc.* config options if present\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\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\nFixing problems:\n  --fix                          Automatically fix problems\n  --fix-dry-run                  Automatically fix problems without saving the changes to the file system\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 <STDIN> - 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\nInline configuration comments:\n  --no-inline-config             Prevent comments from changing config or rules\n  --report-unused-disable-directives  Adds reported errors for unused eslint-disable directives\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\nMiscellaneous:\n  --init                         Run config initialization wizard - default: false\n  --debug                        Output debugging information\n  -h, --help                     Show help\n  -v, --version                  Output the version number\n  --print-config path::String    Print the configuration for the given file\n' } +210ms
  esw:eslint-help Parsing --no-eslintrc +212ms
  esw:eslint-help Parsing no option --no-eslintrc +1ms
  esw:eslint-help Alias found: -c +0ms
  esw:eslint-help Parsing --config +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 --rulesdir +0ms
  esw:eslint-help Parsing --plugin +0ms
  esw:eslint-help Parsing --rule +0ms
  esw:eslint-help Parsing --fix +1ms
  esw:eslint-help Parsing --fix-dry-run +0ms
  esw:eslint-help Parsing --ignore-path +0ms
  esw:eslint-help Parsing --no-ignore +0ms
  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 +1ms
  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 +0ms
  esw:eslint-help Parsing --format +0ms
  esw:eslint-help Parsing --no-inline-config +0ms
  esw:eslint-help Parsing no option --no-inline-config +0ms
  esw:eslint-help Parsing --report-unused-disable-directives +0ms
  esw:eslint-help Parsing --cache +0ms
  esw:eslint-help Parsing --cache-file +0ms
  esw:eslint-help Parsing --cache-location +1ms
  esw:eslint-help Parsing --init +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 +0ms
  esw:eslint-help Parsing --print-config +0ms
  esw:watcher Loaded +0ms
  esw:arg-parser Loaded +0ms
  esw:esw-cli Loaded +0ms
  esw:esw-cli Eslint-Watch: 3.1.3 +0ms
  esw:esw-cli Arguments passed: [ '/usr/local/bin/node', '/root/project/node_modules/.bin/esw', './', '--cache', '--ext', '.js', '-w', '--color' ] +0ms
  esw:esw-cli Parsing args +2ms
  esw:arg-parser Directories to check: [ './' ] +4ms
  esw:arg-parser Args [ './', '--cache', '--ext', '.js', '-w', '--color' ] +0ms
  esw:arg-parser Pushing item: ./ +0ms
  esw:arg-parser Pushing item: --cache +0ms
  esw:arg-parser Pushing item: --ext +0ms
  esw:arg-parser Pushing item: .js +1ms
  esw:arg-parser Pushing item: --color +0ms
  esw:arg-parser setting custom formatter +0ms
  esw:arg-parser GetPath: simple-detail +0ms
  esw:arg-parser /root/project/node_modules/eslint-watch/build/formatters/simple-detail +0ms
  esw:esw-cli Running initial lint +2ms
  esw:esw-cli [ './',
  esw:esw-cli   '--cache',
  esw:esw-cli   '--ext',
  esw:esw-cli   '.js',
  esw:esw-cli   '--color',
  esw:esw-cli   '-f',
  esw:esw-cli   '/root/project/node_modules/eslint-watch/build/formatters/simple-detail' ] +0ms
  esw:eslint-cli eslint: './ --cache --ext .js --color -f /root/project/node_modules/eslint-watch/build/formatters/simple-detail' +142ms
  esw:executor node_modules/.bin/eslint [ './',
  '--cache',
  '--ext',
  '.js',
  '--color',
  '-f',
  '/root/project/node_modules/eslint-watch/build/formatters/simple-detail' ] +350ms
  esw:simple-detail loaded +0ms
  esw:simple-detail [ { filePath: '/root/project/.eslintrc.js',
  esw:simple-detail     messages: [],
  esw:simple-detail     errorCount: 0,
  esw:simple-detail     warningCount: 0,
  esw:simple-detail     fixableErrorCount: 0,
  esw:simple-detail     fixableWarningCount: 0 },
  // too many detail, I remove those.
✓ Clean (17:21:21)
  esw:eslint-cli { exitCode: 0, message: '' } +2s
  esw:esw-cli lint completed. Exit Code: 0 +2s

  esw:esw-cli -w seen +2ms
  esw:watcher { useEslintrc: true,
  esw:watcher   extensions: [ '.js' ],
  esw:watcher   cache: true,
  esw:watcher   ignore: true,
  esw:watcher   format: 'simple-detail' } +2s
  esw:watcher { cache: true,
  esw:watcher   ext: [ '.js' ],
  esw:watcher   watch: true,
  esw:watcher   color: true,
  esw:watcher   format: 'simple-detail',
  esw:watcher   eslintrc: true,
  esw:watcher   ignore: true,
  esw:watcher   inlineConfig: true,
  esw:watcher   _: [ './' ] } +0ms
  esw:watcher Trying to load formatter for re-lint from ./formatters/simple-detail +12ms
  esw:simple-detail loaded +0ms
  esw:watcher Watching: [ './' ] +15ms
rizowski commented 6 years ago

@HsuTing I need the debug output. What is the base image are you trying to run this on?

HsuTing commented 6 years ago

@rizowski I added the debug output in description. I do not know OS. I just use node:latest in docker. I saw the Dockerfile of node:latest, and I think OS is debian:jessie.

rizowski commented 6 years ago

What is the steps to reproduce this? Are you editing files from a volume or inside the container directly?

HsuTing commented 6 years ago

I am just editing one file inside the container directly.

HsuTing commented 6 years ago

Oh, I use docker in win 10. Do this impact the watch?

rizowski commented 6 years ago

Technically it shouldn't matter that docker is on windows. Because you are running everything inside the container and not using a volume. So it should be isolated.

HsuTing commented 6 years ago

I know. I just want to give more detail to you.

rizowski commented 6 years ago

This is what I am using to test the problem. I copied over the files from tests/integration/test-files and modify one of these files to try to trigger the file changed event. I wasn't able to get it to fire.

FROM node:latest

ENV DEBUG="esw:*"
RUN mkdir /var/app
WORKDIR /var/app

RUN apt-get update
RUN apt-get install -y vim
RUN npm i -g eslint-watch eslint

COPY test .
COPY package.json .

RUN npm i

CMD esw ./ --cache --ext .js -w --color
HsuTing commented 6 years ago

I use another way to test.

  1. docker run -it node:latest /bin/bash
  2. git clone <eslint-watch repo>
  3. apt update and apt install -y vim
  4. npm i -g eslint eslint-watch
  5. Copy tests and package.json to new folder, and run npm i in new folder.
  6. esw ./ --cache --ext .js -w --color
  7. Open a new CMD and run docker exec -it <container id> bash.
  8. Edit files in tests.

This does not work again. Is exec to make this bug?