Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol: Unexpected literal in error position of callback #9685

Closed
Zyles opened this issue Jun 6, 2017 · 2 comments
Closed

Protocol: Unexpected literal in error position of callback #9685

Zyles opened this issue Jun 6, 2017 · 2 comments

Comments

@Zyles
Copy link

Zyles commented Jun 6, 2017

https://electron.atom.io/docs/api/protocol/

  • Electron version: 1.7.2
  • Operating system: Win 10

Expected behavior

No errors.

Actual behavior

Errors:

 https://google.com/#q=standard%2Fno-callback-literal  Unexpected literal in error position of callback
    src\main\index.js:48:5
        callback({path: path.normalize(`${__dirname}/${url}`)})

How to reproduce

Do exactly like the docs.

@MarshallOfSound
Copy link
Member

@Zyles That is a standard linting error as callback's in a node.js world typically are of the format

callback(error, result)

In this API's case it is simply

callback(result)

and standard doesn't like it, you should either add an exception or disable that rule. This isn't an error with Electron 👍

@disarticulate
Copy link

disarticulate commented Aug 7, 2017

Incase anyone can't figure out how to ignore this:

  protocol.registerFileProtocol('h5p', (request, callback) => {
    const url = request.url.substr(7)
    // eslint-disable-next-line
    callback({ path: path.normalize(`${url}`) })
  }, (error) => {
    if (error) console.error('Failed to register protocol')
  })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants