Skip to content

Commit dc21743

Browse files
Add prettier and eslint (GoogleChrome#831)
* Ignores archived samples * Uses eslint/recommended rules * Runs prettier and eslint (including --fix) pre-commit via husky * Adds new npm scripts: 'lint', 'lint:fix' and 'prettier' * Does not lint inline js code * Fix all prettier and eslint errors * Add custom prettier rules * Apply custom prettier rules * Update readme to explain how to setup the repo * addressed comments
1 parent 299f213 commit dc21743

Some content is hidden

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

83 files changed

+4827
-1103
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_archive
2+
third-party
3+
node_modules

.eslintrc.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* eslint-env node */
2+
module.exports = {
3+
extends: ['prettier', 'eslint:recommended'],
4+
plugins: ['prettier'],
5+
rules: {
6+
'prettier/prettier': ['error'],
7+
'no-unused-vars': [
8+
'warn',
9+
{
10+
argsIgnorePattern: '^_',
11+
varsIgnorePattern: '^_'
12+
}
13+
]
14+
},
15+
env: {
16+
browser: true,
17+
webextensions: true,
18+
es2021: true,
19+
jquery: true,
20+
worker: true
21+
},
22+
overrides: [],
23+
parserOptions: {
24+
ecmaVersion: 'latest',
25+
sourceType: 'module'
26+
}
27+
};

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Create a report to help us improve
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

109
⚠️ If you have general Chrome Extensions questions, consider posting to the [Chromium Extensions Group](https://groups.google.com/a/chromium.org/forum/#!forum/chromium-extensions) or [Stack Overflow](https://stackoverflow.com/questions/tagged/google-chrome-extension).
@@ -14,6 +13,7 @@ A clear and concise description of what the bug is.
1413

1514
**To Reproduce**
1615
Steps to reproduce the behavior, or file the issue is found in:
16+
1717
1. Go to '...'
1818
2. Click on '....'
1919
3. Scroll down to '....'

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*~
22
*.DS_store
3-
3+
node_modules
44
# Temporary directory for debugging extension samples
55
_debug

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_archive
2+
third-party
3+
node_modules

.prettierrc.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"trailingComma": "none",
7+
"bracketSpacing": true,
8+
"arrowParens": "always"
9+
}

CONTRIBUTING.md

+41-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
1-
# Contributing to this Repository
1+
# How to Contribute
22

3-
Thank you for your interest in contributing!
3+
We'd love to accept your patches and contributions to this project.
44

5-
Send us your patches early and often and in whatever shape or form.
5+
## Before you begin
66

7-
## Legal
7+
### Sign our Contributor License Agreement
88

9-
Unfortunately there are some legal hurdles. Sorry about that.
9+
Contributions to this project must be accompanied by a
10+
[Contributor License Agreement](https://cla.developers.google.com/about) (CLA).
11+
You (or your employer) retain the copyright to your contribution; this simply
12+
gives us permission to use and redistribute your contributions as part of the
13+
project.
1014

11-
This repository is a Google open source project, and so we require contributors to sign Google's open source Contributor License Agreement.
12-
It's easy to do, just click here to sign as an [individual](https://developers.google.com/open-source/cla/individual) or [corporation](https://developers.google.com/open-source/cla/corporate).
13-
Individuals can sign electronically in seconds (see the bottom of the page); corporations will need to email a PDF, or mail.
15+
If you or your current employer have already signed the Google CLA (even if it
16+
was for a different project), you probably don't need to do it again.
1417

15-
We cannot accept PRs or patches larger than fixing typos and the like without a signed CLA.
18+
Visit <https://cla.developers.google.com/> to see your current agreements or to
19+
sign a new one.
1620

17-
If your Github account doesn't show the name you used to sign, please mention your name in your PR.
21+
### Review our Community Guidelines
22+
23+
This project follows [Google's Open Source Community
24+
Guidelines](https://opensource.google/conduct/).
25+
26+
## Contribution process
27+
28+
### Code Reviews
29+
30+
All submissions, including submissions by project members, require review. We
31+
use GitHub pull requests for this purpose. Consult
32+
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
33+
information on using pull requests.
34+
35+
### Setting up your Environment
36+
37+
If you want to contribute to this repository, you need to first [create your own fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
38+
After forking chrome-extensions-samples to your own Github account, run the following steps to get started:
39+
40+
```sh
41+
# clone your fork to your local machine
42+
git clone https://github.com/your-fork/chrome-extensions-samples.git
43+
44+
cd chrome-extensions-samples
45+
46+
# install dependencies
47+
npm install
48+
```

README.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ Note that Chrome Apps are deprecated. Learn more [on the Chromium blog](https://
55

66
For more information on extensions, see [Chrome Developers](https://developer.chrome.com).
77

8-
**Note: Samples for Manifest V3 are still being prepared. In the mean time, consider referring to [_archive/mv2/](_archive/mv2/).**
8+
**Note: Samples for Manifest V3 are still being prepared. In the mean time, consider referring to [\_archive/mv2/](_archive/mv2/).**
99

1010
## Samples
1111

1212
The directory structure is as follows:
1313

14-
* [api-samples/](api-samples/) - extensions focused on a single API package
15-
* [functional-samples/](functional-samples/) - full featured extensions spanning multiple API packages
16-
* [_archive/apps/](_archive/apps/) - deprecated Chrome Apps platform (not listed below)
17-
* [_archive/mv2/](_archive/mv2/) - resources for manifest version 2
14+
- [api-samples/](api-samples/) - extensions focused on a single API package
15+
- [functional-samples/](functional-samples/) - full featured extensions spanning multiple API packages
16+
- [\_archive/apps/](_archive/apps/) - deprecated Chrome Apps platform (not listed below)
17+
- [\_archive/mv2/](_archive/mv2/) - resources for manifest version 2
1818

1919
To experiment with these samples, please clone this repo and use 'Load Unpacked Extension'.
2020
Read more on [Development Basics](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/#load-unpacked).
@@ -119,3 +119,11 @@ Read more on [Development Basics](https://developer.chrome.com/docs/extensions/m
119119
</tr>
120120
</tbody>
121121
</table>
122+
123+
## Contributing
124+
125+
Please see [the CONTRIBUTING file](/CONTRIBUTING.md) for information on contributing to the `chrome-extensions-samples` project.
126+
127+
## License
128+
129+
`chrome-extensions-samples` are authored by Google and are licensed under the [Apache License, Version 2.0](/LICENSE).

api-samples/action/demo/index.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ p {
44

55
.flex {
66
display: flex;
7-
gap: .25em;
8-
margin: .5em 0;
7+
gap: 0.25em;
8+
margin: 0.5em 0;
99
align-items: flex-end;
1010
}
1111

1212
.spaced {
13-
margin: .5em 0;
13+
margin: 0.5em 0;
1414
}
1515

1616
.full-width {

0 commit comments

Comments
 (0)