question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eslint with --rule option not working properly

See original GitHub issue

Steps to reproduce

Here is a example repo: https://github.com/tgreen7/lint-staged-eslint-rule

if you modify index.js, git add index.js, and run yarn precommit then no errors will be logged. However, if you uncomment the line quotes: [2, 'double'] in the .eslintrc.js file and re-run the precommit then the error will be logged.

Also you can try to run yarn lint, which adds that rule in the same way as the precommit, and it does get linted properly.

If I am passing that same rule to the precommit through the eslint --rule option then why is it not getting picked up while running?

Debug Logs

expand to view
[taoh:.../lint-staged-test] ❯ ./node_modules/.bin/lint-staged --debug                                                   ✚ :: master  :: ⬡
  lint-staged:bin Running `lint-staged@7.0.0` +0ms
  lint-staged Loading config using `cosmiconfig` +0ms
  lint-staged Successfully loaded config from `/Users/taoh/Sites/lint-staged-test/package.json`:
  lint-staged { 'index.js': [ 'eslint --rule \'quotes: [2, double]\'' ] } +3ms
  lint-staged:cfg Normalizing config +0ms
  lint-staged:cfg Validating config +2ms
Running lint-staged with the following config:
{
  linters: {
    'index.js': [
      'eslint --rule \'quotes: [2, double]\''
    ]
  },
  concurrent: true,
  chunkSize: 9007199254740991,
  globOptions: {
    matchBase: true,
    dot: true
  },
  ignore: [],
  subTaskConcurrency: 1,
  renderer: 'verbose'
}
  lint-staged:run Running all linter scripts +0ms
  lint-staged:run Resolved git directory to be `/Users/taoh/Sites/lint-staged-test` +1ms
  lint-staged:run Loaded list of staged files in git:
  lint-staged:run [ 'index.js' ] +28ms
  lint-staged:gen-tasks Generating linter tasks +0ms
  lint-staged:cfg Normalizing config +35ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks { pattern: 'index.js',
  lint-staged:gen-tasks   commands: [ 'eslint --rule \'quotes: [2, double]\'' ],
  lint-staged:gen-tasks   fileList: [ '/Users/taoh/Sites/lint-staged-test/index.js' ] } +2ms
Running tasks for index.js [started]
  lint-staged:run-script Running script with commands [ 'eslint --rule \'quotes: [2, double]\'' ] +0ms
  lint-staged:cfg Normalizing config +5ms
eslint --rule 'quotes: [2, double]' [started]
  lint-staged:find-bin Resolving binary for command `eslint --rule 'quotes: [2, double]'` +0ms
  lint-staged:find-bin Binary for `eslint --rule 'quotes: [2, double]'` resolved to `/Users/taoh/Sites/lint-staged-test/node_modules/.bin/eslint` +3ms
  lint-staged:run-script bin: /Users/taoh/Sites/lint-staged-test/node_modules/.bin/eslint +5ms
  lint-staged:run-script args: [ '--rule',
  lint-staged:run-script   '\'quotes:',
  lint-staged:run-script   '[2,',
  lint-staged:run-script   'double]\'',
  lint-staged:run-script   '/Users/taoh/Sites/lint-staged-test/index.js' ] +0ms
  lint-staged:run-script opts: { reject: false } +1ms
eslint --rule 'quotes: [2, double]' [completed]
Running tasks for index.js [completed]
  lint-staged linters were executed successfully! +549ms

Environment

  • OS: macOS High Sierra
  • Node.js: v9.8.0
  • lint-staged: v7.0.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
okonetcommented, Mar 31, 2018

@tgreen7 BTW thanks for the pointer! I just realized how to use this option to better integrate prettier with eslint so it’s less annoying during dev 👍

0reactions
tgreen7commented, Apr 4, 2018

Thanks! Double quotes works 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with Rules - ESLint - Pluggable JavaScript Linter
"problem" means the rule is identifying code that either will cause an error or may cause a ... Some rules require options in...
Read more >
ESLint not working in VS Code? - Stack Overflow
I have the plugin installed in VS Code, and ESLint itself as a developer dependency in my package.json, which I have installed as...
Read more >
ESLint not working in VSCode? Help build a troubleshooting ...
Open the command palette by pressing Ctrl / Cmd + Shift + P and select 'ESLint: Show Output Channel'. If ESLint throws any...
Read more >
ESLint | IntelliJ IDEA Documentation - JetBrains
To resolve the detected problem, click ESLint: Fix '<rule name>' or press Alt+Shift+Enter . To resolve all the detected problems in the current...
Read more >
eslint - npm
Start using eslint in your project by running `npm i eslint`. ... A new option to an existing rule that does not result...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found