Skip to content

Commit

Permalink
refactor: add eslint & extract types
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jan 11, 2024
1 parent 497f075 commit ef57596
Show file tree
Hide file tree
Showing 30 changed files with 885 additions and 99 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
44 changes: 44 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// @ts-check

module.exports = {
root: true,
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
extends: ['plugin:vue/vue3-recommended'],
rules: {
'no-debugger': 'error',
'no-console': ['error', { allow: ['warn', 'error', 'info', 'clear'] }],
'sort-imports': ['error', { ignoreDeclarationSort: true }],

// This rule enforces the preference for using '@ts-expect-error' comments in TypeScript
// code to indicate intentional type errors, improving code clarity and maintainability.
'@typescript-eslint/prefer-ts-expect-error': 'error',
// Enforce the use of 'import type' for importing types
'@typescript-eslint/consistent-type-imports': [
'error',
{
fixStyle: 'inline-type-imports',
disallowTypeAnnotations: false,
},
],
// Enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers
'@typescript-eslint/no-import-type-side-effects': 'error',

'vue/max-attributes-per-line': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/multi-word-component-names': 'off',
'vue/html-self-closing': [
'error',
{
html: { component: 'always', normal: 'always', void: 'any' },
math: 'always',
svg: 'always',
},
],
},
overrides: [],
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
"build": "vite build",
"build-preview": "vite build -c vite.preview.config.ts",
"format": "prettier --write .",
"lint": "eslint --ext .ts,.vue .",
"typecheck": "vue-tsc --noEmit",
"release": "bumpp --all",
"version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"prepublishOnly": "npm run build"
Expand All @@ -68,7 +70,9 @@
"@babel/types": "^7.23.6",
"@rollup/plugin-replace": "^5.0.5",
"@types/codemirror": "^5.60.15",
"@types/hash-sum": "^1.0.2",
"@types/node": "^20.10.6",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@vitejs/plugin-vue": "^5.0.2",
"@volar/cdn": "~1.11.1",
"@volar/monaco": "~1.11.1",
Expand All @@ -77,6 +81,8 @@
"bumpp": "^9.2.1",
"codemirror": "^5.65.16",
"conventional-changelog-cli": "^4.1.0",
"eslint": "^8.56.0",
"eslint-plugin-vue": "^9.20.0",
"fflate": "^0.8.1",
"hash-sum": "^2.0.0",
"lint-staged": "^15.2.0",
Expand Down
Loading

0 comments on commit ef57596

Please sign in to comment.