Browse Source

Lint

pull/937/head
Sergei Birukov 2 years ago
parent
commit
27ec63d3e3
  1. 2
      src/.eslintrc.json
  2. 1
      src/config.js
  3. 3
      webui/.eslintrc.cjs
  4. 3
      webui/package.json
  5. 2
      webui/postcss.config.js
  6. 8
      webui/src/composables/useBytes.js
  7. 16
      webui/vite.config.js

2
src/.eslintrc.json

@ -1,7 +1,7 @@
{ {
"extends": "athom", "extends": "athom",
"ignorePatterns": [ "ignorePatterns": [
"**/vendor/*.js" "node_modules/**/*"
], ],
"rules": { "rules": {
"consistent-return": "off", "consistent-return": "off",

1
src/config.js

@ -1,7 +1,6 @@
'use strict'; 'use strict';
const { release } = require('./package.json'); const { release } = require('./package.json');
require('dotenv').config(); // development
module.exports.RELEASE = release; module.exports.RELEASE = release;
module.exports.PORT = process.env.PORT || '51821'; module.exports.PORT = process.env.PORT || '51821';

3
webui/.eslintrc.cjs

@ -5,6 +5,7 @@ module.exports = {
es2021: true, es2021: true,
}, },
extends: ['eslint:recommended', 'plugin:vue/vue3-recommended', 'prettier'], extends: ['eslint:recommended', 'plugin:vue/vue3-recommended', 'prettier'],
ignorePatterns: ['dist/**/*', 'node_modules/**/*'],
parser: 'vue-eslint-parser', parser: 'vue-eslint-parser',
// parserOptions: { // parserOptions: {
// parser: '@typescript-eslint/parser', // parser: '@typescript-eslint/parser',
@ -15,7 +16,5 @@ module.exports = {
'vue/no-v-html': 'off', 'vue/no-v-html': 'off',
'vue/multi-word-component-names': 'off', 'vue/multi-word-component-names': 'off',
'prettier/prettier': ['error'], 'prettier/prettier': ['error'],
'vue/no-undef-components': ['error'],
'vue/no-undef-properties': ['error'],
}, },
}; };

3
webui/package.json

@ -7,7 +7,8 @@
"dev": "vite --host", "dev": "vite --host",
"build": "vite build", "build": "vite build",
"build:watch": "vite build --watch", "build:watch": "vite build --watch",
"preview": "vite preview" "preview": "vite preview",
"lint": "eslint ."
}, },
"dependencies": { "dependencies": {
"apexcharts": "^3.48.0", "apexcharts": "^3.48.0",

2
webui/postcss.config.js

@ -3,4 +3,4 @@ export default {
tailwindcss: {}, tailwindcss: {},
autoprefixer: {}, autoprefixer: {},
}, },
} };

8
webui/src/composables/useBytes.js

@ -2,13 +2,9 @@ export function useBytes() {
const bytes = (bytes, decimals, kib, maxunit) => { const bytes = (bytes, decimals, kib, maxunit) => {
kib = kib || false; kib = kib || false;
if (bytes === 0) return '0 B'; if (bytes === 0) return '0 B';
if (Number.isNaN(parseFloat(bytes)) && !Number.isFinite(bytes)) if (Number.isNaN(parseFloat(bytes)) && !Number.isFinite(bytes)) return 'NaN';
return 'NaN';
const k = kib ? 1024 : 1000; const k = kib ? 1024 : 1000;
const dm = const dm = decimals != null && !Number.isNaN(decimals) && decimals >= 0 ? decimals : 2;
decimals != null && !Number.isNaN(decimals) && decimals >= 0
? decimals
: 2;
const sizes = kib const sizes = kib
? ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB', 'BiB'] ? ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB', 'BiB']
: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'BB']; : ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'BB'];

16
webui/vite.config.js

@ -1,17 +1,15 @@
import { fileURLToPath, URL } from 'node:url' import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite' import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue';
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [vue()],
vue(),
],
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)) '@': fileURLToPath(new URL('./src', import.meta.url)),
} },
}, },
build: { build: {
outDir: 'dist', outDir: 'dist',
@ -23,4 +21,4 @@ export default defineConfig({
// } // }
// } // }
}, },
}) });

Loading…
Cancel
Save