Skip to content

Commit

Permalink
bump eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
adjsky committed Sep 12, 2024
1 parent ca99447 commit 30bfd5d
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 569 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

23 changes: 0 additions & 23 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
coverage/
.turbo
dist/
45 changes: 45 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import path from "node:path"
import { fileURLToPath } from "node:url"

import { includeIgnoreFile } from "@eslint/compat"
import js from "@eslint/js"
import prettier from "eslint-plugin-prettier/recommended"
import globals from "globals"
import ts from "typescript-eslint"

const baseDirectory = path.dirname(fileURLToPath(import.meta.url))

export default ts.config(
includeIgnoreFile(path.resolve(baseDirectory, ".gitignore")),
{
ignores: ["dist"]
},
js.configs.recommended,
...ts.configs.recommended,
prettier,
{
languageOptions: {
globals: {
...globals.node
},

ecmaVersion: 2022,
sourceType: "module",

parserOptions: {
project: true
}
},

rules: {
"prettier/prettier": "warn",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: false
}
]
}
}
)
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
"generate-docs": "typedoc --out docs packages/resulto/src/index.ts"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@eslint/js": "^9.10.0",
"@trivago/prettier-plugin-sort-imports": "4.1.0",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"@vitest/coverage-v8": "^0.34.2",
"eslint": "^8.47.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.9.0",
"prettier": "^3.0.2",
"turbo": "^1.10.13",
"typedoc": "^0.25.0",
"typescript": "^5.2.2",
"typescript-eslint": "^8.5.0",
"vitest": "^0.34.2"
},
"packageManager": "pnpm@8.6.2"
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin-resulto/.gitignore

This file was deleted.

56 changes: 18 additions & 38 deletions packages/eslint-plugin-resulto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
## Installation

```bash
npm install --save-dev eslint typescript @typescript-eslint/parser eslint-plugin-resulto @typescript-eslint/eslint-plugin
npm install --save-dev eslint @eslint/js typescript typescript-eslint eslint-plugin-resulto
```

## Configuration
Expand All @@ -23,21 +23,18 @@ npm install --save-dev eslint typescript @typescript-eslint/parser eslint-plugin
}
```

2. Create/modify your `ESLint` configuration file, i.e. `.eslintrc.json`.
2. Create/modify your `ESLint` configuration file, i.e. `eslint.config.mjs`.

```json
{
"root": true,
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true
},
"plugins": ["@typescript-eslint", "resulto"],
"rules": {
"resulto/must-use-result": "error"
}
}
```js
import js from "@eslint/js"
import resulto from "eslint-plugin-resulto"
import ts from "typescript-eslint"

export default tseslint.config(
js.configs.recommended,
...ts.configs.recommended,
resulto.configs.recommended
)
```

> See [typescript-eslint docs](https://typescript-eslint.io/getting-started/)
Expand All @@ -50,36 +47,19 @@ you want to purposely discard this value.

To make this work in TypeScript without making ESLint or tsc angry you need to:

1. Add this rule to your `ESLint` configuration file, i.e. `.eslintrc.json`
1. Add this rule to your `ESLint` configuration file, i.e. `eslint.config.mjs`

```json
{
"rules": {
```js
export default tseslint.config({
rules: {
"@typescript-eslint/no-unused-vars": [
"warn",
{
"varsIgnorePattern": "^_"
varsIgnorePattern: "^_"
}
]
}
}
})
```

2. Make sure you do not have `noUnusedLocals` set to `true` in `tsconfig.json`

## Available configs

- `resulto/recommended` - recommended rules.

## Rules

<!-- begin auto-generated rules list -->

💼 Configurations enabled in.\
✅ Set in the `recommended` configuration.

| Name | Description | 💼 |
| :----------------------------------------------- | :--------------------------------------------------- | :-- |
| [must-use-result](docs/rules/must-use-result.md) | Result must be used to make sure errors are handled. ||

<!-- end auto-generated rules list -->
14 changes: 6 additions & 8 deletions packages/eslint-plugin-resulto/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "eslint-plugin-resulto",
"version": "1.0.0",
"version": "2.0.0-beta.0",
"description": "ESLint plugin for resulto",
"scripts": {
"ts-check": "tsc --noEmit",
"test:watch": "vitest watch",
"build": "pkgroll",
"prepare": "pnpm build",
"update:eslint-docs": "eslint-doc-generator"
"prepare": "pnpm build"
},
"type": "module",
"main": "./dist/index.cjs",
Expand Down Expand Up @@ -36,16 +35,15 @@
],
"license": "MIT",
"peerDependencies": {
"@typescript-eslint/parser": "7.x"
"@typescript-eslint/parser": "8.x"
},
"devDependencies": {
"@typescript-eslint/parser": "^7.0.1",
"@typescript-eslint/rule-tester": "^7.0.1",
"eslint-doc-generator": "^1.4.3",
"@typescript-eslint/parser": "^8.5.0",
"@typescript-eslint/rule-tester": "^8.5.0",
"pkgroll": "^1.11.0",
"typescript": "^5.2.2"
},
"dependencies": {
"@typescript-eslint/utils": "^7.0.1"
"@typescript-eslint/utils": "^8.5.0"
}
}
4 changes: 3 additions & 1 deletion packages/eslint-plugin-resulto/src/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { ClassicConfig } from "@typescript-eslint/utils/ts-eslint"

export default {
plugins: ["resulto"],
rules: {
"resulto/must-use-result": "error"
}
}
} satisfies ClassicConfig.Config
9 changes: 8 additions & 1 deletion packages/eslint-plugin-resulto/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import packageJson from "../package.json"
import recommended from "./configs/recommended"
import mustUseResult from "./rules/must-use-result"

import type { Linter } from "@typescript-eslint/utils/ts-eslint"

export default {
configs: {
recommended
},
meta: {
name: packageJson.name,
version: packageJson.version
},
rules: {
"must-use-result": mustUseResult
}
}
} satisfies Linter.Plugin
9 changes: 5 additions & 4 deletions packages/eslint-plugin-resulto/test/must-use.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import rule from "../src/rules/must-use-result"
import { injectCode } from "./inject-code"

const tester = new RuleTester({
parser: "@typescript-eslint/parser",
parserOptions: {
tsconfigRootDir: `${__dirname}/fixture`,
project: "./tsconfig.json"
languageOptions: {
parserOptions: {
tsconfigRootDir: `${__dirname}/fixture`,
project: "./tsconfig.json"
}
}
})

Expand Down
1 change: 0 additions & 1 deletion packages/resulto/.gitignore

This file was deleted.

Loading

0 comments on commit 30bfd5d

Please sign in to comment.