-
-
Notifications
You must be signed in to change notification settings - Fork 63
docs: Lint plugin #2307
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
Merged
Merged
docs: Lint plugin #2307
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2e7d710
Add a stub of the page
ae76b94
Update docs
5569388
Simplify code
aa632f8
Update configs
aleksanderkatan 7293f3c
Further simplify configs
aleksanderkatan 312740c
Update apps/typegpu-docs/src/content/docs/tooling/eslint-plugin-typeg…
aleksanderkatan fa51396
Remove trailing whitespaces
aleksanderkatan 909f005
Merge remote-tracking branch 'origin/release' into docs/lint-plugin
aleksanderkatan 69b8d6a
Review fixes
aleksanderkatan d78d0df
Merge remote-tracking branch 'origin/release' into docs/lint-plugin
aleksanderkatan 364bc7a
Review fixes
aleksanderkatan 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
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
105 changes: 105 additions & 0 deletions
105
apps/typegpu-docs/src/content/docs/tooling/eslint-plugin-typegpu.mdx
|
aleksanderkatan marked this conversation as resolved.
|
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,105 @@ | ||
| --- | ||
| title: Lint Plugin | ||
| description: A guide on how to use the optional lint plugin for TypeGPU | ||
| --- | ||
| import { Tabs, TabItem } from '@astrojs/starlight/components'; | ||
|
|
||
| [eslint-plugin-typegpu](https://www.npmjs.com/package/eslint-plugin-typegpu) is an optional (but highly recommended) tool for projects using TypeGPU. | ||
| It helps with coding 'use gpu' functions by highlighting common pitfalls and unsupported syntax. | ||
|
aleksanderkatan marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Installation | ||
|
|
||
| <Tabs syncKey="package-manager"> | ||
| <TabItem label="npm" icon="seti:npm"> | ||
| ```sh frame=none | ||
| npm add -D eslint-plugin-typegpu | ||
|
aleksanderkatan marked this conversation as resolved.
|
||
| ``` | ||
| </TabItem> | ||
| <TabItem label="pnpm" icon="pnpm"> | ||
| ```sh frame=none | ||
| pnpm add -D eslint-plugin-typegpu | ||
| ``` | ||
| </TabItem> | ||
| <TabItem label="yarn" icon="seti:yarn"> | ||
| ```sh frame=none | ||
| yarn add -D eslint-plugin-typegpu | ||
| ``` | ||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| After installing, the plugin still needs to be added to a config. | ||
| The way this is done depends on the linter used. | ||
|
|
||
| ## Configuring | ||
|
|
||
| ### ESLint (`eslint.config.js`) | ||
|
|
||
|
aleksanderkatan marked this conversation as resolved.
|
||
| The plugin needs to be imported and included in `defineConfig`. | ||
|
|
||
| ```diff lang=ts | ||
| import { defineConfig } from "eslint/config"; | ||
| +import typegpu from "eslint-plugin-typegpu"; | ||
|
|
||
| export default defineConfig([ | ||
| // other configs | ||
| + { | ||
| + plugins: { typegpu }, | ||
| + rules: { | ||
| + 'typegpu/no-integer-division': 'warn', | ||
| + 'typegpu/no-math': 'warn', | ||
| + } | ||
| + } | ||
| ]); | ||
| ``` | ||
|
|
||
| The plugin also exports `recommended` and `all` configs, which may be used instead of listing the rules one by one. | ||
|
|
||
| ```diff lang=ts | ||
| import { defineConfig } from "eslint/config"; | ||
| +import typegpu from "eslint-plugin-typegpu"; | ||
|
|
||
| export default defineConfig([ | ||
| // other configs | ||
| + typegpu.configs.recommended, | ||
| ]); | ||
| ``` | ||
|
|
||
| ### Oxlint (`oxlint.config.ts`) | ||
|
|
||
| The plugin needs to be listed in `jsPlugins`. The rules can either be listed one by one, or a config can be used. | ||
|
|
||
| ```diff lang=ts | ||
| import { defineConfig } from "oxlint"; | ||
| +import typegpu from "eslint-plugin-typegpu"; | ||
|
|
||
| +const typegpuPreset = typegpu.configs?.recommended; | ||
| +const typegpuRules = typegpuPreset && "rules" in typegpuPreset ? typegpuPreset.rules : {}; | ||
|
|
||
| export default defineConfig({ | ||
| categories: { correctness: "warn" }, | ||
| + jsPlugins: ["eslint-plugin-typegpu"], | ||
| rules: { | ||
| + ...typegpuRules, | ||
| "eslint/no-unused-vars": "error", | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| ### Oxlint (`.oxlintrc.json`) | ||
|
|
||
| The plugin needs to be listed in `jsPlugins`, and the rules have to be listed one by one. | ||
|
|
||
| ```diff lang=json | ||
| "$schema": "./node_modules/oxlint/configuration_schema.json", | ||
| "plugins": null, | ||
| + "jsPlugins": ["eslint-plugin-typegpu"], | ||
| "categories": {}, | ||
| + "rules": { | ||
| + "typegpu/no-integer-division": "warn", | ||
| + "typegpu/no-math": "warn", | ||
| + }, | ||
| ``` | ||
|
|
||
| ## Rules | ||
|
|
||
| For the full list of supported rules, as well as their specifics, see the [README.md](https://www.npmjs.com/package/eslint-plugin-typegpu) of the plugin. | ||
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.