Questions tagged [eslint]

The pluggable linting utility for JavaScript and related frameworks.

ESLint is a JavaScript linting tool.

It differs from other linters in that every rule is a separate plugin and you can add more during runtime.

User interface

ESLint is a CLI tool and runs directly from a terminal/command prompt. It may be used as a standalone tool or integrated with an automated task runner such as Grunt (through plugins such as eslint-grunt and grunt-eslint). It can also be integrated with majority of modern editors that support JavaScript. For the list of integrations see ESLint site

Resources


See also

6637 questions
4
votes
1 answer

How to fix import / no-unresolved eslint to look at package.json "module" instead of "main"

I'm currently importing a yarn workspace package that has the module field defined in ES6 and linting with the plugin eslint-plugin-import My create-react-app setup automatically uses the module through webpack but eslint is complaining that…
Kenneth Truong
  • 3,882
  • 3
  • 28
  • 47
4
votes
1 answer

Rollup and eslint : How can I fix this error "TypeError: eslint is not a function" using eslint with rollup?

I'm trying to use rollup for the first time and I can't figure out why I get this error : TypeError: eslint is not a function I previously installed rollup (v1.1.0) then eslint npm install rollup-plugin-eslint (v5.0.0) here is my…
Anne Claire
  • 403
  • 5
  • 10
4
votes
1 answer

Failed to load config "plugin:vue/no-layout-rules" to extend from

I keep getting the error in the title when i try build or serve the vuejs build. Not quite sure on what "no-layout-rules" is about. The only reference to it that I could find was on eslint repo here:…
Vlad Vladimir Hercules
  • 1,781
  • 2
  • 20
  • 37
4
votes
4 answers

How do I automatically check for '.only' calls accidentally left in Mocha specs?

I occasionally forget to remove .only calls from my Mocha specs before pushing spec changes. Doing so obviously affects test coverage, which requires addressing the failure(s). I'd like to catch these before I push changes, ideally as part of the…
user3006381
  • 2,735
  • 3
  • 23
  • 32
4
votes
3 answers

Unable to turn off eslint no-unused-expressions

I have created an app with create-react-app and I have applied the airbnb rules. The app also contains redux and flow. The following code is throwing the no-unused-expressions error in eslint: const reducer = (state: string = '', action: Action) =>…
Luca Borrione
  • 16,324
  • 8
  • 52
  • 66
4
votes
2 answers

How to export constants defined using object destructuring

Guided by eslint's prefer-destructuring rule, I defined some constants like this: const { NODE_ENV, API_URL, } = process.env; Is it possible to export these constants by prefixing the statement by export? export const { NODE_ENV, …
Claudio
  • 3,089
  • 2
  • 18
  • 22
4
votes
1 answer

How to use ESLint for vue template placed in separate html file

Imagine you have "SFC" with template like this: And imagine you have working prettier/eslint setup and you can lint any of your files with…
Maksim Nesterenko
  • 5,661
  • 11
  • 57
  • 91
4
votes
3 answers

eslint Warning Unexpected unnamed async function , anyway to get rid if it?

When I defined my async function as : module.exports.sendSmtpMessage = async function(keys, mailOptions) { // <== warning await sendSmtpMessage(keys, mailOptions); } var sendSmtpMessage = async function(keys, mailOptions) { ... } update2 var…
user762579
4
votes
2 answers

Setup pre-push hook with Husky to prevent pushing to master branch

Is it possible to setup pre-push hook with Husky to prevent pushing to master by mistake?? Husky documentation is very poor so I couldn't find the answer. Right now I have husky set for committing and pushing like this: "husky": { "hooks": { …
p7adams
  • 622
  • 1
  • 9
  • 24
4
votes
0 answers

How do I tell ESLint that another file is included before the current one?

As I'm setting up ESLint for the first time, I'm a little confused about how it deals with globals. I've got 40+ js files, (one js file per page in a CRM like application), and some of them are quite long, like 3-4k+ lines. And these JS files share…
Brian Leishman
  • 8,155
  • 11
  • 57
  • 93
4
votes
1 answer

ESLint to parse and verify JSDoc

Say I have this piece of code: /** @type {string} */ const foo = '123'; const bar = foo.map((c) => c + 1); Then I'd like ESLint to tell me I've got an error here: map is not a function of a string type I use WebStorm as my IDE and it recognizes the…
YardenST
  • 5,119
  • 2
  • 33
  • 54
4
votes
2 answers

eslint `forbid-prop-types` rule cause a warning in firefox console window

As the document says here array and object can be replaced with arrayOf and shape, respectively. So, I did this in my project: class X extends React.Component { .... } X.propTypes = { somePorp: PropTypes.shape.isRequired, // this cause an…
Hacksign
  • 416
  • 2
  • 7
  • 17
4
votes
2 answers

when image tag role be set button jsx-a11y show warning

I need make image tag clickable, but I get a warning by jsx-a11y, how do I fixed it, I already read no-noninteractive-element-interactions, but I do not wanna wrap other div tag around img tag, because it will make a redundancy tag, so does any…
Roy
  • 731
  • 3
  • 10
  • 24
4
votes
1 answer

How to use flat nested ternaries with ESLint?

I have some code like this: let upgrade; if (device.firmwareV !== latestFirmware.version) { upgrade = "Firmware is up to date."; } else if (!firmUpTool) { upgrade = "Cannot upgrade the firmware through this connection."; } else if…
James
  • 5,635
  • 2
  • 33
  • 44
4
votes
1 answer

How to ESlint a string on the client?

I am building a in-browser IDE and am looking for a way to run ESlint on the JS code my users are writing. I am using react and the code that was written is stored in the state as a string. Is there any tool to just take that string and execute…
Divide by Zero
  • 1,343
  • 1
  • 14
  • 37
1 2 3
99
100