Skip to content

Commit

Permalink
chore: setup eslint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Nov 7, 2022
1 parent db343dc commit fe7aaaf
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.js]
indent_style = space
indent_size = 2

[{package.json,*.yml,*.cjson}]
indent_style = space
indent_size = 2
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
51 changes: 50 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
{
"extends": "@antfu"
"extends": [
"@nuxtjs/eslint-config-typescript",
// Enable typescript-specific recommended rules
"plugin:@typescript-eslint/recommended",
// Turns off all rules that are unnecessary or might conflict with Prettier (needs to be last)
"prettier"
],
"plugins": ["unused-imports"],
"rules": {
// Workaround for bug https://github.com/nuxt/eslint-config/issues/147
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "error",
// Don"t report unused imports (this is handled by prettier)
"unused-imports/no-unused-imports": "off",
// Report unused variables (except the ones prefixed with an underscore)
"unused-imports/no-unused-vars": [
"warn",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
],
// Ensure void operator is not used, except for variable assignment or function return (might be handy for promises)
"no-void": ["error", { "allowAsStatement": true }],
// Demote this to warning as long as we are still using cjs modules
"import/named": "warn",
// Import order is handled by prettier (which is incompatible with this rule: https://github.com/simonhaenisch/prettier-plugin-organize-imports/issues/65)
"import/order": "off"
},
"overrides": [
{
"files": ["*.ts", "*.vue"],
// Parser supporting vue files
"parser": "vue-eslint-parser",
"parserOptions": {
// Use ts parser for ts files and for the script tag in vue files
"parser": "@typescript-eslint/parser",
// Path to tsconfig to enable rules that require type information
"project": "./tsconfig.eslint.json",
// Correctly handle vue files
"extraFileExtensions": [".vue"]
},
"extends": [
// Enable recommended rules for typescript that use typing information (may be CPU intensive)
"plugin:@typescript-eslint/recommended-requiring-type-checking"
]
}
]
}
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"singleAttributePerLine": true
}
12 changes: 12 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
// ensure that nobody can accidentally use this config for a build
"noEmit": true
},
"include": [
// whatever paths you intend to lint
"src",
"test"
]
}

0 comments on commit fe7aaaf

Please sign in to comment.