Skip to content

Commit

Permalink
Merge pull request #17 from avallete/8-refactor-script
Browse files Browse the repository at this point in the history
8 refactor script
  • Loading branch information
avallete committed Mar 24, 2021
2 parents a8832ff + 40c54c6 commit 9c336b0
Show file tree
Hide file tree
Showing 66 changed files with 22,369 additions and 310 deletions.
1 change: 1 addition & 0 deletions .eslintignore
78 changes: 78 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const unitTestsExtends = ['plugin:ava/recommended']
const cypressTestsExtends = ['plugin:cypress/recommended', 'eslint-config-sinon', 'plugin:chai-friendly/recommended']
const commonExtends = ['plugin:prettier/recommended', 'plugin:unicorn/recommended', 'plugin:radar/recommended']
const tsExtends = ['airbnb-typescript/base', ...commonExtends]
const jsExtends = ['airbnb-base', ...commonExtends]

// Override some rules that we abuse into our tests
const UNIT_TESTS_TS_OVERRIDE = {
files: ['test/**/*.ts', 'test/**/*.tsx'],
extends: [...unitTestsExtends, ...tsExtends],
rules: {
'radar/no-duplicate-string': 'off',
'no-unused-expressions': 'off',
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
},
}
const UNIT_TESTS_JS_OVERRIDE = {
files: ['test/**/*.js'],
extends: [...unitTestsExtends, ...jsExtends],
rules: {
'radar/no-duplicate-string': 'off',
'no-unused-expressions': 'off',
},
}
const CYPRESS_TS_OVERRIDE = {
files: ['cypress/**/*.ts'],
extends: [...cypressTestsExtends, ...tsExtends],
rules: {
'radar/no-duplicate-string': 'off',
'no-unused-expressions': 'off',
},
}
const CYPRESS_JS_OVERRIDE = {
files: ['cypress/**/*.js'],
extends: [...cypressTestsExtends, ...jsExtends],
parserOptions: {
ecmaVersion: 2020,
},
rules: {
'radar/no-duplicate-string': 'off',
'no-unused-expressions': 'off',
quotes: 'off',
semi: 'off',
},
}
const TS_OVERRIDE = {
rules: {
// disable for event handlers, use preact naming convention for scoped ignore rules
// allow us to du currentTarget.value = 'something' into event handlers
'no-param-reassign': ['error', { props: true, ignorePropertyModificationsFor: ['currentTarget'] }],
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
// DOM .append unavailable in typescript types definitions
'unicorn/prefer-dom-node-append': 'off',
// Since our final script is bundled, devDependencies and dependencies are just useful
// for semantic separation. Only include in dependencies the packages who the code actually
// end up into your final bundled file
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
},
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint'],
extends: [...tsExtends],
settings: {
'import/resolver': {
typescript: {},
},
},
overrides: [UNIT_TESTS_TS_OVERRIDE, CYPRESS_TS_OVERRIDE],
}

module.exports = {
extends: jsExtends,
overrides: [UNIT_TESTS_JS_OVERRIDE, CYPRESS_JS_OVERRIDE, TS_OVERRIDE],
}
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/1-bug-repport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: " \U0001F41B Bug Report"
about: Got a bug! File it using this template!
title: '[BUG]'
labels: bug
assignees: ''
---

**Steps to reproduce**:

**Expected results**:

**Actual results**:

**Notes**:
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/2-feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: " \U0001F680 Feature Request"
about: Suggest an idea for this project
title: '[FEAT]'
labels: feature
assignees: ''
---

**Is your feature request related to a problem? Please describe.**
Please describe the problem you are trying to solve.

**Describe the solution you'd like**
Please describe the desired behavior.

**Describe alternatives you've considered**
Please describe alternative solutions or features you have considered.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
47 changes: 47 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

## Closing issues

Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).
56 changes: 56 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CD

on:
# Use semantic-release to publish the updated package.json to master branch with a new release and tag
# deploy-gh-pages is responsible to build production version and publish it to gh-pages branch
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install dependencies
run: |
npm ci
- name: Lint
run: |
npm run lint
- name: Coverage
# Could be replaced with coverage-all if you want to ensure new files are tested as well
run: |
npm run coverage
npm run coverage:report
env:
NODE_ENV: test
- name: E2E-tests
uses: cypress-io/github-action@v2
with:
build: npm run build
env:
NODE_ENV: test
# Will update the package.json file with semantic-release and push it to master with a new tag
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
env:
GH_TOKEN: ${{ secrets.GH_SEMANTIC_RELEASE_TOKEN }}
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: 44210433+github-actions@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: 44210433+github-actions@users.noreply.github.com
- name: Upload coverage to CodeCov
uses: codecov/codecov-action@v1
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
directory: coverage
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
# CD workflow is responsible for building and release on push to master
pull_request:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install dependencies
run: |
npm ci
- name: Lint
run: |
npm run lint
- name: Coverage
# Could be replaced with coverage-all if you want to ensure new files are tested as well
run: |
npm run coverage
npm run coverage:report
env:
NODE_ENV: test
- name: E2E-tests
uses: cypress-io/github-action@v2
with:
build: npm run build
env:
NODE_ENV: test
- name: Upload coverage to CodeCov
uses: codecov/codecov-action@v1
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
directory: coverage
32 changes: 32 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy to Github Pages

on:
release:
types: [published]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install dependencies
run: |
npm ci
- name: Lint
env:
USERSCRIPTER_MODE: production
NODE_ENV: production
run: |
npm run build
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
BRANCH: gh-pages
FOLDER: dist
19 changes: 19 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Mark stale issues and pull requests

on:
schedule:
- cron: '21 4 * * *'

jobs:
stale:
runs-on: ubuntu-latest

steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has become stale and will be closed automatically within a period of time. Sorry about that.'
stale-pr-message: 'This pull request has become stale and will be closed automatically within a period of time. Sorry about that.'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
days-before-stale: 90
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Created by .ignore support plugin (hsz.mobi)
.awcache
.idea
node_modules/
dist/
.userscripter-temp/
.eslintcache
.nyc_output/
coverage/
cypress/videos/
cypress/screenshots/
.vscode
.dccache
# is generated at build time, should not be commited
metadata-config.json
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
*.log
.babelrc
.awcache
dist/
.userscripter-temp
19 changes: 19 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"check-coverage": true,
"include": [
"src/**",
"metadata.ts"
],
"exclude": [
"dist/**",
"cypress/**",
"test/**"
],
"reporter": [
"text"
],
"lines": 70,
"branches": 70,
"statements": 70
}
1 change: 1 addition & 0 deletions .prettierignore
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"singleQuote": true,
"jsxSingleQuote": true,
"printWidth": 120
}
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ The lack of fine tuning about which videos you want to delete from your playlist
Youtube recently added a button "Delete watched videos" for the watch later playlist. But this button will
delete EVERY started watched videos. Even the ones you didn't finished to watch yet.


This script solve the issue by adding a button on Youtube to remove watched videos with more
This script solve the issue by adding a button on Youtube to remove watched videos with more
than X percent from any playlist.

# How to install ?

You need to have [ViolentMonkey]() or [TamperMonkey]() extension installed in your browser.
Then simply click to [this install link](https://github.com/avallete/yt-playlists-delete-enhancer/raw/gh-pages/yt-playlists-delete-enhancer.user.js) and add this userscript to your extensions.

You can also go to the [GreasyFork](https://greasyfork.org/fr/scripts/398688-yt-playlists-delete-enhancer) page and install it from there.

## Screenshot

![screen1](https://user-images.githubusercontent.com/8771783/77522241-0a1ebf80-6ed8-11ea-84fc-400b178bdc7d.png)
![screen2](https://user-images.githubusercontent.com/8771783/77522248-0c811980-6ed8-11ea-8f60-8ff91eb5e940.png)

Loading

0 comments on commit 9c336b0

Please sign in to comment.