SOLVED: Linters for extension development?

I’ve been wrestling with writing an extension and I think a linter/validator of some sort could be quite helpful when developing a browser extension.

If it finds errors it could point to relevant documentation.

It could check things in manifest.json:

  • required fields
  • disallowed fields
  • invalid values for matches for example
  • not requiring remote files (JS on CDNs for example)
  • when declaring a local resource: checking that it’s actually there

For content scripts:

  • not using browser extension APIs that are not available in content scripts

For background scripts:

  • making sure (somehow) that the code is (more) async

Etcetera.

I searched but couldn’t find anything like this. Does anyone know of something like this existing?

Wrt creating such a tool, I’m thinking JS is probably a good candidate to create it as I assume a lot of people that want to create extensions have npm installed, right?

Any feedback: please :pray:

Check out web-ext lint, which is a sub command of web-ext:

You can also get the raw linter:

2 Likes

@freaktechnik thank you! Exactly what I was looking for.

For other’s sake, to get this you basically:

$ npm install --global web-ext 
$ cd path/to/extension/directory
$ web-ext lint