From ff9715b9247ecb05d9f3090c80432c950d28c379 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Tue, 17 Sep 2024 01:15:29 +0200 Subject: [PATCH] add eslint and stylelint on vite build Signed-off-by: Julien Veyssier --- .eslintrc.js => .eslintrc.cjs | 0 package-lock.json | 83 ++++++++++++++++++++- package.json | 4 +- src/dashboard.js | 8 +- src/main.js | 8 +- stylelint.config.js => stylelint.config.cjs | 0 vite.config.ts | 3 + 7 files changed, 96 insertions(+), 10 deletions(-) rename .eslintrc.js => .eslintrc.cjs (100%) rename stylelint.config.js => stylelint.config.cjs (100%) diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/package-lock.json b/package-lock.json index 9ebb7aa9..43131a3e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,7 +41,9 @@ "@nextcloud/vite-config": "^1.4.2", "eslint-webpack-plugin": "^4.0.0", "stylelint": "^16.5.0", - "stylelint-webpack-plugin": "^5.0.0" + "stylelint-webpack-plugin": "^5.0.0", + "vite-plugin-eslint": "^1.8.1", + "vite-plugin-stylelint": "^5.3.1" }, "engines": { "node": "^16.0.0", @@ -16194,6 +16196,52 @@ } } }, + "node_modules/vite-plugin-eslint": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/vite-plugin-eslint/-/vite-plugin-eslint-1.8.1.tgz", + "integrity": "sha512-PqdMf3Y2fLO9FsNPmMX+//2BF5SF8nEWspZdgl4kSt7UvHDRHVVfHvxsD7ULYzZrJDGRxR81Nq7TOFgwMnUang==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^4.2.1", + "@types/eslint": "^8.4.5", + "rollup": "^2.77.2" + }, + "peerDependencies": { + "eslint": ">=7", + "vite": ">=2" + } + }, + "node_modules/vite-plugin-eslint/node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/vite-plugin-eslint/node_modules/rollup": { + "version": "2.79.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", + "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", + "dev": true, + "license": "MIT", + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/vite-plugin-node-polyfills": { "version": "0.22.0", "resolved": "https://registry.npmjs.org/vite-plugin-node-polyfills/-/vite-plugin-node-polyfills-0.22.0.tgz", @@ -16211,6 +16259,39 @@ "vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0" } }, + "node_modules/vite-plugin-stylelint": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/vite-plugin-stylelint/-/vite-plugin-stylelint-5.3.1.tgz", + "integrity": "sha512-M/hSdfOwnOVghbJDeuuYIU2xO/MMukYR8QcEyNKFPG8ro1L+DlTdViix2B2d/FvAw14WPX88ckA5A7NvUjJz8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.1.0", + "chokidar": "^3.5.3", + "debug": "^4.3.4" + }, + "engines": { + "node": ">=14.18" + }, + "peerDependencies": { + "@types/stylelint": "^13.0.0", + "postcss": "^7.0.0 || ^8.0.0", + "rollup": "^2.0.0 || ^3.0.0 || ^4.0.0", + "stylelint": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0", + "vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0" + }, + "peerDependenciesMeta": { + "@types/stylelint": { + "optional": true + }, + "postcss": { + "optional": true + }, + "rollup": { + "optional": true + } + } + }, "node_modules/vite/node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", diff --git a/package.json b/package.json index 794b4664..bdec7a15 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,8 @@ "@nextcloud/vite-config": "^1.4.2", "eslint-webpack-plugin": "^4.0.0", "stylelint": "^16.5.0", - "stylelint-webpack-plugin": "^5.0.0" + "stylelint-webpack-plugin": "^5.0.0", + "vite-plugin-eslint": "^1.8.1", + "vite-plugin-stylelint": "^5.3.1" } } diff --git a/src/dashboard.js b/src/dashboard.js index d300f952..44b2c656 100644 --- a/src/dashboard.js +++ b/src/dashboard.js @@ -9,11 +9,11 @@ * @copyright Julien Veyssier 2020 */ -import { linkTo } from '@nextcloud/router' -import { getRequestToken } from '@nextcloud/auth' +// import { linkTo } from '@nextcloud/router' +// import { getRequestToken } from '@nextcloud/auth' -//__webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-line -//__webpack_public_path__ = linkTo('cospend', 'js/') // eslint-disable-line +// __webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-line +// __webpack_public_path__ = linkTo('cospend', 'js/') // eslint-disable-line document.addEventListener('DOMContentLoaded', () => { OCA.Dashboard.register('cospend_activity', async (el, { widget }) => { diff --git a/src/main.js b/src/main.js index 5c73cf18..374478c0 100644 --- a/src/main.js +++ b/src/main.js @@ -14,8 +14,8 @@ import './bootstrap.js' import App from './App.vue' import { showError } from '@nextcloud/dialogs' import '@nextcloud/dialogs/style.css' -import { getRequestToken } from '@nextcloud/auth' -import { generateFilePath } from '@nextcloud/router' +// import { getRequestToken } from '@nextcloud/auth' +// import { generateFilePath } from '@nextcloud/router' import { loadState } from '@nextcloud/initial-state' import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js' import vueAwesomeCountdown from 'vue-awesome-countdown' @@ -31,8 +31,8 @@ Vue.use(VueClipboard) Vue.use(SmartTable) Vue.directive('tooltip', Tooltip) -//__webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-line -//__webpack_public_path__ = generateFilePath('cospend', '', 'js/') // eslint-disable-line +// __webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-line +// __webpack_public_path__ = generateFilePath('cospend', '', 'js/') // eslint-disable-line function restoreOptions() { network.getOptionValues().then((response) => { diff --git a/stylelint.config.js b/stylelint.config.cjs similarity index 100% rename from stylelint.config.js rename to stylelint.config.cjs diff --git a/vite.config.ts b/vite.config.ts index f6515067..fc5c32b9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,6 +3,8 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ import { createAppConfig } from '@nextcloud/vite-config' +import eslint from 'vite-plugin-eslint' +import stylelint from 'vite-plugin-stylelint' export default createAppConfig({ main: 'src/main.js', @@ -16,6 +18,7 @@ export default createAppConfig({ localsConvention: 'camelCase', }, }, + plugins: [eslint(), stylelint()], }, inlineCSS: { relativeCSSInjection: true }, })