# SOLVED: Linters for extension development?

**URL:** <https://discourse.mozilla.org/t/solved-linters-for-extension-development/40958>\
**Category:** Development\
**Created:** [May 30, 2019, 9:44am UTC](https://discourse.mozilla.org/t/solved-linters-for-extension-development/40958 "2019-05-30T09:44:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![niels](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/niels/32/27799_2.png) [@niels](https://discourse.mozilla.org/u/niels)\
**Post date:** [May 30, 2019, 9:44am UTC](https://discourse.mozilla.org/t/solved-linters-for-extension-development/40958/1 "2019-05-30T09:44:10Z")

</div>

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 🙏

---

<div class="post-metadata">

**Author:** ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)\
**Post date:** [May 30, 2019, 9:49am UTC](https://discourse.mozilla.org/t/solved-linters-for-extension-development/40958/2 "2019-05-30T09:49:04Z")

</div>

Check out [`web-ext lint`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/web-ext_command_reference#web-ext_lint), which is a sub command of web-ext:

> **[web-ext](https://www.npmjs.com/package/web-ext)**
>
> A command line tool to help build, run, and test web extensions. Latest version: 8.3.0, last published: 4 months ago. Start using web-ext in your project by running \`npm i web-ext\`. There are 29 other projects in the npm registry using web-ext.

You can also get the raw linter:

> **[addons-linter](https://www.npmjs.com/package/addons-linter)**
>
> Mozilla Add-ons Linter. Latest version: 7.8.0, last published: 10 days ago. Start using addons-linter in your project by running \`npm i addons-linter\`. There are 5 other projects in the npm registry using addons-linter.

---

<div class="post-metadata">

**Author:** ![niels](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/niels/32/27799_2.png) [@niels](https://discourse.mozilla.org/u/niels)\
**Post date:** [May 30, 2019, 11:17am UTC](https://discourse.mozilla.org/t/solved-linters-for-extension-development/40958/3 "2019-05-30T11:17:06Z")

</div>

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

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

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

```
