How can I disable 'Insert `0` eslint(prettier/prettier)'? - eslint

I have a React application with Styled Components with ESlint / Stylelint / Prettier that makes a conflict of rules that excludes number-leading-zero on css rules.
So given this code:
import React from 'react';
import styled from 'styled-components/macro';
import { About } from '../styles';
const Faq = styled(About)`
display: block;
span {
display: block;
}
h2 {
padding-bottom: .2rem;
font-weight: lighter;
}
.faq-line {
width: 100%;
height: .2rem;
margin: 2rem 0;
background: #ccc;
}
I get printed in the console:
Insert `0` eslint(prettier/prettier) [13, 21]
Insert `0` eslint(prettier/prettier) [19, 13]
I want to keep prettier format rules but disabling this one that conflicts with my stylelint config rules.
Here's my .eslintrc.js:
module.exports = {
root: true,
env: {
node: true,
es6: true,
},
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module', // Allows for the use of imports
project: './tsconfig.json',
tsconfigRootDir: './',
},
ignorePatterns: ['node_modules/*', '.next/*', '.out/*', '!.prettierrc.js'],
extends: ['eslint:recommended'],
overrides: [
// This configuration will apply only to TypeScript files
{
files: ['**/*.ts', '**/*.tsx'],
parser: '#typescript-eslint/parser',
settings: { react: { version: 'detect' } },
env: {
browser: true,
node: true,
es6: true,
},
plugins: ['testing-library', 'jest-dom', 'import'],
extends: [
'eslint:recommended',
'plugin:#typescript-eslint/recommended', // TypeScript rules
'plugin:react/recommended', // React rules
'plugin:react-hooks/recommended', // React hooks rules
'plugin:testing-library/recommended',
'plugin:testing-library/react',
'plugin:jest-dom/recommended',
'plugin:jsx-a11y/recommended', // Accessibility rules
'plugin:prettier/recommended', // Prettier recommended rules
],
rules: {
// eslint-plugin-import rules
'import/named': 'error',
'import/namespace': 'error',
'import/default': 'error',
'import/export': 'error',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
alphabetize: {
order: 'asc',
},
pathGroups: [
{
pattern: 'react',
group: 'builtin',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
// React, Next & Typescript rules
// We will use TypeScript's types for component props instead
'react/prop-types': 'off',
// No need to import React when using Next.js
'react/react-in-jsx-scope': 'off',
// This rule is not compatible with Next.js's <Link /> components
'jsx-a11y/anchor-is-valid': 'off',
// Why would you want unused vars?
'#typescript-eslint/no-unused-vars': ['error'],
// I suggest this setting for requiring return types on functions only where useful
'#typescript-eslint/explicit-function-return-type': [
'warn',
{
allowExpressions: true,
allowConciseArrowFunctionExpressionsStartingWithVoid: true,
},
],
'prettier/prettier': ['error', {}, { usePrettierrc: true }], // Includes .prettierrc.js rules
},
},
],
};
.stylelintrc:
{
"extends": [
"stylelint-config-standard",
"stylelint-a11y/recommended"
],
"plugins": [
"stylelint-a11y",
"stylelint-order"
],
"rules": {
"number-leading-zero": "never",
"a11y/font-size-is-readable": true,
"a11y/no-text-align-justify": true,
"a11y/no-obsolete-element": true,
"a11y/no-obsolete-attribute": true,
"a11y/content-property-no-static-value": true,
"order/properties-order": [
"top",
"bottom",
"right",
"left",
"width",
"height",
"margin",
"padding",
"color",
"text-align",
"text-decoration",
"font-size",
"font-weight",
"border",
"border-radius"
]
}
}
.prettierrc:
{
"arrowParens": "avoid",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": true,
"printWidth": 80,
"proseWrap": "always",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false,
"vueIndentScriptAndStyle": false
}
DevDependencies:
"#types/styled-components": "^5.1.7",
"#typescript-eslint/eslint-plugin": "^4.16.1",
"#typescript-eslint/parser": "^4.16.1",
"eslint": "^7.21.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest-dom": "^3.6.5",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^3.10.1",
"husky": "^5.1.3",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"prettier-stylelint": "^0.4.2",
"stylelint": "^13.11.0",
"stylelint-a11y": "^1.2.3",
"stylelint-config-standard": "^20.0.0",
"stylelint-order": "^4.1.0"

I want to keep prettier format rules but disabling this one that conflicts with my stylelint config rules.
When using Prettier, it's not possible to turn off leading zeros before numbers. Prettier is a opinionated formatter with a limited set of options.
You can ignore sections of code using special comments, e.g.:
const Faq = styled(About)`
h2 {
/* prettier-ignore */
padding-bottom: .2rem;
}
But this is may not be desirable.
If you intend to use Prettier, I recommend embracing its opinions and configuring stylelint so that it doesn't conflict with it. The stylelint-config-prettier config turns off any rules in stylelint that overlap with Prettier's formatting.

Related

quasar: When building an app it gives vite error

When I do quasar build it gives the following:
deb2302user#deb2302:~/tmp2303/vue/kitty$ quasar build
.d88888b.
d88P" "Y88b
888 888
888 888 888 888 8888b. .d8888b 8888b. 888d888
888 888 888 888 "88b 88K "88b 888P"
888 Y8b 888 888 888 .d888888 "Y8888b. .d888888 888
Y88b.Y8b88P Y88b 888 888 888 X88 888 888 888
"Y888888" "Y88888 "Y888888 88888P' "Y888888 888
Y8b
Build mode............. spa
Pkg quasar............. v2.11.3
Pkg #quasar/app-vite... v1.1.3
Pkg vite............... v2.9.15
Debugging.............. no
Publishing............. no
App • Cleaned build artifact: "/home/deb2302user/tmp2303/vue/kitty/dist/spa"
App • WAIT • Compiling of SPA UI with Vite in progress...
[vite:resolve] Missing "./preload-helper" export in "vite" package
/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vite#2.9.15_sass#1.32.12/node_modules/vite/dist/node/chunks/dep-689425f3.js:38597
throw new Error(
^
Error: Missing "./preload-helper" export in "vite" package
at bail (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vite#2.9.15_sass#1.32.12/node_modules/vite/dist/node/chunks/dep-689425f3.js:38597:8)
at resolve (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vite#2.9.15_sass#1.32.12/node_modules/vite/dist/node/chunks/dep-689425f3.js:38674:10)
at resolveExports (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vite#2.9.15_sass#1.32.12/node_modules/vite/dist/node/chunks/dep-689425f3.js:40982:12)
at resolveDeepImport (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vite#2.9.15_sass#1.32.12/node_modules/vite/dist/node/chunks/dep-689425f3.js:41000:31)
at tryNodeResolve (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vite#2.9.15_sass#1.32.12/node_modules/vite/dist/node/chunks/dep-689425f3.js:40773:20)
at Object.resolveId (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vite#2.9.15_sass#1.32.12/node_modules/vite/dist/node/chunks/dep-689425f3.js:40581:28)
at /home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/rollup#2.77.3/node_modules/rollup/dist/shared/rollup.js:22826:37 {
code: 'PLUGIN_ERROR',
plugin: 'vite:resolve',
hook: 'resolveId',
watchFiles: [
'/home/deb2302user/tmp2303/vue/kitty/index.html',
'/home/deb2302user/tmp2303/vue/kitty/.quasar/client-entry.js',
'/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vite#4.1.1_#types+node#12.20.55/node_modules/vite/package.json',
'/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vue#3.2.45/node_modules/vue/package.json',
'/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+extras#1.15.9/node_modules/#quasar/extras/package.json',
'/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/quasar#2.11.3/node_modules/quasar/package.json',
'/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/vue#3.2.45/node_modules/vue/dist/vue.runtime.esm-bundler.js',
'/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+extras#1.15.9/node_modules/#quasar/extras/roboto-font/roboto-font.css',
'/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+extras#1.15.9/node_modules/#quasar/extras/material-icons/material-icons.css',
'/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+extras#1.15.9/node_modules/#quasar/extras/material-icons-outlined/material-icons-outlined.css',
'/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/quasar#2.11.3/node_modules/quasar/dist/quasar.sass',
'/home/deb2302user/tmp2303/vue/kitty/.quasar/app.js',
'/home/deb2302user/tmp2303/vue/kitty/.quasar/quasar-user-options.js'
]
}
Node.js v18.14.0
package.json
{
"name": "kitty",
"version": "0.0.1",
"private": true,
"description": "Kitty desc",
"author": "none <none>",
"scripts": {
"lint": "eslint --ext .js,.ts,.vue ./",
"format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore",
"test": "echo \"No test specified\" && exit 0"
},
"dependencies": {
"#quasar/extras": "^1.0.0",
"#vitejs/plugin-vue-jsx": "^3.0.0",
"#vue/babel-plugin-jsx": "^1.1.1",
"#vue/cli-plugin-babel": "^5.0.8",
"#vueuse/core": "^9.11.1",
"axios": "^0.21.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"core-js": "^3.8.3",
"d3": "^7.8.1",
"jquery": "^3.6.3",
"pinia": "^2.0.11",
"quasar": "^2.6.0",
"vue": "^3.0.0",
"vue-i18n": "^9.2.2",
"vue-router": "^4.0.0"
},
"devDependencies": {
"#intlify/vite-plugin-vue-i18n": "^3.3.1",
"#quasar/app-vite": "^1.0.0",
"#types/node": "^12.20.21",
"#typescript-eslint/eslint-plugin": "^5.10.0",
"#typescript-eslint/parser": "^5.10.0",
"autoprefixer": "^10.4.2",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-vue": "^9.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4",
"vite": "^4"
},
"engines": {
"node": "^18 || ^16 || ^14.19",
"npm": ">= 6.13.4",
"yarn": ">= 1.21.1"
},
"productName": "Kitty"
}
quasar.config.js
/* eslint-env node */
/*
* This file runs in a Node context (it's NOT transpiled by Babel), so use only
* the ES6 features that are supported by your Node version. https://node.green/
*/
// Configuration for your app
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js
const { configure } = require('quasar/wrappers');
const path = require('path');
module.exports = configure(function (/* ctx */) {
return {
eslint: {
// fix: true,
// include = [],
// exclude = [],
// rawOptions = {},
warnings: true,
errors: true
},
// https://v2.quasar.dev/quasar-cli-vite/prefetch-feature
// preFetch: true,
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli-vite/boot-files
boot: [
'i18n',
'axios',
],
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
css: [
'app.scss'
],
// https://github.com/quasarframework/quasar/tree/dev/extras
extras: [
// 'ionicons-v4',
// 'mdi-v5',
// 'fontawesome-v6',
// 'eva-icons',
// 'themify',
// 'line-awesome',
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
'roboto-font', // optional, you are not bound to it
'material-icons', // optional, you are not bound to it
'material-icons-outlined',
],
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#build
build: {
target: {
browser: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
node: 'node16'
},
vueRouterMode: 'history', // available values: 'hash', 'history'
// vueRouterBase,
// vueDevtools,
// vueOptionsAPI: false,
// rebuildCache: true, // rebuilds Vite/linter/etc cache on startup
// publicPath: '/',
// analyze: true,
// env: {},
// rawDefine: {}
// ignorePublicFolder: true,
// minify: false,
// polyfillModulePreload: true,
// distDir
// extendViteConf (viteConf) {},
// viteVuePluginOptions: {},
vitePlugins: [
['#intlify/vite-plugin-vue-i18n', {
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
// compositionOnly: false,
// you need to set i18n resource including paths !
include: path.resolve(__dirname, './src/i18n/**')
}
],
['#vitejs/plugin-vue-jsx', {}
]
]
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#devServer
devServer: {
// https: true
open: true // opens browser window automatically
},
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
framework: {
config: {},
// iconSet: 'material-icons', // Quasar icon set
// lang: 'en-US', // Quasar language pack
// For special cases outside of where the auto-import strategy can have an impact
// (like functional components as one of the examples),
// you can manually specify Quasar components/directives to be available everywhere:
//
components: [
'QLayout',
'QHeader',
'QDrawer',
'QPageContainer',
'QPage',
'QToolbar',
'QToolbarTitle',
'QBtn',
'QBtnGroup',
'QIcon',
'QList',
'QItem',
'QItemSection',
'QItemLabel',
'QTooltip',
'QInput',
'QCard',
'QCardSection',
'QCardActions',
'QDialog',
'QForm',
'QFooter',
'QAvatar',
'QScrollArea',
'QImg',
'QTabs',
'QTab',
'QRouteTab',
'QTabPanels',
'QTabPanel',
'QFab',
'QFabAction',
'QSeparator',
'QBar',
'QSpace',
'QSelect',
'QRadio',
'QTime',
'QDate',
'QPopupProxy',
'QTable',
'QTh',
'QTr',
'QTd',
'QCheckbox',
'QToggle',
'QSpinnerHourglass',
'QPageSticky',
'QTimeline',
'QTimelineEntry',
'QBadge',
'QStepper',
'QStep',
'QStepperNavigation',
'QMenu',
],
directives: [
'ClosePopup'
],
// Quasar plugins
plugins: [
'Notify'
]
},
// animations: 'all', // --- includes all animations
// https://v2.quasar.dev/options/animations
animations: [],
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#sourcefiles
// sourceFiles: {
// rootComponent: 'src/App.vue',
// router: 'src/router/index',
// store: 'src/store/index',
// registerServiceWorker: 'src-pwa/register-service-worker',
// serviceWorker: 'src-pwa/custom-service-worker',
// pwaManifestFile: 'src-pwa/manifest.json',
// electronMain: 'src-electron/electron-main',
// electronPreload: 'src-electron/electron-preload'
// },
// https://v2.quasar.dev/quasar-cli-vite/developing-ssr/configuring-ssr
ssr: {
// ssrPwaHtmlFilename: 'offline.html', // do NOT use index.html as name!
// will mess up SSR
// extendSSRWebserverConf (esbuildConf) {},
// extendPackageJson (json) {},
pwa: false,
// manualStoreHydration: true,
// manualPostHydrationTrigger: true,
prodPort: 3000, // The default port that the production server should use
// (gets superseded if process.env.PORT is specified at runtime)
middlewares: [
'render' // keep this as last one
]
},
// https://v2.quasar.dev/quasar-cli-vite/developing-pwa/configuring-pwa
pwa: {
workboxMode: 'generateSW', // or 'injectManifest'
injectPwaMetaTags: true,
swFilename: 'sw.js',
manifestFilename: 'manifest.json',
useCredentialsForManifestTag: false,
// useFilenameHashes: true,
// extendGenerateSWOptions (cfg) {}
// extendInjectManifestOptions (cfg) {},
// extendManifestJson (json) {}
// extendPWACustomSWConf (esbuildConf) {}
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-cordova-apps/configuring-cordova
cordova: {
// noIosLegacyBuildFlag: true, // uncomment only if you know what you are doing
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-capacitor-apps/configuring-capacitor
capacitor: {
hideSplashscreen: true
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-electron-apps/configuring-electron
electron: {
// extendElectronMainConf (esbuildConf)
// extendElectronPreloadConf (esbuildConf)
inspectPort: 5858,
bundler: 'packager', // 'packager' or 'builder'
packager: {
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
// OS X / Mac App Store
// appBundleId: '',
// appCategoryType: '',
// osxSign: '',
// protocol: 'myapp://path',
// Windows only
// win32metadata: { ... }
},
builder: {
// https://www.electron.build/configuration/configuration
appId: 'kitty'
}
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-browser-extensions/configuring-bex
bex: {
contentScripts: [
'my-content-script'
],
// extendBexScriptsConf (esbuildConf) {}
// extendBexManifestJson (json) {}
}
}
});
quasar dev by itself works as expected
You need to downgrade vite dependency to version v2.9.15. At the start of the build log you can see that Quasar is using that version.

quasar build gives error: vite.createFilter is not a function

quasar build gives vite error.
From the last issue, quasar: When building an app it gives vite error. I have changed "vite": "^3" to "vite": "2.9.14" in package.json , that resolved that last error, though now I'm getting a new one
deb2302user#deb2302:~/tmp2303/vue/kitty$ quasar build
.d88888b.
d88P" "Y88b
888 888
888 888 888 888 8888b. .d8888b 8888b. 888d888
888 888 888 888 "88b 88K "88b 888P"
888 Y8b 888 888 888 .d888888 "Y8888b. .d888888 888
Y88b.Y8b88P Y88b 888 888 888 X88 888 888 888
"Y888888" "Y88888 "Y888888 88888P' "Y888888 888
Y8b
Build mode............. spa
Pkg quasar............. v2.11.3
Pkg #quasar/app-vite... v1.1.3
Pkg vite............... v2.9.14
Debugging.............. no
Publishing............. no
App • Cleaned build artifact: "/home/deb2302user/tmp2303/vue/kitty/dist/spa"
/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#vitejs+plugin-vue-jsx#3.0.0_vite#2.9.14+vue#3.2.45/node_modules/#vitejs/plugin-vue-jsx/dist/index.cjs:40
const filter = vite.createFilter(include || /\.[jt]sx$/, exclude);
^
TypeError: vite.createFilter is not a function
at vueJsxPlugin (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#vitejs+plugin-vue-jsx#3.0.0_vite#2.9.14+vue#3.2.45/node_modules/#vitejs/plugin-vue-jsx/dist/index.cjs:40:23)
at /home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+app-vite#1.1.3_lezvi6egse7w7wgglmky3dvexq/node_modules/#quasar/app-vite/lib/config-tools.js:70:40
at Array.forEach (<anonymous>)
at parseVitePlugins (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+app-vite#1.1.3_lezvi6egse7w7wgglmky3dvexq/node_modules/#quasar/app-vite/lib/config-tools.js:25:11)
at createViteConfig (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+app-vite#1.1.3_lezvi6egse7w7wgglmky3dvexq/node_modules/#quasar/app-vite/lib/config-tools.js:137:10)
at Object.vite (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+app-vite#1.1.3_lezvi6egse7w7wgglmky3dvexq/node_modules/#quasar/app-vite/lib/modes/spa/spa-config.js:6:17)
at SpaBuilder.build (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+app-vite#1.1.3_lezvi6egse7w7wgglmky3dvexq/node_modules/#quasar/app-vite/lib/modes/spa/spa-builder.js:7:37)
at build (/home/deb2302user/tmp2303/vue/kitty/node_modules/.pnpm/#quasar+app-vite#1.1.3_lezvi6egse7w7wgglmky3dvexq/node_modules/#quasar/app-vite/lib/cmd/build.js:162:14)
Node.js v18.14.0
package.json
{
"name": "kitty",
"version": "0.0.1",
"private": true,
"description": "Kitty desc",
"author": "amirny2205 <amirny2205#yandex.ru>",
"scripts": {
"lint": "eslint --ext .js,.ts,.vue ./",
"format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore",
"test": "echo \"No test specified\" && exit 0"
},
"dependencies": {
"#quasar/extras": "^1.0.0",
"#vitejs/plugin-vue-jsx": "^3.0.0",
"#vue/babel-plugin-jsx": "^1.1.1",
"#vue/cli-plugin-babel": "^5.0.8",
"axios": "^0.21.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"core-js": "^3.8.3",
"jquery": "^3.6.3",
"pinia": "^2.0.11",
"quasar": "^2.6.0",
"vue": "^3.0.0",
"vue-i18n": "^9.2.2",
"vue-router": "^4.0.0"
},
"devDependencies": {
"#intlify/vite-plugin-vue-i18n": "^3.3.1",
"#quasar/app-vite": "^1.0.0",
"#types/node": "^12.20.21",
"#typescript-eslint/eslint-plugin": "^5.10.0",
"#typescript-eslint/parser": "^5.10.0",
"autoprefixer": "^10.4.2",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-vue": "^9.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4",
"vite": "2.9.14"
},
"engines": {
"node": "^18 || ^16 || ^14.19",
"npm": ">= 6.13.4",
"yarn": ">= 1.21.1"
},
"productName": "Kitty"
}
quasar.config.js
/* eslint-env node */
/*
* This file runs in a Node context (it's NOT transpiled by Babel), so use only
* the ES6 features that are supported by your Node version. https://node.green/
*/
// Configuration for your app
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js
const { configure } = require('quasar/wrappers');
const path = require('path');
module.exports = configure(function (/* ctx */) {
return {
eslint: {
// fix: true,
// include = [],
// exclude = [],
// rawOptions = {},
warnings: true,
errors: true
},
// https://v2.quasar.dev/quasar-cli-vite/prefetch-feature
// preFetch: true,
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli-vite/boot-files
boot: [
'i18n',
'axios',
],
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
css: [
'app.scss'
],
// https://github.com/quasarframework/quasar/tree/dev/extras
extras: [
// 'ionicons-v4',
// 'mdi-v5',
// 'fontawesome-v6',
// 'eva-icons',
// 'themify',
// 'line-awesome',
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
'roboto-font', // optional, you are not bound to it
'material-icons', // optional, you are not bound to it
'material-icons-outlined',
],
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#build
build: {
target: {
browser: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
node: 'node16'
},
vueRouterMode: 'history', // available values: 'hash', 'history'
// vueRouterBase,
// vueDevtools,
// vueOptionsAPI: false,
// rebuildCache: true, // rebuilds Vite/linter/etc cache on startup
// publicPath: '/',
// analyze: true,
// env: {},
// rawDefine: {}
// ignorePublicFolder: true,
// minify: false,
// polyfillModulePreload: true,
// distDir
// extendViteConf (viteConf) {},
// viteVuePluginOptions: {},
vitePlugins: [
['#intlify/vite-plugin-vue-i18n', {
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
// compositionOnly: false,
// you need to set i18n resource including paths !
include: path.resolve(__dirname, './src/i18n/**')
}
],
['#vitejs/plugin-vue-jsx', {}
]
]
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#devServer
devServer: {
// https: true
open: true // opens browser window automatically
},
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
framework: {
config: {},
// iconSet: 'material-icons', // Quasar icon set
// lang: 'en-US', // Quasar language pack
// For special cases outside of where the auto-import strategy can have an impact
// (like functional components as one of the examples),
// you can manually specify Quasar components/directives to be available everywhere:
//
components: [
'QLayout',
'QHeader',
'QDrawer',
'QPageContainer',
'QPage',
'QToolbar',
'QToolbarTitle',
'QBtn',
'QBtnGroup',
'QIcon',
'QList',
'QItem',
'QItemSection',
'QItemLabel',
'QTooltip',
'QInput',
'QCard',
'QCardSection',
'QCardActions',
'QDialog',
'QForm',
'QFooter',
'QAvatar',
'QScrollArea',
'QImg',
'QTabs',
'QTab',
'QRouteTab',
'QTabPanels',
'QTabPanel',
'QFab',
'QFabAction',
'QSeparator',
'QBar',
'QSpace',
'QSelect',
'QRadio',
'QTime',
'QDate',
'QPopupProxy',
'QTable',
'QTh',
'QTr',
'QTd',
'QCheckbox',
'QToggle',
'QSpinnerHourglass',
'QPageSticky',
'QTimeline',
'QTimelineEntry',
'QBadge',
'QStepper',
'QStep',
'QStepperNavigation',
'QMenu',
],
directives: [
'ClosePopup'
],
// Quasar plugins
plugins: [
'Notify'
]
},
// animations: 'all', // --- includes all animations
// https://v2.quasar.dev/options/animations
animations: [],
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#sourcefiles
// sourceFiles: {
// rootComponent: 'src/App.vue',
// router: 'src/router/index',
// store: 'src/store/index',
// registerServiceWorker: 'src-pwa/register-service-worker',
// serviceWorker: 'src-pwa/custom-service-worker',
// pwaManifestFile: 'src-pwa/manifest.json',
// electronMain: 'src-electron/electron-main',
// electronPreload: 'src-electron/electron-preload'
// },
// https://v2.quasar.dev/quasar-cli-vite/developing-ssr/configuring-ssr
ssr: {
// ssrPwaHtmlFilename: 'offline.html', // do NOT use index.html as name!
// will mess up SSR
// extendSSRWebserverConf (esbuildConf) {},
// extendPackageJson (json) {},
pwa: false,
// manualStoreHydration: true,
// manualPostHydrationTrigger: true,
prodPort: 3000, // The default port that the production server should use
// (gets superseded if process.env.PORT is specified at runtime)
middlewares: [
'render' // keep this as last one
]
},
// https://v2.quasar.dev/quasar-cli-vite/developing-pwa/configuring-pwa
pwa: {
workboxMode: 'generateSW', // or 'injectManifest'
injectPwaMetaTags: true,
swFilename: 'sw.js',
manifestFilename: 'manifest.json',
useCredentialsForManifestTag: false,
// useFilenameHashes: true,
// extendGenerateSWOptions (cfg) {}
// extendInjectManifestOptions (cfg) {},
// extendManifestJson (json) {}
// extendPWACustomSWConf (esbuildConf) {}
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-cordova-apps/configuring-cordova
cordova: {
// noIosLegacyBuildFlag: true, // uncomment only if you know what you are doing
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-capacitor-apps/configuring-capacitor
capacitor: {
hideSplashscreen: true
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-electron-apps/configuring-electron
electron: {
// extendElectronMainConf (esbuildConf)
// extendElectronPreloadConf (esbuildConf)
inspectPort: 5858,
bundler: 'packager', // 'packager' or 'builder'
packager: {
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
// OS X / Mac App Store
// appBundleId: '',
// appCategoryType: '',
// osxSign: '',
// protocol: 'myapp://path',
// Windows only
// win32metadata: { ... }
},
builder: {
// https://www.electron.build/configuration/configuration
appId: 'kitty'
}
},
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-browser-extensions/configuring-bex
bex: {
contentScripts: [
'my-content-script'
],
// extendBexScriptsConf (esbuildConf) {}
// extendBexManifestJson (json) {}
}
}
});

Deploy Nextjs app to cpanel 500 internal server error

I have a website hosted on CPanel which was previously in React, but I needed to migrate it to NextJS for SEO requirements. Now that I want to deploy it, I struggle to make it work. I followed this video : https://www.youtube.com/watch?v=lex3qZAf_Ok&t=1136s and the official NextJS documentation : https://nextjs.org/docs/advanced-features/custom-server, but in the end, when I add the Node JS app I get a 500 Internal Server Error.
When I execute node server.js on local or through cpanel terminal, it works and shows the website at localhost:3000.
I tried with all my files like in the video, and with a standalone build, but I have the same issue.
My code architecture :
package.json :
{
"name": "newglobal",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js",
"export": "next build && next export",
"lint": "next lint",
"sitemap": "next-sitemap --config next-sitemap-config.js"
},
"dependencies": {
"#emailjs/browser": "^3.6.2",
"axios": "^0.26.1",
"bootstrap": "^5.1.3",
"moment": "^2.29.3",
"next": "12.1.5",
"react": "^17.0.2",
"react-big-calendar": "^0.40.1",
"react-dom": "^17.0.2",
"react-icons": "^4.3.1",
"react-multi-carousel": "^2.8.0",
"react-responsive-carousel": "^3.2.23",
"reactstrap": "^9.0.2",
"sass": "^1.50.0",
"sharp": "^0.30.6"
},
"devDependencies": {
"babel-plugin-styled-components": "^2.0.7",
"babel-preset-next": "^1.4.0",
"eslint": "8.13.0",
"eslint-config-next": "12.1.5",
"next-sitemap": "^2.5.28",
"styled-components": "^5.3.5"
}
}
next.config.js
/** #type {import('next').NextConfig} */
const path = require("path");
const nextConfig = {
experimental: {
outputStandalone: true,
},
images : {
domains : ["res.cloudinary.com", 'http://localhost:3000'],
loader : 'imgix',
path : ''
},
reactStrictMode: true,
sassOptions: {
includePaths: [path.join(__dirname, 'src/styles')],
prependData: `#import "variables.scss";`
},
};
module.exports = nextConfig;
jsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"#/*":["src/*"],
"#/components/*":["src/components/*"],
"#/styles/*":["src/styles/*"],
"#/context/*":["src/context/*"],
"#/image/*":["public/img/*"]
}
}
}
I use the same server.js as the official documentation, or the following after the standalone build :
process.env.NODE_ENV = "production";
process.chdir(__dirname);
const NextServer = require("next/dist/server/next-server").default;
const http = require("http");
const path = require("path");
// Make sure commands gracefully respect termination signals (e.g. from Docker)
process.on("SIGTERM", () => process.exit(0));
process.on("SIGINT", () => process.exit(0));
let handler;
const server = http.createServer(async (req, res) => {
try {
await handler(req, res);
} catch (err) {
console.error(err);
res.statusCode = 500;
res.end("internal server error");
}
});
const currentPort = parseInt(process.env.PORT, 10) || 3000;
server.listen(currentPort, (err) => {
if (err) {
console.error("Failed to start server", err);
process.exit(1);
}
const addr = server.address();
const nextServer = new NextServer({
hostname: "localhost",
port: currentPort,
dir: path.join(__dirname),
dev: false,
conf: {
env: {},
webpack: null,
webpackDevMiddleware: null,
eslint: { ignoreDuringBuilds: false },
typescript: { ignoreBuildErrors: false, tsconfigPath: "tsconfig.json" },
distDir: "./.next",
cleanDistDir: true,
assetPrefix: "",
configOrigin: "next.config.js",
useFileSystemPublicRoutes: true,
generateEtags: true,
pageExtensions: ["tsx", "ts", "jsx", "js"],
target: "server",
poweredByHeader: true,
compress: true,
analyticsId: "",
images: {
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
path: "",
loader: "imgix",
domains: ["res.cloudinary.com", "http://localhost:3000"],
disableStaticImages: false,
minimumCacheTTL: 60,
formats: ["image/webp"],
dangerouslyAllowSVG: false,
contentSecurityPolicy: "script-src 'none'; frame-src 'none'; sandbox;",
},
devIndicators: {
buildActivity: true,
buildActivityPosition: "bottom-right",
},
onDemandEntries: { maxInactiveAge: 15000, pagesBufferLength: 2 },
amp: { canonicalBase: "" },
basePath: "",
sassOptions: {
includePaths: [
"C:\\Users\\johnk\\OneDrive\\Documents\\Elikya Academy\\global.client\\src\\styles",
],
prependData: '#import "variables.scss";',
},
trailingSlash: false,
i18n: null,
productionBrowserSourceMaps: false,
optimizeFonts: true,
excludeDefaultMomentLocales: true,
serverRuntimeConfig: {},
publicRuntimeConfig: {},
reactStrictMode: true,
httpAgentOptions: { keepAlive: true },
outputFileTracing: true,
staticPageGenerationTimeout: 60,
swcMinify: false,
experimental: {
cpus: 11,
sharedPool: true,
plugins: false,
profiling: false,
isrFlushToDisk: true,
workerThreads: false,
pageEnv: false,
optimizeCss: false,
nextScriptWorkers: false,
scrollRestoration: false,
externalDir: false,
reactRoot: false,
disableOptimizedLoading: false,
gzipSize: true,
swcFileReading: true,
craCompat: false,
esmExternals: true,
isrMemoryCacheSize: 52428800,
serverComponents: false,
fullySpecified: false,
outputFileTracingRoot: "",
outputStandalone: true,
images: { layoutRaw: false },
trustHostHeader: false,
},
configFileName: "next.config.js",
},
});
handler = nextServer.getRequestHandler();
console.log("Listening on port", currentPort);
});
try to 'next build' first before you delopy on CPanel , if you got erorr in next build you must fix it , then try deploy agin
As a workaround because I needed to deploy the website, I removed SSR from my pages and used useEffect instead, and did a next export to deploy it easily.

ESLint no-unused-expressions on json file

So, I'm using vite, eslint and prettier for my React + Typescript project, and when I run eslint --ext .js,.jsx,.ts,.tsx,.json --ignore-path .eslintignore ., it fails on:
this is the file:
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
PS.: I want it to be formatted that way!
This is my .eslintrc.js and .prettierrc.js respectively:
// .eslintrc.js
module.exports = {
env: {
browser: true,
es2021: true
},
extends: ['plugin:react/recommended', 'airbnb', 'prettier'],
parser: '#typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 12,
sourceType: 'module'
},
plugins: ['react', '#typescript-eslint', 'prettier'],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
}
},
ignorePatterns: [
'node_modules/',
'coverage/',
'.editorconfig',
'package.json',
'tsconfig.json'
],
rules: {
'react/jsx-filename-extension': 'off',
'react/function-component-definition': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'import/extensions': ['error', 'never'],
'import/prefer-default-export': 'off',
'import/first': 'off',
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': 'off',
'no-plusplus': 'off',
indent: ['error', 4],
'comma-dangle': ['error', 'never'],
'class-methods-use-this': 'off',
semi: 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/*.test.ts', '**/*.test.js', 'vite.config.ts']
}
]
}
};
// .prettierrc.js
module.exports = {
singleQuote: true,
arrowParens: 'always',
semi: true,
printWidth: 100,
tabWidth: 4,
trailingComma: 'none',
endOfLine: 'lf'
};
Oh, also, for prettier, everything is fine, that file doesn't trigger any errors on prettier. And I also did try using the eslint --fix cli, but it throws the exact same error...
What do I need to change?

Display prettier linting errors in vite hmr overlay with svelte

I have a Svelte app with Vite bundler. My linter is Eslint with Prettier and vite-plugin-svelte plugins. Linting works well, but I want to make the app show all the linting errors inside Vite hmr overlay, same way it works with syntax errors as in this picture
My question is: Is it even possible to make something like that with Vite? I found nothing helpful about Vite's hmr overlay in the documentation, or maybe I just missing something in Eslint/Prettier config?
Here is config files:
.eslintrc :
{
"extends": ["eslint:recommended", "airbnb-base", "prettier"],
"plugins": ["svelte3", "prettier"],
"env": {
"es6": true,
"browser": true,
"node": true
},
"overrides": [
{
"files": ["*.svelte"],
"processor": "svelte3/svelte3"
}
],
"parserOptions": {
"project": "./jsconfig.json"
},
"rules": {
"prefer-arrow-callback": "off",
"arrow-body-style": "off",
"import/prefer-default-export": "off",
"import/no-anonymous-default-export": [
"error",
{
"allowArray": true,
"allowArrowFunction": false,
"allowAnonymousClass": false,
"allowAnonymousFunction": false,
"allowCallExpression": true,
"allowLiteral": false,
"allowObject": true
}
],
"dot-notation": "off"
}
}
.prettierrc.js
module.exports = {
arrowParens: 'always',
bracketSpacing: true,
endOfLine: 'lf',
printWidth: 80,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
overrides: [
{
files: 'package*.json',
options: {
printWidth: 1000,
},
},
],
};
vite.config.js
export default defineConfig({
plugins: [
svelte({
preprocess: preprocess(),
}),
],
});
If it's possible to write your own vite plugin or modify the one in question, adding throw new Error(YOUR_ERROR) in the right plugin hook will trigger the overlay. e.g: modifying this example
https://vitejs.dev/guide/api-plugin.html#transformindexhtml
const htmlPlugin = () => {
return {
name: 'html-transform',
transformIndexHtml(html) {
// ADD THROW LINE
throw new Error("this will showup in an overlay")
}
}
}
Will lead to...

Resources