Skip to content

Commit

Permalink
Merge pull request #134 from Sparticuz/feature/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparticuz authored Apr 12, 2024
2 parents 27ce54f + 2176712 commit 551a1a9
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 68 deletions.
90 changes: 76 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,100 @@ My eslint config

I use this on projects that I develop.

Included in the readme is also Typescript, Prettier, Vitest configs for bootstrapping new projects.

## Install

`npm install --save-dev @sparticuz/eslint-config typescript-eslint`
`npm install --save-dev @sparticuz/eslint-config typescript-eslint typescript prettier vitest @tsconfig/node20 @tsconfig/strictest`

## Example package.json

```json
"scripts": {
"build": "rm -rf dist/** && tsc -p tsconfig.build.json",
"lint": "eslint \"**/*.?(c|m)[jt]s?(x)\"",
"test": "vitest run --coverage"
},
```

## Example eslint.config.js

```js
// @ts-check

import myConfig from "@sparticuz/eslint-config";
import tseslint from "typescript-eslint";

export default tseslint.config(
...myConfig,
{
languageOptions: {
parserOptions: {
project: true
}
}
}
ignores: ["dist/**/*"],
},
...myConfig,
);
```

## Example prettier.config.cjs

This is my prettier.config.cjs file. Requires `npm install --save-dev prettier @ianvs/prettier-plugin-sort-imports`
## Example prettier.config.js

```js
/** @type {import("prettier").Config} */
const config = {
export const config = {
trailingComma: "all",
};
module.exports = config;
export default config;
```

## Example Typescript config

### tsconfig.json

```json
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Base Default TSConfig",
"extends": ["@tsconfig/node20/tsconfig", "@tsconfig/strictest/tsconfig"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"exactOptionalPropertyTypes": false,
"lib": ["DOM", "ES2023"],
"module": "NodeNext",
"moduleResolution": "nodenext",
"noUnusedLocals": false,
"outDir": "dist",
"resolveJsonModule": true,
"sourceMap": true
},
"include": ["src", "test"]
}
```

### tsconfig.build.json

```json
{
// extend your base config to share compilerOptions, etc
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"removeComments": true,
"sourceMap": false
},
"exclude": ["test"]
}
```

## Example vitest.config.ts

```ts
import { loadEnv } from "vite";
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
coverage: {
reportOnFailure: true,
reporter: ["json", "json-summary", "text"],
},
env: loadEnv("", process.cwd(), ""),
},
});
```
7 changes: 5 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @ts-expect-error There are no types
import js from "@eslint/js";
// @ts-expect-error There are no types
import prettierConfig from "eslint-config-prettier";
// @ts-expect-error There are no types
import arrayFuncPlugin from "eslint-plugin-array-func";
Expand Down Expand Up @@ -132,10 +134,11 @@ export default tseslint.config(
{
// Disable typechecking for Javascript files
extends: [tseslint.configs.disableTypeChecked],
files: ["*.js", "eslint.config.js"],
files: ["*.js"],
},
{
files: ["eslint.config.js"],
extends: [tseslint.configs.disableTypeChecked],
files: ["eslint.config.js", "vitest.config.ts"],
rules: {
// Everything should be included in @sparticuz/eslint-config's dependencies.
"n/no-extraneous-import": "off",
Expand Down
50 changes: 0 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"devDependencies": {
"@tsconfig/node20": "^20.1.4",
"@tsconfig/strictest": "^2.0.5",
"@types/eslint__js": "^8.42.3",
"@types/eslint-config-prettier": "^6.11.3",
"eslint": "^8.57.0",
"prettier": "^3.2.5",
"typescript": "^5.4.5"
Expand Down

0 comments on commit 551a1a9

Please sign in to comment.