Skip to content

Commit

Permalink
feat: add eslint (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
toddeTV authored Jan 23, 2025
1 parent d60e8a1 commit aa64a96
Show file tree
Hide file tree
Showing 6 changed files with 2,692 additions and 22 deletions.
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"cesium.gltf-vscode",
"dbaeumer.vscode-eslint",
"eamodio.gitlens",
"GitHub.copilot",
"GitHub.vscode-pull-request-github",
Expand Down
42 changes: 42 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": false,
"editor.linkedEditing": true,
"editor.rulers": [120],
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "format/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],
"eslint.useFlatConfig": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"css",
"less",
"scss",
"pcss",
"postcss"
],
"files.autoSave": "onFocusChange",
"javascript.preferences.importModuleSpecifier": "non-relative",
"javascript.preferences.importModuleSpecifierEnding": "js",
"javascript.preferences.renameMatchingJsxTags": true,
"npm.packageManager": "pnpm",
"prettier.enable": false,
"search.exclude": {
"**/.output": true,
"**/.pnp.*": true,
Expand Down
23 changes: 22 additions & 1 deletion README.dev.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Developer README

This document is intended for contributors. It explains how to set up the development environment for this project.
This document is intended for contributors. It explains how to set up the development environment for this project.<br>
User-oriented documentation, including installation and usage instructions, can be found in [README.md](/README.md).

## initial setup
Expand Down Expand Up @@ -30,6 +30,27 @@ Development VM ID from Thorsten for this project: `014`<br>
6. Install dependencies: `pnpm i`
7. Happy coding <3

## lint and prettier

This project uses [antfu/eslint-config](https://github.com/antfu/eslint-config) for eslint most of the files.
The following extend it:

- [antfu/eslint-plugin-format](https://github.com/antfu/eslint-plugin-format) for using external formatters like
e.g. `prettier` for the file types that eslint cannot handle.
- [azat-io/eslint-plugin-perfectionist](https://github.com/azat-io/eslint-plugin-perfectionist) for
sorting object keys, imports, etc. - with auto-fix.

Keep in mind that the plugin names are renamed, see
[Plugins Rename](https://github.com/antfu/eslint-config?tab=readme-ov-file#plugins-renaming), e.g.:

```diff
-// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
+// eslint-disable-next-line ts/consistent-type-definitions
type foo = { bar: 2 }
```

[Why I don't use Prettier for every file type](https://antfu.me/posts/why-not-prettier)

## Docs and helper websites

\[currently none\]
65 changes: 65 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import antfu from '@antfu/eslint-config'
import perfectionist from 'eslint-plugin-perfectionist'

export default antfu(
{
formatters: {
markdown: 'prettier',
},

jsonc: true,

stylistic: {
indent: 2,
quotes: 'single',
},

typescript: true,

yaml: true,
},
{
files: [
'**/*.js',
'**/*.json',
'**/*.md',
'**/*.ts',
'**/*.xml',
'**/*.yaml',
'**/*.yml',
],

ignores: [
],

plugins: {
perfectionist,
},

rules: {
'antfu/consistent-chaining': [
'off',
],
'import/extensions': [ // ensure consistent file extensions in import declarations
'error',
'always',
{
gltf: 'always',
js: 'always',
ts: 'never',
vue: 'always',
},
],
'jsonc/sort-keys': [
'error',
],
'perfectionist/sort-objects': [
'error',
{
order: 'asc',
type: 'natural',
},
],
},
},
)
21 changes: 14 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@
"pnpm": "9"
},
"scripts": {
},
"dependencies": {
},
"devDependencies": {
"@types/node": "~22.10.7",
"@types/three": "~0.172.0",
"typescript": "~5.7.3"
"lint": "eslint .",
"lint:fix": "run-s \"lint --fix\""
},
"peerDependencies": {
"@farmfe/core": ">=1",
Expand Down Expand Up @@ -66,5 +61,17 @@
"webpack": {
"optional": true
}
},
"dependencies": {
},
"devDependencies": {
"@antfu/eslint-config": "~3.16.0",
"@types/node": "~22.10.7",
"@types/three": "~0.172.0",
"eslint": "~9.18.0",
"eslint-plugin-format": "~1.0.1",
"eslint-plugin-perfectionist": "~4.7.0",
"npm-run-all2": "~7.0.2",
"typescript": "~5.7.3"
}
}
Loading

0 comments on commit aa64a96

Please sign in to comment.