Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ESLint and PrettierJS #2726

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/eslint_csslint_jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: npm install --force

- name: Run eslint
run: npx eslint --config=tests/eslint_rules.config.mjs
run: npx eslint
continue-on-error: true

# - name: Run JSLint
Expand All @@ -40,11 +40,9 @@ jobs:
- name: Run npm test
run: npm test

- name: Install csslint using npm
run: npm install -g [email protected]
# - name: Install csslint using npm
# run: npm install -g [email protected]

# - name: Lint CSS files
# run: |
# for file in $(grep -rl --include='*.css' '' ./); do npx csslint --config tests/csslint_rules.json "$file"; done


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
25 changes: 13 additions & 12 deletions build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def chromium(browser):
item != '.git' and
item != '.github' and
item != 'cached' and
item != 'previews' and
item != 'py' and
item != 'wiki' and
item != 'node_modules' and
item != 'build' and
item != 'config' and
item != 'tests' and
item != 'LICENSE' and
item != 'README.md' and
item != 'SECURITY.md' and
item != 'CONTRIBUTING.md' and
item.find('.zip') == -1
):
s = os.path.join('../', item)
Expand Down Expand Up @@ -94,19 +94,20 @@ def firefox():
os.chdir(temporary_path)

for item in os.listdir('../'):

if (
item != '.git' and
item != '.github' and
item != 'cached' and
item != 'previews' and
item != 'py' and
item != 'wiki' and
item != 'node_modules' and
item != 'build' and
item != 'config' and
item != 'tests' and
item != 'LICENSE' and
item != 'README.md' and
item != 'SECURITY.md' and
item != 'CONTRIBUTING.md' and
item.find('.zip') == -1
):
s = os.path.join('../', item)
s = os.path.join('../', item)
d = os.path.join(temporary_path, item)
if os.path.isdir(s):
shutil.copytree(s, d, True, None)
Expand Down Expand Up @@ -163,4 +164,4 @@ def firefox():
elif arg == '-chromium-beta':
chromium('beta')
elif arg == '-firefox':
firefox()
firefox()
28 changes: 28 additions & 0 deletions config/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from "@eslint/js";
import globals from "globals";

const customGlobals = {
extension: "writable",
ImprovedTube: "writable",
chrome: "readonly",
}

export default [

js.configs.recommended,
{
languageOptions: {
globals: {
...customGlobals,
...globals.browser,
},
},
rules: {
"no-unused-vars": [
"error",
{ destructuredArrayIgnorePattern: "^_" },
],
},
},

];
6 changes: 6 additions & 0 deletions config/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
trailingComma: "es5",
tabWidth: 4,
semi: false,
singleQuote: true,
};
8 changes: 0 additions & 8 deletions jest.config.js

This file was deleted.

6 changes: 3 additions & 3 deletions js&css/extension/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ extension.storage.get = function (key) {
if (key.indexOf('/') === -1) {
return this.data[key];
} else {
var target = this.data,
path = key.split('/').filter(function (value) {
var target = this.data;
/*path = key.split('/').filter(function (value) {
return value != '';
});
});*/

for (var i = 0, l = key.length; i < l; i++) {
var part = key[i];
Expand Down
4 changes: 2 additions & 2 deletions js&css/extension/www.youtube.com/general/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ extension.features.popupWindowButtons = function (event) {
event.preventDefault();
event.stopPropagation();
try { this.parentElement.itPopupWindowButton.dataset.id = this.parentElement.href.match(/(?:[?&]v=|embed\/|shorts\/)([^&?]{11})/)[1] } catch (error) { console.log(error)};
ytPlayer = document.querySelector("#movie_player");
let ytPlayer = document.querySelector("#movie_player");
if (ytPlayer) {width = ytPlayer.offsetWidth * 0.65; height = ytPlayer.offsetHeight * 0.65}
else { width = innerWidth * 0.4; height = innerHeight * 0.4; }
if (!ytPlayer) {
if (!ytPlayer) {
let shorts = /short/.test(this.parentElement.href);
if ( width / height < 1 ) { let vertical = true } else { let vertical = false }
if ( !vertical && shorts ) { width = height * 0.6}
Expand Down
Loading
Loading