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.

--fix converts to backtick, then valid-typeof reports error

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.5.0
  • Node Version: 6.5.0
  • npm Version: 3.10.3

What parser (default, Babel-ESLint, etc.) are you using? “babel-eslint”: “6.1.2”

Please show your full configuration: .eslintrc.json:

{
  "parser": "babel-eslint",
  "extends": "airbnb",
  "env": {
    "node": true
  },
  "globals": {
    "emit": true,
    "doc": true
  },
  "plugins": [
      "react"
  ],
  "rules": {
    "react/require-extension": "off",
    "linebreak-style": ["error", "windows"],
    "react/jsx-sort-props": 0,
    "react/jsx-no-bind": 0,
    "comma-dangle": 0,
    "no-use-before-define": 0,
    "consistent-return": 0,
    "semi": [2, "never"],
    "quotes": ["error", "backtick"],
    "strict": 0,
    "max-len": ["error", 120, 2, {"ignoreUrls": true}],
    "no-param-reassign": ["error", { "props": false }]
  }
}

package.json:

{
  "name": "apflora",
  "version": "1.0.1",
  "description": "Aktionsplan Flora Kt. Zürich Backend",
  "main": "server.js",
  "dependencies": {
    "ampersand-app": "^2.0.0",
    "async": "2.0.1",
    "dateformat": "1.0.12",
    "hapi": "15.0.3",
    "hapi-node-postgres": "4.0.1",
    "inert": "4.0.2",
    "json2csv": "3.6.3",
    "json2xls": "0.1.2",
    "lodash": "4.15.0",
    "pg": "6.1.0",
    "pg-promise": "^5.3.3",
    "request": "2.74.0",
    "underscore": "1.8.3"
  },
  "devDependencies": {
    "babel-eslint": "6.1.2",
    "code": "3.0.2",
    "del": "2.2.2",
    "eslint": "3.5.0",
    "eslint-config-airbnb": "11.1.0",
    "eslint-plugin-import": "1.15.0",
    "eslint-plugin-jsx-a11y": "2.2.2",
    "eslint-plugin-react": "6.2.1",
    "gulp": "3.9.1",
    "gulp-sftp": "0.1.5",
    "lab": "11.0.1",
    "require-dir": "0.3.0",
    "run-sequence": "1.2.2"
  },
  "scripts": {
    "start": "npm test && node startServer.js",
    "startWithoutTests": "node startServer.js",
    "predeploy": "gulp prod_clean_dist",
    "deploy": "gulp prod_copy",
    "postdeploy": "gulp prod_sftp",
    "test": "eslint src --fix && lab",
    "yolo": "npm run deploy"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/FNSKtZH/apflora_api.git"
  },
  "keywords": [
    "apflora",
    "aktionsplan",
    "flora",
    "species",
    "conservation"
  ],
  "author": "Alexander Gabriel",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/FNSKtZH/apflora/issues"
  },
  "homepage": "https://github.com/FNSKtZH/apflora"
}

What did you do? Please include the actual source code causing the issue.

I added

"quotes": ["error", "backtick"]

to .eslintrc and

eslint src --fix to the scripts in package.json

after reading this

What did you expect to happen?

' to be replaced by backtips ONLY where applicable (as like: not in 'use strict'). OR: Other rules not to complain about where --fix sets backtips.

What actually happened? Please include the actual, raw output from ESLint.

this code:

'use strict'

module.exports = (string) => {
  if (string && typeof string === `string`) {
    // does something
  }
}

produced this error:

C:\Users\alex\apflora_api\src\removeKmlNogoStrings.js
  10:35   error  Typeof comparisons should be to string literals  valid-typeof

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, Sep 16, 2016

It seems like the bug here is that valid-typeof doesn’t allow comparisons to template literals.

typeof foo === `string`

should not cause an error to be reported.

0reactions
not-an-aardvarkcommented, Sep 16, 2016

See #7168

Read more comments on GitHub >

github_iconTop Results From Across the Web

Usage of the backtick character (`) in JavaScript - Stack Overflow
We can use the spread operator here to pass multiple values. The first argument—we called it strings—is an array of all the plain...
Read more >
demo-outil-edition - node_modules - eslint - CHANGELOG.md
(#9003) (薛定谔的猫); 3d020b9 Update: emit a warning for ecmaFeatures rather than throwing an error (#8974) (Teddy Katz); d2f8f9f Fix: ...
Read more >
Diff - 402e1b6e55e9041dfd1a93580e45e5c5dba1db55^!
init fix checklicenses.py errors add OWNERS automatically rename license ... Fix: `strict` rule reports a syntax error for ES2016 (fixes ...
Read more >
Code Issues - Embold Help Center
Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable, Exception, or Error, use a subclassed exception or error instead.
Read more >
Orion/ESLint - Eclipsepedia
These rules report about problems with your code that might have ... Fix All? ... valid-typeof, Error, 7.0, Invalid 'typeof' comparison ...
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