Skip to content

Commit

Permalink
dx: improve formatting, working eslint alias
Browse files Browse the repository at this point in the history
  • Loading branch information
tomoglavas committed May 11, 2022
1 parent 6e91ce3 commit d66f1b0
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 82 deletions.
74 changes: 39 additions & 35 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,34 @@ module.exports = defineConfig({
},
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:vue/vue3-recommended',
'plugin:node/recommended',
],
plugins: [
"@typescript-eslint",
"import",
"node",
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
],
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
ecmaVersion: 2020,
project: "./tsconfig.json",
tsconfigRootDir: "./",
extraFileExtensions: ['.vue', '.json'],
},
plugins: ['import', '@typescript-eslint', 'prettier'],
settings: {
'import/resolver': {
alias: {
map: [
["~", "./src"],
],
'eslint-import-resolver-custom-alias': {
alias: {
'~': './src',
},
extensions: ['.ts', '.js', '.json', '.vue'],
// Note: if using lerna or yarn worskpaces, try this for failing imports
// packages: ['packages/*'],
},
},
},
rules: {
'prettier/prettier': 'error',
eqeqeq: ['warn', 'always', { null: 'never' }],
'no-debugger': ['error'],
'no-empty': ['warn', { allowEmptyCatch: true }],
Expand All @@ -47,23 +44,33 @@ module.exports = defineConfig({
'prefer-const': [
'warn',
{
destructuring: 'all'
}
destructuring: 'all',
},
],
'node/no-missing-import': ['off'],
'node/no-missing-require': [
'error',
{
// for try-catching yarn pnp
allowModules: ['pnpapi'],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],
},
],
'node/no-missing-import': 'off',
'node/no-missing-require': 'off',
'node/no-deprecated-api': 'off',
'node/no-unpublished-import': 'off',
'node/no-unpublished-require': 'off',
'node/no-unsupported-features/es-syntax': 'off',
'node/no-unsupported-features/node-builtins': ['error', {
'version': '>=14.17.3',
'ignores': []
}],
'node/no-unsupported-features/node-builtins': [
'error',
{
version: '>=14.17.3',
ignores: [],
},
],
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] }
{ allow: ['arrowFunctions'] },
],
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
Expand All @@ -84,29 +91,26 @@ module.exports = defineConfig({
],
'newlines-between': 'always',
alphabetize: {
/* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */
/* sort in ascending order. Options: ["ignore", "asc", "desc"] */
order: 'asc',
/* ignore case. Options: [true, false] */
caseInsensitive: true,
},
},
],
'import/no-named-as-default': ['off'],
'import/no-extraneous-dependencies': 'error',
'import/no-unresolved': 'error',
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
files: ['*.d.ts'],
rules: {
'@typescript-eslint/triple-slash-reference': 'off'
}
}
]
})
'@typescript-eslint/triple-slash-reference': 'off',
},
},
],
})
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
trailingComma: "es5",
tabWidth: 2,
semi: false,
singleQuote: true,
}
28 changes: 12 additions & 16 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,26 @@
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.formatOnSave": false,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll.eslint": true
},
"[vue]": {
"editor.defaultFormatter": "johnsoncodehk.volar"
"editor.defaultFormatter": "Vue.volar",
},
"[typescript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
"[typescript, javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
},
"editor.quickSuggestions": {
"strings": true
},
"editor.linkedEditing": true,
"css.customData": [
"./.vscode/css-data.json"
],
"html.autoClosingTags": true,
"eslint.format.enable": true,
"eslint.alwaysShowStatus": true,
"eslint.codeActionsOnSave.mode":"problems",
"eslint.codeActionsOnSave.mode": "problems",
"eslint.validate": [
"vue",
"json",
Expand All @@ -43,6 +36,9 @@
".ts"
]
},
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.eol": "\n",
"files.exclude": {
"**/node_modules": true,
Expand All @@ -54,4 +50,4 @@
"typescript.updateImportsOnFileMove.enabled": "always",
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsdk": "./node_modules/typescript/lib",
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@
"@vueuse/integrations": "^7.6.2",
"body-scroll-lock": "^4.0.0-beta.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-define-config": "^1.0.9",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-custom-alias": "^1.3.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^7.13.0",
"focus-trap": "^6.7.3",
"markdown-it": "^12.3.2",
Expand All @@ -75,6 +77,7 @@
"postcss": "^8.4.13",
"postcss-import": "^14.1.0",
"postcss-nested": "^5.0.6",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"rollup-plugin-visualizer": "^5.6.0",
"text-clipper": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
".eslintrc.js",
"./*.ts"
],
"exclude": [
"exclude": [
"node_modules",
"dist",
"**/*.spec.ts"
Expand Down
10 changes: 0 additions & 10 deletions tsconfig.node.json

This file was deleted.

19 changes: 6 additions & 13 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-unresolved */
import { resolve } from 'path'

import vue from '@vitejs/plugin-vue'
Expand Down Expand Up @@ -31,14 +32,8 @@ export default defineConfig({
},
},
optimizeDeps: {
include: [
],
exclude: [
'vue',
'vue-router',
'@vueuse/core',
'vue-demi',
],
include: [],
exclude: ['vue', 'vue-router', '@vueuse/core', 'vue-demi'],
},
resolve: {
alias: {
Expand Down Expand Up @@ -72,7 +67,7 @@ export default defineConfig({
`,
placement: 'before',
space: false,
})
}),
})
// md.use(require('markdown-it-toc-done-right'), {
// listType: 'ul',
Expand Down Expand Up @@ -101,11 +96,9 @@ export default defineConfig({
plugins: [
require('postcss-import'),
require('postcss-nested')({
"bubble": [
"screen"
]
bubble: ['screen'],
}),
],
},
},
});
})
44 changes: 38 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1503,15 +1503,23 @@ escape-string-regexp@^4.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==

eslint-config-prettier@^8.5.0:
version "8.5.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1"
integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==

eslint-define-config@^1.0.9:
version "1.4.0"
resolved "https://registry.yarnpkg.com/eslint-define-config/-/eslint-define-config-1.4.0.tgz#1f2fe6126b4fc6e2f72292e94203f478b81a0208"
integrity sha512-DJGEdzX4fkdkhPSzPgOpBbBjhT+b9DcgbAgxfrEUcipVWlSuesQJriKffHz1JF5mhKFm7PGoiZz4D2nb4GslNA==

eslint-import-resolver-alias@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-alias/-/eslint-import-resolver-alias-1.1.2.tgz#297062890e31e4d6651eb5eba9534e1f6e68fc97"
integrity sha512-WdviM1Eu834zsfjHtcGHtGfcu+F30Od3V7I9Fi57uhBEwPkjDcii7/yW8jAT+gOhn4P/vOxxNAXbFAKsrrc15w==
eslint-import-resolver-custom-alias@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-custom-alias/-/eslint-import-resolver-custom-alias-1.3.0.tgz#361858d18103edd19ac69284b95e276e91a3cf7c"
integrity sha512-9rrpduF6/SZHFXrJgjeA+edJek6xulplYfo/UJvLPrY38O9UY00rAq76dHRnZ289yftc5NIfx3THi0IILRQ3dg==
dependencies:
glob-parent "^5.1.0"
resolve "^1.3.0"

eslint-import-resolver-node@^0.3.6:
version "0.3.6"
Expand Down Expand Up @@ -1568,6 +1576,13 @@ eslint-plugin-node@^11.1.0:
resolve "^1.10.1"
semver "^6.1.0"

eslint-plugin-prettier@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz#8b99d1e4b8b24a762472b4567992023619cb98e0"
integrity sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==
dependencies:
prettier-linter-helpers "^1.0.0"

eslint-plugin-vue@^7.13.0:
version "7.20.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-7.20.0.tgz#98c21885a6bfdf0713c3a92957a5afeaaeed9253"
Expand Down Expand Up @@ -1740,6 +1755,11 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==

fast-diff@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==

fast-glob@^3.2.11, fast-glob@^3.2.9:
version "3.2.11"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
Expand Down Expand Up @@ -1894,7 +1914,7 @@ get-symbol-description@^1.0.0:
call-bind "^1.0.2"
get-intrinsic "^1.1.1"

glob-parent@^5.1.2, glob-parent@~5.1.2:
glob-parent@^5.1.0, glob-parent@^5.1.2, glob-parent@~5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
Expand Down Expand Up @@ -2697,6 +2717,18 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==

prettier-linter-helpers@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"
integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
dependencies:
fast-diff "^1.1.2"

prettier@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032"
integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==

[email protected]:
version "1.28.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.28.0.tgz#0d8f561fa0f7cf6ebca901747828b149147044b6"
Expand Down Expand Up @@ -2844,7 +2876,7 @@ resolve-from@^4.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==

resolve@^1.1.7, resolve@^1.10.1, resolve@^1.20.0, resolve@^1.22.0:
resolve@^1.1.7, resolve@^1.10.1, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.3.0:
version "1.22.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198"
integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==
Expand Down

0 comments on commit d66f1b0

Please sign in to comment.