Skip to content

Commit

Permalink
convert to flat ESLint config
Browse files Browse the repository at this point in the history
  • Loading branch information
fire332 committed Mar 31, 2024
1 parent 480b4e8 commit 9048617
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 61 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

39 changes: 0 additions & 39 deletions .eslintrc.js

This file was deleted.

File renamed without changes.
File renamed without changes.
90 changes: 90 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
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';
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,

{
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-constant-binary-expression': 'error', // default in 'eslint:recommended' since v9
'no-constructor-return': 'error',
'no-empty-static-block': 'error', // default in 'eslint:recommended' since v9
'no-unmodified-loop-condition': 'error'
}
},

{
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.*']
}
];
31 changes: 27 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
"name": "youtube-webos",
"version": "0.3.2",
"description": "Ad-free YouTube app for webOS",
"type": "module",
"main": "index.js",
"scripts": {
"build": "webpack --mode=production",
"build:dev": "webpack --mode=development",
"package": "ares-package -n dist",
"deploy": "node tools/deploy.mjs",
"deploy": "node tools/deploy.js",
"launch": "ares-launch youtube.leanback.v4",
"manifest": "node tools/gen-manifest.js youtube.leanback.v4.manifest.json",
"version": "node tools/sync-version.js && git add assets/appinfo.json",
"manifest": "node tools/gen-manifest.cjs youtube.leanback.v4.manifest.json",
"version": "node tools/sync-version.cjs && git add assets/appinfo.json",
"prepare": "husky install",
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
"lint": "eslint .",
"prettier-check": "prettier --ignore-path .prettierignore --check ."
},
"repository": "github:webosbrew/youtube-webos",
Expand All @@ -30,6 +31,7 @@
"@babel/core": "^7.24.3",
"@babel/plugin-transform-runtime": "^7.24.3",
"@babel/preset-env": "^7.24.3",
"@eslint/js": "^8.57.0",
"@types/babel__core": "^7.20.5",
"@webos-tools/cli": "^3.0.2",
"babel-loader": "^9.1.3",
Expand All @@ -39,6 +41,7 @@
"css-loader": "^6.10.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"globals": "^15.0.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
Expand Down
11 changes: 0 additions & 11 deletions src/.eslintrc.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions webpack.config.mjs → webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const makeConfig = () => [
rules: [
{
test: /\.(?:m|c)?js$/i,

loader: 'babel-loader',
exclude: [
// Some module should not be transpiled by Babel
Expand All @@ -35,6 +36,10 @@ const makeConfig = () => [
],
options: {
cacheDirectory: true
},
resolve: {
// File extension DON'T MATTER in a bundler.
fullySpecified: false
}
},
{
Expand Down

0 comments on commit 9048617

Please sign in to comment.