Skip to content

Commit ca73b70

Browse files
authored
chore: Add Prettier (#2506)
* feat: add prettier config * style: Prettier all the things! * fix: slightly update ESLint config now that we have Prettier Some rules are just not relevant anymore. I would think most of them but let's be conservative. I only removed the ones that reported (stylistic) problems. * feat: add a Prettier check in CI * fix: re-position some $FlowIgnore comments
1 parent b6a546a commit ca73b70

File tree

96 files changed

+7312
-6830
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+7312
-6830
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ jobs:
195195
condition:
196196
equal: [*nodejs_current, << parameters.nodejs >>]
197197
steps:
198+
- run: npm run prettier-ci
198199
- run:
199200
name: run linting check and unit tests with coverage
200201
command: npm run test-coverage

.eslintrc

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,8 @@
5454
"dot-notation": [2, {"allowKeywords": true}],
5555
"eqeqeq": [2, "allow-null"],
5656
"guard-for-in": 0,
57-
"indent": [2, 2, {
58-
"CallExpression": {
59-
"arguments": "first"
60-
},
61-
"SwitchCase": 1,
62-
"VariableDeclarator": 1,
63-
"outerIIFEBody": 1,
64-
"MemberExpression": 1,
65-
"FunctionDeclaration": {
66-
"parameters": 1,
67-
"body": 1
68-
},
69-
"FunctionExpression": {
70-
"parameters": 1,
71-
"body": 1
72-
}
73-
}],
7457
"key-spacing": 2,
7558
"keyword-spacing": 2,
76-
"max-len": [2, 80, 2, {"ignoreComments": true}],
7759
"new-cap": [2, {"capIsNewExceptions": ["Deferred"]}],
7860
"no-bitwise": 2,
7961
"no-caller": 2,
@@ -119,16 +101,10 @@
119101
"one-var": [2, "never"],
120102
"prefer-const": 2,
121103
"prefer-template": 2,
122-
"quote-props": [1, "consistent-as-needed"],
123104
"quotes": [2, "single", "avoid-escape"],
124105
"require-yield": 2,
125106
"semi": [2, "always"],
126107
"space-before-blocks": [2, "always"],
127-
"space-before-function-paren": [2, {
128-
"anonymous": "never",
129-
"named": "never",
130-
"asyncArrow": "always"
131-
}],
132108
"space-infix-ops": 2,
133109
"strict": [2, "never"],
134110
"valid-typeof": 2,

.prettierignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# exclude everything by default
2+
*.*
3+
4+
# exclude these files
5+
package-lock.json
6+
LICENSE
7+
8+
# exclude these directories
9+
/artifacts/
10+
/coverage/
11+
/flow-typed/
12+
/lib/
13+
/node_modules/
14+
/tests/fixtures/
15+
16+
# allow files we want to process
17+
!*.js
18+
!*.md

.prettierrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"arrowParens": "always",
3+
"singleQuote": true,
4+
"proseWrap": "never",
5+
"overrides": [
6+
{
7+
"files": "scripts/*",
8+
"options": {
9+
"parser": "babel"
10+
}
11+
},
12+
{
13+
"files": "*.md",
14+
"options": {
15+
"proseWrap": "preserve"
16+
}
17+
}
18+
]
19+
}

CONTRIBUTING.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ development more awesome by contributing to the `web-ext` tool. Here are links t
1010
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
1111
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
1212

13-
1413
- [Picking an issue](#picking-an-issue)
1514
- [Installation](#installation)
1615
- [Develop all the things](#develop-all-the-things)
@@ -36,8 +35,6 @@ development more awesome by contributing to the `web-ext` tool. Here are links t
3635

3736
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
3837

39-
40-
4138
# Picking an issue
4239

4340
If you're looking for a small task to work on so you can get familiar with the
@@ -46,7 +43,6 @@ process of contributing patches, have a read through these
4643

4744
If you'd like to work on a bug, please comment on it to let the maintainers know. If someone else has already commented and taken up that bug, please refrain from working on it and submitting a PR without asking the maintainers as it leads to unnecessary duplication of effort.
4845

49-
5046
# Installation
5147

5248
To get started on a patch, first install `web-ext` from [source](README.md#installation-from-source).
@@ -230,18 +226,19 @@ This section will show you how to add a new commands and options.
230226
their options. The commands are defined in `src/program.js` in the `main` function.
231227
For example, the `build` command is defined like this:
232228

233-
````javascript
234-
program
235-
.command(
236-
'build',
237-
'Create a web extension package from source',
238-
commands.build, {
239-
'as-needed': {
240-
describe: 'Watch for file changes and re-build as needed',
241-
type: 'boolean',
242-
},
243-
})
244-
````
229+
```javascript
230+
program.command(
231+
'build',
232+
'Create a web extension package from source',
233+
commands.build,
234+
{
235+
'as-needed': {
236+
describe: 'Watch for file changes and re-build as needed',
237+
type: 'boolean',
238+
},
239+
}
240+
);
241+
```
245242

246243
The first argument to `program.command()` is the command name, the second is the
247244
description (shown for `--help`), the third is a callback that executes the
@@ -257,20 +254,21 @@ converted from hyphenated words to [camelCase](https://en.wikipedia.org/wiki/Cam
257254
words. So, the
258255
`--as-needed` and `--source-dir` options would be passed like:
259256

260-
````javascript
261-
commands.build({asNeeded: true, sourceDir: './src/extension'})
257+
```javascript
258+
commands
259+
.build({ asNeeded: true, sourceDir: './src/extension' })
262260
.then((result) => {
263261
// ...
264262
});
265-
````
263+
```
266264

267265
### Adding a command option
268266

269267
To add a command option, locate the relevant command definition (i.e. `run`)
270268
and specify a new option definition as an object.
271269
Here is an example of adding the `--file-path` option:
272270

273-
````javascript
271+
```javascript
274272
program
275273
// other commands...
276274
.command('run', 'Run the web extension', commands.run, {
@@ -282,8 +280,8 @@ program
282280
requiresArg: true,
283281
type: 'string',
284282
},
285-
})
286-
````
283+
});
284+
```
287285

288286
This option can be used like `web-ext run --file-path=./path/to/file` or
289287
`--fp=./path/to/file`. Since Yargs can be pretty powerful yet not completely
@@ -299,22 +297,23 @@ to use a development version of the
299297
[signing API](http://addons-server.readthedocs.io/en/latest/topics/api/signing.html)
300298
so as not to disturb any real `addons.mozilla.org` data.
301299

302-
* Read through how to use the
300+
- Read through how to use the
303301
[web-ext sign](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext#Distributing_your_own_WebExtension)
304302
command so you understand it.
305-
* Create an API key on the development version of the
303+
- Create an API key on the development version of the
306304
[Manage API Keys](https://addons-dev.allizom.org/en-US/developers/addon/api/key/)
307305
page. You will need to register an account if you don't have one already. Make
308306
sure you use a password that is different from your production account.
309-
* Let's say your generated *JWT issuer* is `user:123` and your *JWT secret* is
307+
- Let's say your generated _JWT issuer_ is `user:123` and your _JWT secret_ is
310308
`abc1234`. Here is an example of a command you can run that will use the
311309
development API:
312310

313-
````
311+
```
314312
web-ext sign --api-key user:123 --api-secret abc1234 \
315313
--api-url-prefix https://addons-dev.allizom.org/api/v4
316-
````
317-
* Signed add-ons created with the development API are hard to install into
314+
```
315+
316+
- Signed add-ons created with the development API are hard to install into
318317
Firefox. If you need to test installation of add-ons (you probably don't)
319318
then you'd have to use our staging API server. File an issue for information
320319
on that.
@@ -331,7 +330,7 @@ this at the top of your description:
331330
Fixes #123
332331

333332
The issue number in this case is "123."
334-
The word *Fixes* is magical; github will automatically close the issue when your
333+
The word _Fixes_ is magical; github will automatically close the issue when your
335334
pull request is merged.
336335

337336
## Writing commit messages
@@ -343,14 +342,15 @@ Additionally, write the commit message in past tense so it will read
343342
naturally as a historic changelog.
344343

345344
Examples:
346-
* `feat: Added a systematic dysfunctioner`
347-
* `fix: Fixed hang in systematic dysfunctioner`
348-
* `docs: Improved contributor docs`
349-
* `style: Added no-console linting, cleaned up code`
350-
* `refactor: Split out dysfunctioner for testability`
351-
* `perf: Systematic dysfunctioner is now 2x faster`
352-
* `test: Added more tests for systematic dysfunctioner`
353-
* `chore: Upgraded yargs to 3.x.x`
345+
346+
- `feat: Added a systematic dysfunctioner`
347+
- `fix: Fixed hang in systematic dysfunctioner`
348+
- `docs: Improved contributor docs`
349+
- `style: Added no-console linting, cleaned up code`
350+
- `refactor: Split out dysfunctioner for testability`
351+
- `perf: Systematic dysfunctioner is now 2x faster`
352+
- `test: Added more tests for systematic dysfunctioner`
353+
- `chore: Upgraded yargs to 3.x.x`
354354

355355
If you want to use scopes then it would look more like:
356356
`feat(dysfunctioner): Added --quiet option`.
@@ -364,23 +364,23 @@ each time you commit to your work branch to make continuous integration smoother
364364

365365
To release a new version of `web-ext`, follow these steps:
366366

367-
* Pull from master to make sure you're up to date.
368-
* Bump the version in `package.json`.
369-
* Commit and push the version change
367+
- Pull from master to make sure you're up to date.
368+
- Bump the version in `package.json`.
369+
- Commit and push the version change
370370
(or create and merge a pull request for it).
371-
* Create a changelog by running `npm run changelog`.
371+
- Create a changelog by running `npm run changelog`.
372372
This will output Markdown of all unreleased changes.
373-
* Create a [new release](https://github.com/mozilla/web-ext/releases/new)
373+
- Create a [new release](https://github.com/mozilla/web-ext/releases/new)
374374
and paste in the changelog Markdown.
375375
It may require some manual editing. For example, some commit messages
376376
might have been truncated.
377377
Title the github release after the new version you just
378378
added to `package.json` in the previous commit (example: `1.0.4`).
379-
* When you publish the release, github creates a tag.
379+
- When you publish the release, github creates a tag.
380380
When TravisCI builds the tag,
381381
it will automatically publish the package to
382382
[npm](https://www.npmjs.com/package/web-ext).
383-
* After the package has been published, check the
383+
- After the package has been published, check the
384384
[needs: docs](https://github.com/mozilla/web-ext/issues?utf8=%E2%9C%93&q=is%3Aclosed%20label%3A%22needs%3A%20docs%22%20)
385385
label to see if
386386
[the user docs](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext)
@@ -398,4 +398,4 @@ If the issue you're working on involves changing any of the headings in this doc
398398
before making a commit and submitting a pull request, please remember to update the table of contents.
399399
To update the TOC, run the command `npm run gen-contributing-toc` from your root directory and you will auto generate a new TOC.
400400

401-
[Flow]: http://flowtype.org/
401+
[flow]: http://flowtype.org/

ISSUE_TEMPLATE.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### Is this a feature request or a bug?
22

3-
43
### What is the current behavior?
4+
55
<!--
66
* If this is a bug, please explain how to reproduce the problem and
77
include the `web-ext` commands you ran.
@@ -10,16 +10,14 @@
1010
* Upload a zip file of your web extension source if necessary.
1111
-->
1212

13-
1413
### What is the expected or desired behavior?
1514

16-
1715
### Version information (for bug reports)
1816

19-
* **Firefox version**:
20-
* **Your OS and version**:
21-
* Paste the output of these commands:
17+
- **Firefox version**:
18+
- **Your OS and version**:
19+
- Paste the output of these commands:
2220

23-
````
21+
```
2422
node --version && npm --version && web-ext --version
25-
````
23+
```

0 commit comments

Comments
 (0)