Skip to content

Commit

Permalink
Merge pull request #912 from 3YOURMIND/eslint-plugin-3yourmind/mvp
Browse files Browse the repository at this point in the history
feature(eslint): add reusable eslint config, create `@3yourmind/eslint-config`
  • Loading branch information
Isokaeder authored May 13, 2024
2 parents 801e93e + 97f613e commit 84d6d33
Show file tree
Hide file tree
Showing 236 changed files with 3,758 additions and 2,069 deletions.
138 changes: 0 additions & 138 deletions .eslintrc.js

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.nuxt/
.turbo/
dist/
gh-pages/
node_modules/
packages/kotti-ui/report.*.html
packages/yoco/fonts/
Expand All @@ -12,3 +11,6 @@ vite.config.ts.timestamp*

# os:macOS
.DS_Store

# package.json debug:turbo script
/turbo-graph.png
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"source.fixAll.eslint": "always"
},
"editor.formatOnSave": true,
"eslint.options": {
"extensions": [".js", ".vue", ".ts"]
},
"eslint.validate": [
"javascript",
"javascriptreact",
"json",
"jsonc",
"typescript",
"typescriptreact",
"vue"
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,21 @@ yarn run build
| Path | Purpose |
| :----------------------- | :------------------------- |
| `packages/documentation` | Nuxt-managed documentation |

### Turborepo Tooling

#### Debugging

The best starting point for debugging turbo is:

1. Figure out what turbo command gets run (e.g. by checking `package.json`)
2. Check the relevant tasks in `turbo.json` and `packages/*/turbo.json`

The [Turborepo Documentation](https://turbo.build/repo/docs) is an excellent resource, also make sure you have the `@recommended` `Vercel.turbo-vsc` extension installed as it provides autocomplete and linting for `turbo.json`.

It is also possible to [visualize the graph used by `turbo run`](https://turbo.build/repo/docs/reference/command-line-reference/run#--graph)

```sh
# generate a graph of turbo run build (needs graphviz)
yarn run debug:turbo
```
95 changes: 95 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// @ts-check

import tseslint from 'typescript-eslint'
import eslintConfig3YD from '@3yourmind/eslint-config'
import { fileURLToPath } from 'url'
import path from 'node:path'

/**
* Find the project root in a way that is compatible with most javascript engines (e.g. node, vscode's node, bun)
*/
const root = (() => {
const cause = []

try {
const result = __dirname
if (result) return result
} catch (error) {
cause.push(error)
}

try {
const result = import.meta.dirname
if (result) return result
} catch (error) {
cause.push(error)
}

try {
const result = path.dirname(fileURLToPath(import.meta.url))
if (result) return result
} catch (error) {
cause.push(error)
}

throw new Error('could not determine project root', { cause })
})()

const config = tseslint.config(
/**
* DO NOT ADD ANY OTHER KEYS TO THIS FIRST OBJECT
*
* @see {@link https://eslint.org/docs/latest/use/configure/ignore#ignoring-files}
*/
{
ignores: ['**/dist/**', '**/.nuxt/**', '**/.turbo/**', '**/*.js'],
},
...eslintConfig3YD.configs.global,
{
languageOptions: {
ecmaVersion: 2022,
parserOptions: {
debugLevel: 'typescript-eslint',
project: [
'./tsconfig.json',
'./internals/*/tsconfig.json',
'./packages/*/tsconfig.json',
'./packages/kotti-ui/tsconfig.node.json',
],
tsconfigRootDir: root,
},
sourceType: 'module',
},
},
...eslintConfig3YD.configs.default.map((config) => ({
...config,
files: ['packages/**/*.ts', 'packages/**/*.tsx'],
})),
...eslintConfig3YD.configs.untyped,
...eslintConfig3YD.configs.json,
...eslintConfig3YD.configs.tests.map((config) => ({
...config,
files: [...config.files, 'packages/kotti-ui/source/test-utils/**/*.ts'],
})),
...eslintConfig3YD.configs.vue,
{
rules: {
'@typescript-eslint/no-restricted-imports': [
'error',
{
message:
"Avoid direct imports from lodash; e.g. import foo from 'lodash/foo' instead of import { foo } from 'lodash'",
name: 'lodash',
},
],
},
},
{
files: ['packages/kotti-ui/source/*/index.ts'],
rules: {
'@typescript-eslint/naming-convention': 'off',
},
},
)

export default config
2 changes: 1 addition & 1 deletion internals/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "@3yourmind/scripts",
"private": true,
"scripts": {
"check:eslint": "yarn --cwd ../.. run eslint --max-warnings=0 --ignore-path=.gitignore ./internals/scripts",
"check:eslint": "eslint --max-warnings=0 .",
"check:prettier": "yarn --cwd ../.. run prettier --check --ignore-path=.gitignore ./internals/scripts",
"fix:eslint": "yarn run check:eslint --fix",
"fix:prettier": "yarn run check:prettier --write"
Expand Down
2 changes: 1 addition & 1 deletion internals/scripts/source/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { $, semver } from 'bun'
import { z } from 'zod'

const packagesToConsider = [] as string[]
const packagesToConsider = ['packages/eslint-config']

const packageJsonSchema = z.object({ name: z.string(), version: z.string() })

Expand Down
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"ignore": ["**/dist/**"],
"ignoreBinaries": [],
"ignoreBinaries": ["dot", "open"],
"ignoreDependencies": ["lerna", "lint-staged"],
"workspaces": {
"packages/*": {
Expand Down
24 changes: 9 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,16 @@
}
],
"devDependencies": {
"@3yourmind/eslint-config": "*",
"@types/eslint__js": "^8.42.3",
"@types/node": "20.11.16",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vue/eslint-config-typescript": "^12.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-sonarjs": "^0.23.0",
"eslint-plugin-vitest": "^0.3.22",
"eslint-plugin-vue": "^9.20.1",
"eslint": "^9.2.0",
"husky": "^7.0.1",
"knip": "^5.13.0",
"lerna": "^7.4.2",
"lint-staged": "^11.0.1",
"nodemon": "^3.0.3",
"postcss": "^8.4.34",
"postcss": "^8.4.38",
"postcss-html": "^1.6.0",
"prettier": "^3.2.5",
"publint": "^0.2.7",
Expand All @@ -74,9 +67,9 @@
"stylelint-config-standard-scss": "^10.0.0",
"stylelint-csstree-validator": "^3.0.0",
"stylelint-prettier": "^4.0.2",
"turbo": "^1.13.2",
"typescript": "^5.3",
"vue-eslint-parser": "9"
"turbo": "^1.13.3",
"typescript": "^5.4.4",
"typescript-eslint": "^7.8.0"
},
"engines": {
"node": ">=18"
Expand Down Expand Up @@ -117,14 +110,15 @@
"check:prettier": "turbo run check:prettier",
"check:publint": "turbo run check:publint",
"check:stylelint": "turbo run check:stylelint",
"debug:turbo": "turbo run build --graph --dry | dot -Tpng -oturbo-graph.png && open turbo-graph.png",
"fix": "turbo run fix",
"fix:eslint": "turbo run fix:eslint",
"fix:prettier": "turbo run fix:prettier",
"fix:stylelint": "turbo run fix:stylelint",
"prepare": "husky install",
"prepublishOnly": "turbo run check build",
"test": "turbo run test",
"watch": "nodemon -e js,ts,vue,scss,css,json --watch packages/vue-use-tippy/source --watch packages/yoco/source --exec \"turbo run watch\""
"watch": "nodemon -e css,js,json,scss,ts,vue --watch packages/vue-use-tippy/source --watch packages/yoco/source --exec \"turbo run watch\""
},
"version": "1.0.0",
"workspaces": [
Expand Down
13 changes: 0 additions & 13 deletions packages/documentation/.unimportedrc.json

This file was deleted.

8 changes: 0 additions & 8 deletions packages/documentation/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# `@3yourmind/documentation`

> TODO: description
## Usage

```
const documentation = require('@3yourmind/documentation');
// TODO: DEMONSTRATE API
```
Loading

0 comments on commit 84d6d33

Please sign in to comment.