Skip to content

Commit

Permalink
feat: Add shared ESLint config, rename tanstackBuildConfig (#103)
Browse files Browse the repository at this point in the history
* chore: Add custom eslint flat config

* Newline

* Update maps

* Add eslint export

* Rename to tanstackVitePlugin

* Try downgrading prettier

* Remove tanstack/temp
  • Loading branch information
lachlancollins authored Jun 26, 2024
1 parent a4954b4 commit 33580e7
Show file tree
Hide file tree
Showing 22 changed files with 441 additions and 1,527 deletions.
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**/.next
**/.nx/cache
**/.svelte-kit
**/coverage
**/dist
**/docs
**/snap
pnpm-lock.yaml
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,
"trailingComma": "all"
}
48 changes: 0 additions & 48 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion bin/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function checkForConfigFile(configPath) {
console.error(
[
'No tanstack.config.js file found!',
'This may be because you\'re not passing the --config or --cwd flags.',
"This may be because you're not passing the --config or --cwd flags.",
'If you are passing these flags, check that the path is correct.',
'Otherwise, you can create a `tanstack.config.js` file in your project root.',
].join('\n'),
Expand Down
8 changes: 6 additions & 2 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@
"to": "overview"
},
{
"label": "Build",
"to": "build"
"label": "ESLint",
"to": "eslint"
},
{
"label": "Publish",
"to": "publish"
},
{
"label": "Vite",
"to": "vite"
}
]
}
Expand Down
6 changes: 6 additions & 0 deletions docs/eslint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: eslint
title: ESLint
---

To-do!
3 changes: 2 additions & 1 deletion docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ TanStack Config allows you to publish, update, and maintain your packages withou

## Utilities

- [Build](../build)
- [ESLint](../eslint)
- [Publish](../publish)
- [Vite](../vite)

## Required Pre-Requisites

Expand Down
12 changes: 6 additions & 6 deletions docs/build.md → docs/vite.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: build
title: Build
id: vite
title: Vite
---

The Vite build setup is the culmination of several attempts to dual publish ESM and CJS for TanStack projects, while preserving compatibility with all Typescript module resolution options.
Expand Down Expand Up @@ -45,22 +45,22 @@ The build config is quite opinionated, as it is designed to work with our intern

### vite.config.ts

- Import `mergeConfig` and `tanstackBuildConfig`.
- Merge your custom config first, followed by `tanstackBuildConfig`.
- Import `mergeConfig` and `tanstackViteConfig`.
- Merge your custom config first, followed by `tanstackViteConfig`.
- Please avoid modifying `build` in your custom config.
- See an example below:

```ts
import { defineConfig, mergeConfig } from 'vite'
import { tanstackBuildConfig } from '@tanstack/config/build'
import { tanstackViteConfig } from '@tanstack/config/vite'

const config = defineConfig({
// Framework plugins, vitest config, etc.
})

export default mergeConfig(
config,
tanstackBuildConfig({
tanstackViteConfig({
entry: './src/index.ts',
srcDir: './src',
}),
Expand Down
31 changes: 4 additions & 27 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
import antfu from '@antfu/eslint-config'
// @ts-check

export default antfu(
{
formatters: true,
ignores: [
'**/snap',
'**/vite.config.js.timestamp-*',
'**/vite.config.ts.timestamp-*',
],
},
{
rules: {
'antfu/if-newline': 'off',
'antfu/top-level-function': 'off',
'jsdoc/require-returns-description': 'off',
'style/arrow-parens': ['error', 'always'],
'style/brace-style': ['error', '1tbs'],
'node/prefer-global/process': 'off',
'ts/array-type': ['error', { default: 'generic', readonly: 'generic' }],
'ts/ban-ts-comment': 'off',
'ts/consistent-type-definitions': 'off',
'ts/no-inferrable-types': ['error', { ignoreParameters: true }],
'curly': 'off',
'no-console': 'off',
},
},
)
import { rootConfig } from './src/eslint/index.js'

export default [...rootConfig]
4 changes: 2 additions & 2 deletions integrations/react/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import { tanstackBuildConfig } from '@tanstack/config/build'
import { tanstackViteConfig } from '@tanstack/config/vite'

const config = defineConfig({
plugins: [react()],
Expand All @@ -12,7 +12,7 @@ const config = defineConfig({

export default mergeConfig(
config,
tanstackBuildConfig({
tanstackViteConfig({
entry: './src/index.ts',
srcDir: './src',
}),
Expand Down
2 changes: 1 addition & 1 deletion integrations/solid/snap/cjs/App.cjs.map

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

2 changes: 1 addition & 1 deletion integrations/solid/snap/esm/App.js.map

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

10 changes: 2 additions & 8 deletions integrations/solid/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ function App() {
<h1>Vite + Solid</h1>
<div class="card">
<button onClick={() => setCount((count) => count + 1)}>
count is
{' '}
{count()}
count is {count()}
</button>
<p>
Edit
{' '}
<code>src/App.tsx</code>
{' '}
and save to test HMR
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p class="read-the-docs">
Expand Down
4 changes: 2 additions & 2 deletions integrations/solid/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import solid from 'vite-plugin-solid'
import { tanstackBuildConfig } from '@tanstack/config/build'
import { tanstackViteConfig } from '@tanstack/config/vite'

const config = defineConfig({
plugins: [solid()],
Expand All @@ -12,7 +12,7 @@ const config = defineConfig({

export default mergeConfig(
config,
tanstackBuildConfig({
tanstackViteConfig({
entry: './src/index.ts',
srcDir: './src',
}),
Expand Down
4 changes: 2 additions & 2 deletions integrations/vanilla/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackBuildConfig } from '@tanstack/config/build'
import { tanstackViteConfig } from '@tanstack/config/vite'

const config = defineConfig({
test: {
Expand All @@ -10,7 +10,7 @@ const config = defineConfig({

export default mergeConfig(
config,
tanstackBuildConfig({
tanstackViteConfig({
entry: './src/index.ts',
srcDir: './src',
}),
Expand Down
4 changes: 2 additions & 2 deletions integrations/vue/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import { tanstackBuildConfig } from '@tanstack/config/build'
import { tanstackViteConfig } from '@tanstack/config/vite'

const config = defineConfig({
plugins: [vue()],
Expand All @@ -12,7 +12,7 @@ const config = defineConfig({

export default mergeConfig(
config,
tanstackBuildConfig({
tanstackViteConfig({
entry: './src/index.ts',
srcDir: './src',
}),
Expand Down
31 changes: 21 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@
},
"sideEffects": false,
"exports": {
"./eslint": {
"import": {
"default": "./src/eslint/index.js"
}
},
"./publish": {
"import": {
"types": "./src/publish/index.d.ts",
"default": "./src/publish/index.js"
}
},
"./build": {
"./vite": {
"import": {
"types": "./src/build/index.d.ts",
"default": "./src/build/index.js"
"types": "./src/vite/index.d.ts",
"default": "./src/vite/index.js"
}
},
"./package.json": "./package.json"
Expand All @@ -45,12 +50,14 @@
"scripts": {
"preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...')} else {process.exit(1)}\" || npx -y only-allow pnpm",
"test": "pnpm run test:ci",
"test:pr": "nx run-many --targets=test:eslint,test:types,test:build",
"test:ci": "nx run-many --targets=test:eslint,test:types,test:build",
"test:pr": "nx run-many --targets=test:format,test:eslint,test:types,test:build",
"test:ci": "nx run-many --targets=test:format,test:eslint,test:types,test:build",
"test:build": "publint --strict",
"test:types": "tsc",
"test:eslint": "eslint .",
"fix:eslint": "eslint . --fix",
"test:eslint": "eslint ./bin ./src",
"test:format": "pnpm run prettier --check",
"prettier": "prettier --ignore-unknown .",
"prettier:write": "pnpm run prettier --write",
"cipublish": "node ./bin/config.js publish --cwd .",
"cipublishforce": "CI=true pnpm cipublish"
},
Expand All @@ -64,23 +71,27 @@
},
"dependencies": {
"@commitlint/parse": "^19.0.3",
"@eslint/js": "^9.5.0",
"commander": "^12.1.0",
"current-git-branch": "^1.1.0",
"esbuild-register": "^3.5.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import-x": "^0.5.1",
"globals": "^15.6.0",
"interpret": "^3.1.1",
"jsonfile": "^6.1.0",
"liftoff": "^5.0.0",
"minimist": "^1.2.8",
"rollup-plugin-preserve-directives": "^0.4.0",
"semver": "^7.6.2",
"simple-git": "^3.25.0",
"typescript-eslint": "^8.0.0-alpha.32",
"v8flags": "^4.0.1",
"vite-plugin-dts": "^3.9.1",
"vite-plugin-externalize-deps": "^0.8.0",
"vite-tsconfig-paths": "^4.3.2"
},
"devDependencies": {
"@antfu/eslint-config": "^2.21.0",
"@arethetypeswrong/cli": "^0.15.3",
"@types/current-git-branch": "^1.1.6",
"@types/interpret": "^1.1.3",
Expand All @@ -90,10 +101,10 @@
"@types/node": "^20.14.2",
"@types/semver": "^7.5.8",
"@types/v8flags": "^3.1.3",
"eslint": "^9.4.0",
"eslint-plugin-format": "^0.1.1",
"eslint": "^9.5.0",
"jsdom": "^24.1.0",
"nx": "^19.2.2",
"prettier": "^3.3.2",
"publint": "^0.2.8",
"type-fest": "^4.20.0",
"typescript": "^5.4.5",
Expand Down
Loading

0 comments on commit 33580e7

Please sign in to comment.