Repository navigation
feat: add @tanstack/oxlint-config #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+811
−195
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a278ae2
feat: add @tanstack/oxlint-config
DogPawHat 45eb665
feat(oxlint-config): leave import order and comment style to the form…
DogPawHat 1c4dc19
docs: humanize and simpifly docs
DogPawHat 7ebf3d5
ci: apply automated fixes
autofix-ci[bot] 7e929bd
chore: lint the repo with @tanstack/oxlint-config
DogPawHat 36bcad4
chore: move oxlint above eslint
DogPawHat 585a4dc
fix(oxlint-config): align engines.node with oxlint
DogPawHat c370940
chore: move oxlint to top of overivew
DogPawHat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/oxlint-config': minor | ||
| --- | ||
|
|
||
| Add `@tanstack/oxlint-config`, a port of `@tanstack/eslint-config` to Oxlint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| id: oxlint | ||
| title: Oxlint | ||
| --- | ||
|
|
||
| ## Purpose | ||
|
|
||
| This package unifies the shared [Oxlint](https://oxc.rs/docs/guide/usage/linter) config used across all TanStack projects. It is designed to be framework-agnostic, and does not include any framework-specific plugins. | ||
|
|
||
| ## Installation | ||
|
|
||
| To install the package, run the following command: | ||
|
|
||
| ```bash | ||
| pnpm add -D @tanstack/oxlint-config | ||
| ``` | ||
|
|
||
| ## Setup | ||
|
|
||
| ### package.json | ||
|
|
||
| - Make sure you have Oxlint v1.87+ installed | ||
| - `oxlint-tsgolint` is required, as the config enables type-aware linting | ||
|
|
||
| ### oxlint.config.ts | ||
|
|
||
| ```ts | ||
| import { tanstackConfig } from '@tanstack/oxlint-config' | ||
| import { defineConfig } from 'oxlint' | ||
|
|
||
| export default defineConfig({ | ||
| extends: [tanstackConfig], | ||
| // Not inherited through `extends` | ||
| env: tanstackConfig.env, | ||
| ignorePatterns: tanstackConfig.ignorePatterns, | ||
| rules: { | ||
| // Custom rules go here | ||
| }, | ||
| }) | ||
| ``` | ||
|
|
||
| ## Rules | ||
|
|
||
| You can inspect the enabled rules by browsing the source [here](https://github.com/TanStack/config/tree/main/packages/oxlint-config). Each rule has a comment explaining why it is included in the shared config. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { defineConfig } from 'oxlint' | ||
| import { tanstackConfig } from '@tanstack/oxlint-config' | ||
|
|
||
| export default defineConfig({ | ||
| extends: [tanstackConfig], | ||
| env: tanstackConfig.env, | ||
| ignorePatterns: tanstackConfig.ignorePatterns, | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { defineConfig } from 'oxlint' | ||
| import { tanstackConfig } from '@tanstack/oxlint-config' | ||
|
|
||
| export default defineConfig({ | ||
| extends: [tanstackConfig], | ||
| env: tanstackConfig.env, | ||
| ignorePatterns: tanstackConfig.ignorePatterns, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| { | ||
| "name": "@tanstack/oxlint-config", | ||
| "version": "0.0.0", | ||
| "description": "Shared Oxlint config used by TanStack projects.", | ||
| "author": "tannerlinsley", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/TanStack/config.git", | ||
| "directory": "packages/oxlint-config" | ||
| }, | ||
| "homepage": "https://tanstack.com/config", | ||
| "funding": { | ||
| "type": "github", | ||
| "url": "https://github.com/sponsors/tannerlinsley" | ||
| }, | ||
| "scripts": { | ||
| "test:types": "tsc", | ||
| "test:oxlint": "oxlint ./src", | ||
| "build": "tsdown" | ||
| }, | ||
| "type": "module", | ||
| "types": "./dist/index.d.ts", | ||
| "exports": { | ||
| ".": "./src/index.ts", | ||
| "./plugin": "./src/plugin.ts", | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "publishConfig": { | ||
| "exports": { | ||
| ".": "./dist/index.js", | ||
| "./plugin": "./dist/plugin.js", | ||
| "./package.json": "./package.json" | ||
| } | ||
| }, | ||
| "preferGlobal": false, | ||
| "sideEffects": false, | ||
| "files": [ | ||
| "dist", | ||
| "src" | ||
| ], | ||
| "engines": { | ||
| "node": "^20.19.0 || >=22.12.0" | ||
| }, | ||
| "dependencies": { | ||
| "@oxlint/plugins": "catalog:" | ||
| }, | ||
| "devDependencies": { | ||
| "oxlint": "catalog:", | ||
| "oxlint-tsgolint": "catalog:" | ||
| }, | ||
| "peerDependencies": { | ||
| "oxlint": "^1.87.0", | ||
| "oxlint-tsgolint": ">=7.0.2003" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type { DummyRuleMap } from 'oxlint' | ||
|
|
||
| /** | ||
| * Port of `importRules` from `@tanstack/eslint-config`. | ||
| * | ||
| * Not ported: `import/order`, which Oxlint does not implement. Import order | ||
| * is left to the formatter, such as Oxfmt's `sortImports`. | ||
| * | ||
| * @see https://oxc.rs/docs/guide/usage/linter/rules.html | ||
| */ | ||
| export const importRules: DummyRuleMap = { | ||
| /** Bans the use of inline type-only markers for named imports */ | ||
| 'import/consistent-type-specifier-style': ['error', 'prefer-top-level'], | ||
| /** Reports any imports that come after non-import statements */ | ||
| 'import/first': 'error', | ||
| /** Stylistic preference */ | ||
| 'import/newline-after-import': 'error', | ||
| /** No require() or module.exports */ | ||
| 'import/no-commonjs': 'error', | ||
| /** Reports if a resolved path is imported more than once */ | ||
| 'import/no-duplicates': 'error', | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { fileURLToPath } from 'node:url' | ||
| import { defineConfig } from 'oxlint' | ||
| import { javascriptRules } from './javascript.ts' | ||
| import { importRules } from './import.ts' | ||
| import { typescriptRules } from './typescript.ts' | ||
| import { nodeRules } from './node.ts' | ||
| import type { OxlintConfig } from 'oxlint' | ||
|
|
||
| /** | ||
| * JS plugins are resolved from this package, so consumers don't need to | ||
| * install them. | ||
| */ | ||
| const resolve = (specifier: string): string => | ||
| fileURLToPath(import.meta.resolve(specifier)) | ||
|
|
||
| /** | ||
| * Oxlint does not inherit `env`, `ignorePatterns` or `settings` through | ||
| * `extends`, so `env` and `ignorePatterns` are always set, for consumers to | ||
| * pass through. | ||
| */ | ||
| type TanstackConfig = OxlintConfig & | ||
| Required<Pick<OxlintConfig, 'env' | 'ignorePatterns'>> | ||
|
|
||
| export const tanstackConfig: TanstackConfig = defineConfig({ | ||
| plugins: ['import', 'typescript', 'unicorn'], | ||
| jsPlugins: [ | ||
| { name: 'tanstack', specifier: resolve('@tanstack/oxlint-config/plugin') }, | ||
| ], | ||
| categories: { | ||
| correctness: 'off', | ||
| }, | ||
| options: { | ||
| typeAware: true, | ||
| }, | ||
| env: { | ||
| browser: true, | ||
| es2020: true, | ||
| }, | ||
| ignorePatterns: [ | ||
| '**/.nx/**', | ||
| '**/.svelte-kit/**', | ||
| '**/build/**', | ||
| '**/coverage/**', | ||
| '**/dist/**', | ||
| '**/snap/**', | ||
| '**/vite.config.*.timestamp-*.*', | ||
| ], | ||
| rules: { | ||
| ...javascriptRules, | ||
| ...typescriptRules, | ||
| ...importRules, | ||
| ...nodeRules, | ||
| }, | ||
| }) | ||
|
|
||
| export { javascriptRules, importRules, typescriptRules, nodeRules } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import type { DummyRuleMap } from 'oxlint' | ||
|
|
||
| /** | ||
| * Port of `javascriptRules` from `@tanstack/eslint-config`. | ||
| * | ||
| * Not ported: `no-octal`, which Oxlint does not implement. Legacy octal | ||
| * literals are already a syntax error in ES modules. | ||
| * | ||
| * @see https://oxc.rs/docs/guide/usage/linter/rules.html | ||
| */ | ||
| export const javascriptRules: DummyRuleMap = { | ||
| 'for-direction': 'error', | ||
| 'no-async-promise-executor': 'error', | ||
| 'no-case-declarations': 'error', | ||
| 'no-class-assign': 'error', | ||
| 'no-compare-neg-zero': 'error', | ||
| 'no-cond-assign': 'error', | ||
| 'no-constant-binary-expression': 'error', | ||
| 'no-constant-condition': 'error', | ||
| 'no-control-regex': 'error', | ||
| 'no-debugger': 'error', | ||
| 'no-delete-var': 'error', | ||
| 'no-dupe-else-if': 'error', | ||
| 'no-duplicate-case': 'error', | ||
| 'no-empty-character-class': 'error', | ||
| 'no-empty-pattern': 'error', | ||
| 'no-empty-static-block': 'error', | ||
| 'no-ex-assign': 'error', | ||
| 'no-extra-boolean-cast': 'error', | ||
| 'no-fallthrough': 'error', | ||
| 'no-global-assign': 'error', | ||
| 'no-invalid-regexp': 'error', | ||
| 'no-irregular-whitespace': 'error', | ||
| 'no-loss-of-precision': 'error', | ||
| 'no-misleading-character-class': 'error', | ||
| 'no-nonoctal-decimal-escape': 'error', | ||
| 'no-regex-spaces': 'error', | ||
| 'no-self-assign': 'error', | ||
| /** Warn about variable with identical names in the outer scope */ | ||
| 'no-shadow': 'warn', | ||
| 'no-shadow-restricted-names': 'error', | ||
| 'no-sparse-arrays': 'error', | ||
| 'no-unsafe-finally': 'error', | ||
| 'no-unsafe-optional-chaining': 'error', | ||
| 'no-unused-labels': 'error', | ||
| 'no-unused-private-class-members': 'error', | ||
| 'no-useless-backreference': 'error', | ||
| 'no-useless-catch': 'error', | ||
| 'no-useless-escape': 'error', | ||
| /** Prefer let and const */ | ||
| 'no-var': 'error', | ||
| 'no-with': 'error', | ||
| /** Prefer const if never re-assigned */ | ||
| 'prefer-const': 'error', | ||
| 'require-yield': 'error', | ||
| /** Stylistic consistency */ | ||
| 'sort-imports': ['error', { ignoreDeclarationSort: true }], | ||
| 'use-isnan': 'error', | ||
| /** Enforce comparing typeof against valid strings */ | ||
| 'valid-typeof': 'error', | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import type { DummyRuleMap } from 'oxlint' | ||
|
|
||
| /** | ||
| * Port of `nodeRules` from `@tanstack/eslint-config`, using the native | ||
| * `unicorn` equivalent of `n/prefer-node-protocol`. | ||
| * | ||
| * @see https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-node-protocol.html | ||
| */ | ||
| export const nodeRules: DummyRuleMap = { | ||
| /** Enforce usage of the `node:` prefix for builtin imports */ | ||
| 'unicorn/prefer-node-protocol': 'error', | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.