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

Bump deps to latest major version and other misc dev UX #146

Merged
merged 36 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f6210bd
bump all dependencies
fire332 Mar 29, 2024
c7ea790
add override to retain formatting before prettier 3.2.5
fire332 Mar 29, 2024
a5e12db
update deploy script to point to new @webos-tools/cli
fire332 Mar 29, 2024
cfea7b8
convert babel config to ESM syntax
fire332 Mar 29, 2024
da37dd5
use @babel/runtime-corejs3 instead of @babel/runtime due to breaking …
fire332 Mar 29, 2024
8b6cc3f
babel config: update for new options and cache based on plugin versions
fire332 Mar 29, 2024
3887a91
tidy webpack and eslint configs
fire332 Mar 29, 2024
bd6c847
add more eslint rules
fire332 Mar 29, 2024
0dcda87
lint everything with eslint
fire332 Mar 29, 2024
8b1ee9e
fix lint error
fire332 Mar 29, 2024
11a2e6e
use stricter tsconfig's
fire332 Mar 29, 2024
3730ca5
remove deprecated vscode extension from recommendations
fire332 Mar 29, 2024
8d003dd
use ares-install from node_modules/bin instead of directly from depen…
fire332 Mar 29, 2024
6a21895
Merge branch 'webosbrew:main' into main
fire332 Mar 30, 2024
d0230bd
make prettier format .vscode folder
fire332 Mar 31, 2024
2373c24
explicitly lint files/folders starting with "." as ESLint excludes by…
fire332 Mar 31, 2024
6428058
explicitly include files starting with "." in type check as TypeScrip…
fire332 Mar 31, 2024
ebd29c6
don't init during assignment to `module.exports` as TS compiler doesn…
fire332 Mar 31, 2024
480b4e8
prettify index.html
fire332 Mar 31, 2024
9a167cd
convert to flat ESLint config
fire332 Mar 31, 2024
04f9842
add type-check script
fire332 Mar 31, 2024
e0264e7
type check tools folder and fix errors
fire332 Mar 31, 2024
cfd6ab9
fix babel/webpack ESM/CommonJS mismatch
fire332 Apr 1, 2024
c506a8d
add inspect script
fire332 Apr 1, 2024
7826adf
Merge branch 'main' of https://github.com/webosbrew/youtube-webos
fire332 Apr 1, 2024
760581e
bump deps
fire332 Apr 6, 2024
b195d37
migrate to husky v9
fire332 Apr 6, 2024
04d170a
migrate to ESLint v9
fire332 Apr 6, 2024
8ace993
add ESLint rule 'no-useless-assignment'
fire332 Apr 6, 2024
a704ec0
let git handle line endings
fire332 Apr 6, 2024
f533d35
add eslint-plugin-regexp
fire332 Apr 6, 2024
3011da8
fix lint error
fire332 Apr 6, 2024
2ce984a
run ESLint and tsc with lint-staged
fire332 Apr 6, 2024
21b0dd0
add lint-staged.config.js to tsconfig.tooling.json
throwaway96 Apr 6, 2024
49f1492
add @types/lint-staged
throwaway96 Apr 7, 2024
6db7baa
sponsorblock.js: fix tiny-sha256 import
throwaway96 Apr 7, 2024
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
16 changes: 14 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
module.exports = {
/** @type {import('prettier').Config} */
const config = {
trailingComma: 'none',
singleQuote: true
singleQuote: true,
endOfLine: 'auto',
overrides: [
{
files: ['tsconfig.json', 'jsconfig.json', 'tsconfig.*.json'],
options: {
parser: 'jsonc'
}
}
]
};

export default config;
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"recommendations": [
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"eg2.vscode-npm-script"
"dbaeumer.vscode-eslint"
]
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"javascript.preferences.quoteStyle": "single",
"prettier.requireConfig": true,
"prettier.useEditorConfig": true,
"editor.formatOnSave": true
"editor.formatOnSave": true,
"prettier.ignorePath": ".prettierignore",
"typescript.tsdk": "node_modules\\typescript\\lib"
}
31 changes: 25 additions & 6 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
module.exports = (api) => {
api.cache.never();
import Module from 'node:module';

const require = Module.createRequire(import.meta.url);

// From: https://github.com/babel/babel-polyfills/blob/a5db9c31c5b5474b4018e6178bc40882fc3eb5bf/packages/babel-plugin-polyfill-corejs3/README.md#version

const {
version: babelruntimeVersion
} = require('@babel/runtime-corejs3/package.json');
const { version: corejspureVersion } = require('core-js-pure/package.json');

/** @type {import('@babel/core').ConfigFunction} */
function makeConfig(api) {
api.cache.invalidate(() => babelruntimeVersion + corejspureVersion);

return {
// Fixes "TypeError: __webpack_require__(...) is not a function"
// https://github.com/webpack/webpack/issues/9379#issuecomment-509628205
// https://babeljs.io/docs/en/options#sourcetype
// https://babel.dev/docs/options#sourcetype
sourceType: 'unambiguous',
// https://babel.dev/docs/assumptions
assumptions: {
noNewArrows: true
},
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: false,
version: require('./package.json').dependencies['@babel/runtime']
version: babelruntimeVersion
}
],
[
'polyfill-corejs3',
{
method: 'usage-pure'
method: 'usage-pure',
version: corejspureVersion
}
],
[
Expand All @@ -36,4 +53,6 @@ module.exports = (api) => {
]
]
};
};
}

export default makeConfig;
101 changes: 101 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import Module from 'node:module';

import eslintJs from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
// @ts-expect-error No type definitions available for this package. https://github.com/ota-meshi/eslint-plugin-regexp/issues/723
import * as regexpPlugin from 'eslint-plugin-regexp';
import globals from 'globals';

const require = Module.createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

/** @type {'module' | 'commonjs'} */
const defaultSourceType =
require(join(__dirname, 'package.json')).type ?? 'commonjs';

/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
eslintJs.configs.recommended,
prettierConfig,
regexpPlugin.configs['flat/recommended'],

{
linterOptions: {
reportUnusedDisableDirectives: 'error'
},

languageOptions: {
sourceType: defaultSourceType,
parserOptions: {
ecmaFeatures: {
impliedStrict: true
}
},
globals: {
...globals.nodeBuiltin
}
},

rules: {
'no-var': 'error',
'no-await-in-loop': 'error',
'no-implicit-globals': ['error'],
'no-unused-vars': ['error', { vars: 'local', argsIgnorePattern: '^_' }],
'no-useless-rename': ['error'],
'arrow-body-style': ['error', 'as-needed'],
'no-lonely-if': 'error',
'prefer-object-has-own': 'error',
'prefer-exponentiation-operator': 'error',
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
'array-callback-return': [
'error',
{ checkForEach: true, allowVoid: true }
],
'no-constructor-return': 'error',
'no-unmodified-loop-condition': 'error',
'no-useless-assignment': 'error',

/* eslint-plugin-regexp */
'regexp/prefer-character-class': ['error', { minAlternatives: 2 }],
'regexp/no-empty-alternative': 'error', // Set to warn in recommended config
'regexp/no-lazy-ends': 'error', // Set to warn in recommended config
'regexp/no-potentially-useless-backreference': 'error', // Set to warn in recommended config
'regexp/confusing-quantifier': 'error', // Set to warn in recommended config
'regexp/no-useless-flag': 'error', // Set to warn in recommended config
'regexp/optimal-lookaround-quantifier': 'error' // Set to warn in recommended config
}
},

{
files: ['src/**/*'],
languageOptions: {
globals: {
...globals.browser
}
}
},

{
// Why doesn't ESLint do this by default is beyond me.
files: ['**/*.cjs'],
languageOptions: {
sourceType: 'commonjs'
}
},

{
// Why doesn't ESLint do this by default is beyond me.
files: ['**/*.mjs'],
languageOptions: {
sourceType: 'module'
}
},

{
// `ignores` field must be in the very bottom config.
ignores: ['dist/**/*', '**/*-polyfill.*']
}
];
13 changes: 0 additions & 13 deletions jsconfig.json

This file was deleted.

10 changes: 10 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function globForCode(/** @type {string} */ toolName) {
return '*.?(c|m){js,ts}?(x)' + `*(${toolName})`;
throwaway96 marked this conversation as resolved.
Show resolved Hide resolved
}

/** @type {import('lint-staged').Config} */
export default {
'*': 'prettier --ignore-unknown --write',
[globForCode('eslint')]: 'eslint',
[globForCode('tsc')]: () => 'tsc -b'
};
Loading