mirror of
https://github.com/jellyfin/jellyfin-chromecast.git
synced 2024-11-22 21:49:44 +00:00
chore(lint): make linting stricter and auto lint on commit and save
This commit is contained in:
parent
0c015961c8
commit
743c1d9a31
@ -2,8 +2,11 @@ root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
157
.eslintrc.js
157
.eslintrc.js
@ -1,50 +1,113 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
plugins: ['@typescript-eslint', 'promise', 'import', 'jsdoc'],
|
||||
env: {
|
||||
node: true,
|
||||
es6: true,
|
||||
browser: true
|
||||
},
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:promise/recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:jsdoc/recommended',
|
||||
'plugin:import/errors',
|
||||
'plugin:import/warnings',
|
||||
'plugin:import/typescript',
|
||||
'prettier'
|
||||
],
|
||||
rules: {
|
||||
'@typescript-eslint/explicit-function-return-type': 'error',
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'import/newline-after-import': 'error',
|
||||
'import/order': 'error'
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['.js', '.ts'],
|
||||
env: {
|
||||
node: false,
|
||||
browser: true,
|
||||
es6: true
|
||||
},
|
||||
globals: {
|
||||
cast: 'readonly',
|
||||
PRODUCTION: 'readonly',
|
||||
$scope: 'writable'
|
||||
}
|
||||
}
|
||||
],
|
||||
settings: {
|
||||
'import/parsers': {
|
||||
'@typescript-eslint/parser': ['.ts', '.tsx']
|
||||
},
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
alwaysTryTypes: true
|
||||
}
|
||||
}
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
browser: true,
|
||||
es6: true
|
||||
},
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:jsdoc/recommended',
|
||||
'plugin:json/recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'prettier',
|
||||
'plugin:prettier/recommended',
|
||||
'plugin:promise/recommended',
|
||||
'plugin:import/errors',
|
||||
'plugin:import/warnings',
|
||||
'plugin:import/typescript'
|
||||
],
|
||||
plugins: ['prettier', 'promise', 'import', 'jsdoc'],
|
||||
rules: {
|
||||
'import/newline-after-import': 'error',
|
||||
'import/order': 'error',
|
||||
'jsdoc/require-hyphen-before-param-description': 'error',
|
||||
'jsdoc/require-description': 'warn',
|
||||
'jsdoc/require-jsdoc': 'error',
|
||||
//TypeScript and IntelliSense already provides us information about the function typings while hovering and
|
||||
// eslint-jsdoc doesn't detect a mismatch between what's declared in the function and what's declared in
|
||||
// JSDOC.
|
||||
'jsdoc/require-param-type': 'off',
|
||||
'jsdoc/require-returns-type': 'off',
|
||||
'jsdoc/check-indentation': 'error',
|
||||
'jsdoc/check-syntax': 'error',
|
||||
'jsdoc/check-param-names': 'error',
|
||||
'jsdoc/check-property-names': 'error',
|
||||
'jsdoc/check-tag-names': 'error',
|
||||
'jsdoc/no-types': 'error',
|
||||
'jsdoc/valid-types': 'off',
|
||||
'promise/no-nesting': 'error',
|
||||
'promise/no-return-in-finally': 'error',
|
||||
'promise/prefer-await-to-callbacks': 'error',
|
||||
'promise/prefer-await-to-then': 'error',
|
||||
'@typescript-eslint/explicit-function-return-type': 'error',
|
||||
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
||||
'@typescript-eslint/no-unused-vars': 'error',
|
||||
'prefer-arrow-callback': 'error',
|
||||
'prefer-template': 'error',
|
||||
curly: 'error',
|
||||
'padding-line-between-statements': [
|
||||
'error',
|
||||
// Always require blank lines after directives (like 'use-strict'), except between directives
|
||||
{ blankLine: 'always', prev: 'directive', next: '*' },
|
||||
{ blankLine: 'any', prev: 'directive', next: 'directive' },
|
||||
// Always require blank lines after import, except between imports
|
||||
{ blankLine: 'always', prev: 'import', next: '*' },
|
||||
{ blankLine: 'any', prev: 'import', next: 'import' },
|
||||
// Always require blank lines before and after every sequence of variable declarations and export
|
||||
{
|
||||
blankLine: 'always',
|
||||
prev: '*',
|
||||
next: ['const', 'let', 'var', 'export']
|
||||
},
|
||||
{
|
||||
blankLine: 'always',
|
||||
prev: ['const', 'let', 'var', 'export'],
|
||||
next: '*'
|
||||
},
|
||||
{
|
||||
blankLine: 'any',
|
||||
prev: ['const', 'let', 'var', 'export'],
|
||||
next: ['const', 'let', 'var', 'export']
|
||||
},
|
||||
// Always require blank lines before and after class declaration, if, do/while, switch, try
|
||||
{
|
||||
blankLine: 'always',
|
||||
prev: '*',
|
||||
next: ['if', 'class', 'for', 'do', 'while', 'switch', 'try']
|
||||
},
|
||||
{
|
||||
blankLine: 'always',
|
||||
prev: ['if', 'class', 'for', 'do', 'while', 'switch', 'try'],
|
||||
next: '*'
|
||||
},
|
||||
// Always require blank lines before return statements
|
||||
{ blankLine: 'always', prev: '*', next: 'return' }
|
||||
]
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['.js', '.ts'],
|
||||
env: {
|
||||
node: false,
|
||||
browser: true,
|
||||
es6: true
|
||||
},
|
||||
globals: {
|
||||
cast: 'readonly',
|
||||
PRODUCTION: 'readonly',
|
||||
$scope: 'writable'
|
||||
}
|
||||
}
|
||||
],
|
||||
settings: {
|
||||
'import/parsers': {
|
||||
'@typescript-eslint/parser': ['.ts', '.tsx']
|
||||
},
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
alwaysTryTypes: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
# ide
|
||||
.idea
|
||||
.vscode
|
||||
tags
|
||||
|
||||
# npm/yarn
|
||||
|
@ -1,6 +1,5 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"semi": true,
|
||||
"tabWidth": 4
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"editor.formatOnSave": true
|
||||
}
|
3
commitlint.config.js
Normal file
3
commitlint.config.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
extends: ['@commitlint/config-conventional']
|
||||
};
|
1750
package-lock.json
generated
1750
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@ -9,6 +9,8 @@
|
||||
"axios": "^0.21.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^12.1.1",
|
||||
"@commitlint/config-conventional": "^12.1.1",
|
||||
"@types/chromecast-caf-receiver": "^5.0.12",
|
||||
"@types/jest": "^26.0.22",
|
||||
"@types/node": "^14.14.39",
|
||||
@ -20,12 +22,14 @@
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"css-loader": "^5.2.1",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"eslint": "^7.24.0",
|
||||
"eslint-config-prettier": "^8.2.0",
|
||||
"eslint-import-resolver-typescript": "^2.3.0",
|
||||
"eslint-import-resolver-typescript": "^2.4.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-jsdoc": "^32.3.0",
|
||||
"eslint-plugin-prettier": "^3.3.0",
|
||||
"eslint-plugin-json": "^2.1.2",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"eslint-plugin-promise": "^5.1.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"html-loader": "^2.1.2",
|
||||
@ -35,10 +39,9 @@
|
||||
"imagemin-svgo": "^8.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"prettier": "^2.2.1",
|
||||
"pretty-quick": "^3.1.0",
|
||||
"source-map-loader": "^2.0.1",
|
||||
"style-loader": "^2.0.0",
|
||||
"stylelint": "^13.8.0",
|
||||
"stylelint": "^13.12.0",
|
||||
"stylelint-config-prettier": "^8.0.2",
|
||||
"stylelint-config-standard": "^21.0.0",
|
||||
"ts-jest": "^26.5.4",
|
||||
@ -52,15 +55,15 @@
|
||||
"webpack-dev-server": "^3.11.0",
|
||||
"webpack-merge": "^5.4.1"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
}
|
||||
},
|
||||
"engines": {
|
||||
"yarn": "YARN NO LONGER USED - use npm instead."
|
||||
},
|
||||
"homepage": "https://jellyfin.org/",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged"
|
||||
}
|
||||
},
|
||||
"license": "GPL-2.0-or-later",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -70,9 +73,9 @@
|
||||
"build:development": "TS_NODE_PROJECT=\"tsconfig-webpack.json\" webpack --config webpack.config.ts --mode=development",
|
||||
"build:production": "TS_NODE_PROJECT=\"tsconfig-webpack.json\" webpack --config webpack.config.ts --mode=production",
|
||||
"lint": "npm run lint:code && npm run lint:css && npm run prettier",
|
||||
"lint:code": "eslint --ext .ts,.js .",
|
||||
"lint:css": "stylelint ./src/css/*.css",
|
||||
"prepare": "npm run build:production && husky install",
|
||||
"lint:code": "eslint --ext .ts,.js,.json .",
|
||||
"lint:css": "stylelint **/*.css",
|
||||
"prepare": "npm run build:production",
|
||||
"prettier": "prettier --check .",
|
||||
"start": "TS_NODE_PROJECT=\"tsconfig-webpack.json\" webpack serve --config webpack.config.ts",
|
||||
"test": "jest --passWithNoTests",
|
||||
|
7
stylelint.config.js
Normal file
7
stylelint.config.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
syntax: 'css',
|
||||
extends: ['stylelint-config-standard', 'stylelint-config-prettier'],
|
||||
rules: {
|
||||
'at-rule-no-unknown': null
|
||||
}
|
||||
};
|
@ -18,5 +18,5 @@
|
||||
"@types/node",
|
||||
"@types/chromecast-caf-receiver"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,102 +7,101 @@ import { merge } from 'webpack-merge';
|
||||
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
import ImageMinimizerPlugin from 'image-minimizer-webpack-plugin';
|
||||
import version from './package.json';
|
||||
import { version } from './package.json';
|
||||
|
||||
const common: webpack.Configuration = {
|
||||
context: path.resolve(__dirname, 'src'),
|
||||
entry: './app.ts',
|
||||
output: {
|
||||
filename: '[name].[fullhash].js',
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
publicPath: './'
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js']
|
||||
},
|
||||
plugins: [
|
||||
// @ts-expect-error - Typings mismatch between versions
|
||||
new CleanWebpackPlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
filename: 'index.html',
|
||||
template: 'index.html',
|
||||
hash: false,
|
||||
favicon: 'favicon.ico'
|
||||
}),
|
||||
new ImageMinimizerPlugin({
|
||||
minimizerOptions: {
|
||||
plugins: [
|
||||
[
|
||||
'svgo',
|
||||
{
|
||||
plugins: [
|
||||
{
|
||||
removeComments: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
context: path.resolve(__dirname, 'src'),
|
||||
entry: './app.ts',
|
||||
output: {
|
||||
filename: '[name].[fullhash].js',
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
publicPath: './'
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js']
|
||||
},
|
||||
plugins: [
|
||||
// @ts-expect-error - Typings mismatch between versions
|
||||
new CleanWebpackPlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
filename: 'index.html',
|
||||
template: 'index.html',
|
||||
hash: false,
|
||||
favicon: 'favicon.ico'
|
||||
}),
|
||||
new ImageMinimizerPlugin({
|
||||
minimizerOptions: {
|
||||
plugins: [
|
||||
[
|
||||
'svgo',
|
||||
{
|
||||
plugins: [
|
||||
{
|
||||
removeComments: false
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{ test: /\.html$/, loader: 'html-loader' },
|
||||
{
|
||||
test: /\.(png|svg|jpg|gif)$/,
|
||||
use: 'file-loader'
|
||||
},
|
||||
{
|
||||
test: /\.(ttf|eot|woff(2)?)(\?[a-z0-9=&.]+)?$/,
|
||||
loader: 'file-loader'
|
||||
},
|
||||
{ test: /\.css$/i, use: ['style-loader', 'css-loader'] },
|
||||
{ test: /\.tsx?$/, loader: 'ts-loader' },
|
||||
{ test: /\.js$/, loader: 'source-map-loader' }
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{ test: /\.html$/, loader: 'html-loader' },
|
||||
{
|
||||
test: /\.(png|svg|jpg|gif)$/,
|
||||
use: 'file-loader'
|
||||
},
|
||||
{
|
||||
test: /\.(ttf|eot|woff(2)?)(\?[a-z0-9=&.]+)?$/,
|
||||
loader: 'file-loader'
|
||||
},
|
||||
{ test: /\.css$/i, use: ['style-loader', 'css-loader'] },
|
||||
{ test: /\.tsx?$/, loader: 'ts-loader' },
|
||||
{ test: /\.js$/, loader: 'source-map-loader' }
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
const development: webpack.Configuration = {
|
||||
mode: 'development',
|
||||
devtool: 'inline-source-map',
|
||||
// @ts-expect-error - Typings mismatch between versions
|
||||
devServer: {
|
||||
contentBase: path.join(__dirname, 'dist'),
|
||||
compress: true,
|
||||
port: process.env.RECEIVER_PORT
|
||||
? Number.parseInt(process.env.RECEIVER_PORT, 10)
|
||||
: 9000,
|
||||
publicPath: '/'
|
||||
},
|
||||
plugins: [
|
||||
new DefinePlugin({
|
||||
PRODUCTION: JSON.stringify(false),
|
||||
RECEIVERVERSION: JSON.stringify(version)
|
||||
})
|
||||
]
|
||||
mode: 'development',
|
||||
devtool: 'inline-source-map',
|
||||
// @ts-expect-error - Typings mismatch between versions
|
||||
devServer: {
|
||||
contentBase: path.join(__dirname, 'dist'),
|
||||
compress: true,
|
||||
port: process.env.RECEIVER_PORT
|
||||
? Number.parseInt(process.env.RECEIVER_PORT, 10)
|
||||
: 9000,
|
||||
publicPath: '/'
|
||||
},
|
||||
plugins: [
|
||||
new DefinePlugin({
|
||||
PRODUCTION: JSON.stringify(false),
|
||||
RECEIVERVERSION: JSON.stringify(version)
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
const production: webpack.Configuration = {
|
||||
mode: 'production',
|
||||
plugins: [
|
||||
new DefinePlugin({
|
||||
PRODUCTION: JSON.stringify(true),
|
||||
RECEIVERVERSION: JSON.stringify(version)
|
||||
})
|
||||
]
|
||||
mode: 'production',
|
||||
plugins: [
|
||||
new DefinePlugin({
|
||||
PRODUCTION: JSON.stringify(true),
|
||||
RECEIVERVERSION: JSON.stringify(version)
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
module.exports = (
|
||||
argv: { [key: string]: string }
|
||||
): webpack.Configuration => {
|
||||
let config;
|
||||
if (argv.mode === 'production') {
|
||||
config = merge(common, production);
|
||||
} else {
|
||||
config = merge(common, development);
|
||||
}
|
||||
module.exports = (argv: { [key: string]: string }): webpack.Configuration => {
|
||||
let config;
|
||||
|
||||
return config;
|
||||
if (argv.mode === 'production') {
|
||||
config = merge(common, production);
|
||||
} else {
|
||||
config = merge(common, development);
|
||||
}
|
||||
|
||||
return config;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user