NPM configuration for base typescript projects
Includes:
And configuration for saneish defaults, which can be extended
Most of these are the raw defaults/recommended settings from typescript, eslint and prettier.
Install the oxc extension, then update settings.json:
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true,IntelliJ has an Oxc plugin supporting oxfmt and oxlint: https://plugins.jetbrains.com/plugin/27061-oxc
- Install
@linzjs/style:
# this also installs dependencies: madge oxfmt oxlint oxlint-tsgolint
npm install --save-dev @linzjs/style- Install the config files: There are two ways to apply the config
Either create the base configuration files
# If on windows run `node ./node_modules/@linzjs/style/build/src/install.js`
# - oxfmt.config.ts
# - oxlint.config.ts
# - tsconfig.json
npx linz-style-installOr extend your existing oxlint.config.ts config
Example extending the oxlint.config.ts file in your project
import base from '@linzjs/style/oxlint.config-react';
import { defineConfig } from 'oxlint';
export default defineConfig({
extends: [base],
overrides: [
{
/** Overrides for typescript */
files: ['**/*.ts', '**/*.tsx'],
rules: {
'react/super-crazy-hook-rule': 'error',
},
},
],
});- Update
package.jsonscripts
Add/update lint-related commands in package.json:
scripts: {
"lint": "npx concurrently \"npm run lint:circular\" \"npm run lint:oxlint\" \"npm run lint:fmt\" \"tsc\"",
"lint:circular": "madge --circular --extensions js,ts,tsx --ts-config tsconfig.json ./src",
"lint:oxlint": "oxlint --deny-warnings",
"lint:fmt": "oxfmt --check .",
"lint:fix": "oxlint --fix",
"format": "oxfmt --write ."
}- Apply the formatting/linting to all source code
npm run lint .
See Migration Docs
See Migration Docs