Skip to content

Commit 3154edd

Browse files
rushilsrivastavalegitatx
and
legitatx
authored
🎨 Clean up repo, update utilities (#1)
* 📝 Repository cleanup * ⚡ Upgrade to NPM * 🎨 TSLint --> ESLint * 🎨 TSLint --> ESLint * 🎨 TSLint --> ESLint * ✅ Fix tests * ✅ Update legacy tests * ✅ Update legacy tests * ✅ Update legacy tests We will always use webpack 5+, remove version check for stub to avoid crazy workaround hack Co-authored-by: legitatx <[email protected]>
1 parent bb752c3 commit 3154edd

38 files changed

+15318
-3817
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
sample/
4+
.github/

.eslintrc.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
es6: true,
6+
},
7+
globals: {
8+
window: "readonly",
9+
},
10+
parser: "@typescript-eslint/parser",
11+
parserOptions: {
12+
parser: "@babel/eslint-parser",
13+
ecmaVersion: 6,
14+
sourceType: "module",
15+
},
16+
extends: [
17+
"airbnb",
18+
"plugin:react/recommended",
19+
"plugin:react-hooks/recommended",
20+
"plugin:jsx-a11y/recommended",
21+
"plugin:@typescript-eslint/eslint-recommended",
22+
"plugin:@typescript-eslint/recommended",
23+
"prettier",
24+
],
25+
settings: {
26+
"import/resolver": {
27+
node: {
28+
paths: [".", "src"],
29+
extensions: [".js", ".ts"],
30+
},
31+
},
32+
},
33+
plugins: [
34+
"prettier",
35+
"react",
36+
"jsx-a11y",
37+
"react-hooks",
38+
"@typescript-eslint",
39+
],
40+
rules: {
41+
"import/extensions": "off",
42+
"import/prefer-default-export": "off",
43+
"import/no-webpack-loader-syntax": "off",
44+
"import/no-unresolved": "off",
45+
"import/no-extraneous-dependencies": "off",
46+
"no-use-before-define": "off",
47+
"no-console": "off",
48+
"no-extend-native": "off",
49+
"no-param-reassign": "off",
50+
"class-methods-use-this": "off",
51+
"node/no-unpublished-require": "off",
52+
"node/no-missing-import": "off",
53+
"node/no-unpublished-import": "off",
54+
"dot-notation": ["error", { allowKeywords: true }],
55+
"@typescript-eslint/explicit-module-boundary-types": "off",
56+
"@typescript-eslint/no-explicit-any": "off",
57+
"@typescript-eslint/no-var-requires": "off",
58+
"func-names": "off",
59+
"no-underscore-dangle": "off",
60+
camelcase: "warn",
61+
"no-plusplus": "off",
62+
"no-nested-ternary": "off",
63+
"@typescript-eslint/ban-types": "warn",
64+
"no-unused-expressions": "off",
65+
},
66+
};

.github/CHANGELOG.md

-6
This file was deleted.

.github/CONTRIBUTING.MD

+29-22
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,73 @@
11
# How to Contribute
22

3-
## Important checks
4-
- Before create any pull requests, please open a issue explaining the situation
5-
- Be sure to follow the tslint rules and run the prettier
6-
- Be sure **before open the pull request**, to test the existent code and/or create tests if you made a new feature or
3+
Before create any pull requests, please open a issue explaining the situation
4+
5+
- Be sure to follow the eslint rules and run the prettier
6+
- Be sure **before open the pull request**, to test the existent code and/or create tests if you made a new feature or
77
changed a already existing one.
88

9-
# Issues
9+
## Issues
10+
1011
Should be in the format:
1112

1213
```text
1314
**Type:**
14-
- [x] bug
15+
- [x] bug
1516
- [ ] feature
1617
- [ ] enhancement
1718
- [ ] question
18-
19+
1920
**Environment:**
2021
- OS: Windows 10
21-
- Version: 0.6.0
22-
22+
- Version: 0.6.0
23+
2324
**Going to open a PR:**
2425
- [x] yes
2526
- [ ] no
26-
27-
**Description:**
27+
28+
**Description:**
2829
The messages aren't showing on the console
2930
```
3031

31-
# Pull Requests
32+
## Pull Requests
33+
3234
- On the description of the pull request set the issue id for closing it:
35+
3336
```text
3437
Now the messages are showing. Closes #41
3538
```
3639

3740
## Following the guideline
41+
3842
Please follow the above rules, so the repo can stay consistent and easy for everyone find questions and
3943
already resolved stuff. Be aware that your PR can be denied if you don't follow then :cry:
4044

41-
# Running this project locally
45+
## Running this project locally
46+
47+
### Building and Testing
4248

43-
## Building and Testing
4449
Inside this repository have an example plugin, so you can test and see it working
45-
After cloning the repository, run:
46-
```
50+
After cloning the repository, run:
51+
52+
```bash
4753
yarn build
4854
```
4955

50-
And then run:
51-
```
56+
And then run:
57+
58+
```bash
5259
yarn start:sample
5360
```
54-
61+
5562
This will make the webpack run in watch mode for the sample plugin source and output the built files on the "dist"
5663
directory.
57-
Load the extension **(the files in "sample/dist" directory)** using the "load unpacked extension", open a
58-
new tab in any site and open the developer panel on it. Watch the dev. tools console tab, and do some changes on
64+
Load the extension **(the files in "sample/dist" directory)** using the "load unpacked extension", open a
65+
new tab in any site and open the developer panel on it. Watch the dev. tools console tab, and do some changes on
5966
the background or content script. Voila!
6067

6168
**Note:**
6269
You must have both background and content scripts for this plugin to work, and they must be specified in separate `entry` chunks
6370
in your webpack config.
6471

6572
The reloading script will be injected only on the main entries chunks (in background and content script). Any other
66-
chunks will be ignored.
73+
chunks will be ignored.

.github/workflows/audit-and-lint.yml

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
11
name: audit-and-lint
2+
23
on: [push]
4+
35
jobs:
46
install-audit-lint:
57
runs-on: ubuntu-latest
68

79
steps:
8-
- uses: actions/checkout@v1
9-
- name: Cache NPM dependencies
10-
id: npm-cache
11-
uses: actions/cache@v1
10+
- uses: actions/checkout@v2
11+
12+
- name: Set up Node.js
13+
uses: actions/setup-node@v2
14+
with:
15+
node-version: "14.x"
16+
17+
- name: Cache node modules
18+
uses: actions/cache@v2
1219
with:
13-
path: ~/.cache/yarn
14-
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
20+
path: node_modules
21+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
1522
restore-keys: |
16-
${{ runner.os }}-yarn-
23+
${{ runner.OS }}-build-${{ env.cache-name }}-
24+
${{ runner.OS }}-build-
25+
${{ runner.OS }}-
1726
1827
- name: Install dependencies
19-
run: yarn
28+
run: npm ci
29+
env:
30+
CI: TRUE
2031

2132
- name: Package auditory
22-
run: yarn audit
33+
run: npm audit
2334

2435
- name: Lint the source
25-
run: yarn lint
36+
run: npm run lint
37+
env:
38+
CI: TRUE

.github/workflows/publish.yml

+30-16
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,48 @@
11
name: publish
2+
23
on:
34
release:
45
types:
56
- created
67
branches:
78
- master
9+
810
jobs:
911
build-and-test:
1012
runs-on: ubuntu-latest
1113

1214
steps:
13-
- uses: actions/checkout@v1
14-
- name: Cache NPM dependencies
15-
id: npm-cache
16-
uses: actions/cache@v1
15+
- uses: actions/checkout@v2
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: "14.x"
21+
22+
- name: Cache node modules
23+
uses: actions/cache@v2
1724
with:
18-
path: ~/.cache/yarn
19-
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
25+
path: node_modules
26+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
2027
restore-keys: |
21-
${{ runner.os }}-yarn-
28+
${{ runner.OS }}-build-${{ env.cache-name }}-
29+
${{ runner.OS }}-build-
30+
${{ runner.OS }}-
31+
32+
- name: Install dependencies
33+
run: npm ci --ignore-scripts
34+
env:
35+
CI: TRUE
2236

23-
- name: Install and build
24-
run:
25-
- yarn
26-
- yarn build
37+
- name: Build plugin
38+
run: npm run build
39+
env:
40+
CI: TRUE
2741

2842
- name: Publish package
43+
run: |
44+
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
45+
npm publish --ignore-scripts
2946
env:
30-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
31-
CI: true
32-
run:
33-
- echo "//registry.yarnpkg.com/:_authToken=$NPM_AUTH_TOKEN" >> ~/.npmrc
34-
- yarn publish
47+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
CI: TRUE

.github/workflows/tests.yml

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
11
name: tests
2+
23
on: [push]
4+
35
jobs:
46
build-and-test:
57
runs-on: ubuntu-latest
68

79
steps:
8-
- uses: actions/checkout@v1
9-
- name: Cache NPM dependencies
10-
id: npm-cache
11-
uses: actions/cache@v1
10+
- uses: actions/checkout@v2
11+
12+
- name: Set up Node.js
13+
uses: actions/setup-node@v2
14+
with:
15+
node-version: "14.x"
16+
17+
- name: Cache node modules
18+
uses: actions/cache@v2
1219
with:
13-
path: ~/.cache/yarn
14-
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
20+
path: node_modules
21+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
1522
restore-keys: |
16-
${{ runner.os }}-yarn-
23+
${{ runner.OS }}-build-${{ env.cache-name }}-
24+
${{ runner.OS }}-build-
25+
${{ runner.OS }}-
1726
1827
- name: Install dependencies
19-
run: yarn
28+
run: npm ci
29+
env:
30+
CI: TRUE
2031

2132
- name: Build plugin
22-
run: yarn build
33+
run: npm run build
2334

2435
- name: Run the tests
25-
run: yarn test
36+
run: npm run test
37+
env:
38+
CI: TRUE

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ jspm_packages
5353
# Yarn Integrity file
5454
.yarn-integrity
5555

56-
# NPM lock file
57-
package-lock.json
56+
# Yarn lock file
57+
yarn.lock

.gitmodules

-4
This file was deleted.

.npmignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ dist/tests.js.map
88
.babelrc
99
.gitignore
1010
tsconfig.json
11-
tslint.json
1211
webpack.config.js
13-
yarn.lock
12+
yarn.lock

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Rubens Pinheiro Gonçalves Cavalcante
3+
Copyright (c) 2019 Rubens Pinheiro Gonçalves Cavalcante, 2021 Simplify Jobs Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)