Skip to content

Commit fe7d82c

Browse files
authored
chore: lint with oxlint (#1359)
* chore: add agent skills lock and agent notes Agent skills are installed from skills-lock.json, while the installed copies in .agents and .claude stay out of git, as in the other Trigen repositories. AGENTS.md describes what matters in this repository; CLAUDE.md points to it. * chore: update Node.js to 26 and pnpm to 12 pnpm 12 reads build script approvals from allowBuilds instead of onlyBuiltDependencies. * ci: align workflows with the Trigen baseline Every job takes Node.js from .tool-versions and pnpm 12, actions are pinned to release commits, which renovate keeps current, and the token of a run only reads unless a job needs more. Tests run as separate types, lint and unit jobs; checks add package.json linting; commitlint runs from the repository; the release job is ready for npm trusted publishing. * chore: measure size with the small-lib preset The big-lib preset runs the bundle in headless Chrome, which no longer works; the small-lib preset measures what a consumer ships, for the whole package and for single components, with limits pinned on a 50 B step. * chore: fix package.json lint errors The description ends with a period and the homepage, now the documentation website, follows the license. * chore: replace the Stack Overflow link with a question template The react-chartjs-2 tag on Stack Overflow gets no new questions since 2025. The bug report now points to the StackBlitz sandbox. * build: build the package with Vite Vite builds the same ESM and CommonJS entries that rollup with swc did, unminified and for modern targets, so the pure annotations reach the bundlers of consumers. Declarations are emitted from tsconfig.build.json, and the scripts follow the Trigen baseline. * test: move tests next to the sources and check types with tsc Specs live beside the code they test, and tsd type tests become @ts-expect-error cases in them, checked by tsc and by Vitest typecheck. * chore: update Storybook to 10 Addons that moved into the core are dropped, the config is ESM TypeScript, and the scripts are named as in the other Trigen repositories: storybook and storybook:build. chartjs-plugin-zoom 3 ships ESM types that the stories need. * chore: write stories in typed CSF3 Stories are type-checked with the rest of the code now, so a change of the component types that breaks a usage shows up in test:types. * chore: remove CLAUDE.md Claude Code reads AGENTS.md by itself. * chore: install the sandboxes from the root workspace The sandboxes were a separate pnpm workspace with their own lockfile, so they got another copy of Chart.js and ran on the package from npm. In the root workspace they share one install and run on the sources of the package; StackBlitz still installs each one with its own package.json from npm. * chore: drop the Storybook alias to the sources The sandboxes resolve the package to its sources through the workspace now. * chore: lint with oxlint ESLint with the standard config and Prettier are replaced by oxlint with @trigen/oxlint-config: base, module, React, type-checked TypeScript, test and Storybook configs, with type-aware rules and type checking on. oxlint --fix also formats, so Prettier is gone. Sample data in sandboxes and stories may use plain numbers and log to the console. * fix: type ref objects with RefObject MutableRefObject is deprecated in React 19 types. RefObject<T | null> accepts the same refs: useRef(null) results with any @types/react version from the peer range. * style: format the code with oxlint The code follows the Trigen style now. Besides formatting: props of elements are ordered, helpers that capture nothing move to the module scope, and stories import types first. * chore: resolve the package to its sources in type checks Stories import the sandboxes, which import react-chartjs-2 by name: without an install of the sandboxes, as in CI, tsc maps the name to the sources. * chore: drop the path mapping to the sources The sandboxes resolve the package to its sources through the workspace now. * chore: add funding links npm fund and the Sponsor button of the repository point to Ko-fi, as in the other repositories of the maintainer. * fix: keep the pure annotations of forwardRef calls swc added them to the build, Vite does not: without them a bundler keeps Chart and its Chart.js core even when only an event helper is imported. The annotations are in the sources now, and size-limit measures a helper-only import. The type test of plugins on the generic Chart, lost in the move from tsd, is back. * chore: update Node.js to 26 and pnpm to 12 pnpm 12 reads build script approvals from allowBuilds instead of onlyBuiltDependencies. * ci: align workflows with the Trigen baseline Every job takes Node.js from .tool-versions and pnpm 12, actions are pinned to release commits, which renovate keeps current, and the token of a run only reads unless a job needs more. Tests run as separate types, lint and unit jobs; checks add package.json linting; commitlint runs from the repository; the release job is ready for npm trusted publishing. * chore: measure size with the small-lib preset The big-lib preset runs the bundle in headless Chrome, which no longer works; the small-lib preset measures what a consumer ships, for the whole package and for single components, with limits pinned on a 50 B step. * chore: fix package.json lint errors The description ends with a period and the homepage, now the documentation website, follows the license. * build: build the package with Vite Vite builds the same ESM and CommonJS entries that rollup with swc did, unminified and for modern targets, so the pure annotations reach the bundlers of consumers. Declarations are emitted from tsconfig.build.json, and the scripts follow the Trigen baseline. * chore: replace the Stack Overflow link with a question template The react-chartjs-2 tag on Stack Overflow gets no new questions since 2025. The bug report now points to the StackBlitz sandbox. * test: move tests next to the sources and check types with tsc Specs live beside the code they test, and tsd type tests become @ts-expect-error cases in them, checked by tsc and by Vitest typecheck. * chore: add funding links npm fund and the Sponsor button of the repository point to Ko-fi, as in the other repositories of the maintainer. * fix: keep the pure annotations of forwardRef calls swc added them to the build, Vite does not: without them a bundler keeps Chart and its Chart.js core even when only an event helper is imported. The annotations are in the sources now, and size-limit measures a helper-only import. The type test of plugins on the generic Chart, lost in the move from tsd, is back. * chore: update Storybook to 10 Addons that moved into the core are dropped, the config is ESM TypeScript, and the scripts are named as in the other Trigen repositories: storybook and storybook:build. chartjs-plugin-zoom 3 ships ESM types that the stories need. * chore: install the sandboxes from the root workspace The sandboxes were a separate pnpm workspace with their own lockfile, so they got another copy of Chart.js and ran on the package from npm. In the root workspace they share one install and run on the sources of the package; StackBlitz still installs each one with its own package.json from npm. * chore: write stories in typed CSF3 Stories are type-checked with the rest of the code now, so a change of the component types that breaks a usage shows up in test:types. * chore: drop the Storybook alias to the sources The sandboxes resolve the package to its sources through the workspace now. * chore: resolve the package to its sources in type checks Stories import the sandboxes, which import react-chartjs-2 by name: without an install of the sandboxes, as in CI, tsc maps the name to the sources. * chore: drop the path mapping to the sources The sandboxes resolve the package to its sources through the workspace now. * chore: send questions to GitHub Discussions Questions go to the Q&A category of Discussions instead of issues, so they stay apart from bug reports and an answer can be marked. * chore: send questions to GitHub Discussions Questions go to the Q&A category of Discussions instead of issues, so they stay apart from bug reports and an answer can be marked. * test: render the typed chart components The specs checked only the props types, so the render function of the typed components was never run. * test: check the controller, ref and options of the typed charts With empty datasets Chart.js never looks up the controller, so the tests passed even without the controller registration. Each test now checks one behavior.
1 parent cfc7317 commit fe7d82c

81 files changed

Lines changed: 2753 additions & 3460 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.eslintignore‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎.eslintrc.json‎

Lines changed: 0 additions & 73 deletions
This file was deleted.

‎.nano-staged.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"**/*.{js,ts,tsx}": ["prettier --write", "eslint"]
2+
"*.{c,m,}{js,ts}{x,}": "oxlint --fix"
33
}

‎.prettierrc‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎.storybook/main.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { StorybookConfig } from '@storybook/react-vite';
1+
import type { StorybookConfig } from '@storybook/react-vite'
22

33
const config: StorybookConfig = {
44
framework: '@storybook/react-vite',
55
stories: ['../stories/*.stories.tsx'],
6-
addons: ['@storybook/addon-docs'],
7-
};
6+
addons: ['@storybook/addon-docs']
7+
}
88

9-
export default config;
9+
export default config

‎.storybook/manager.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { addons } from 'storybook/manager-api';
2-
import { create } from 'storybook/theming';
1+
import { addons } from 'storybook/manager-api'
2+
import { create } from 'storybook/theming'
33

44
addons.setConfig({
55
theme: create({
66
base: 'light',
77
brandTitle: 'react-chartjs-2',
8-
brandUrl: 'https://react-chartjs-2.js.org',
8+
brandUrl: 'https://react-chartjs-2.js.org'
99
}),
10-
panelPosition: 'right',
11-
});
10+
panelPosition: 'right'
11+
})

‎.storybook/preview.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import type { Preview } from '@storybook/react-vite';
2-
import { configureActions } from 'storybook/actions';
1+
import type { Preview } from '@storybook/react-vite'
2+
import { configureActions } from 'storybook/actions'
33

44
// Chart.js passes deeply nested objects to event handlers
55
configureActions({
6-
depth: 5,
7-
});
6+
depth: 5
7+
})
88

99
const preview: Preview = {
1010
parameters: {
11-
layout: 'centered',
12-
},
13-
};
11+
layout: 'centered'
12+
}
13+
}
1414

15-
export default preview;
15+
export default preview

‎oxlint.config.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { defineConfig } from '@trigen/oxlint'
2+
import baseConfig from '@trigen/oxlint-config'
3+
import moduleConfig from '@trigen/oxlint-config/module'
4+
import reactConfig from '@trigen/oxlint-config/react'
5+
import storybookConfig from '@trigen/oxlint-config/storybook'
6+
import testConfig from '@trigen/oxlint-config/test'
7+
import tsTypeCheckedConfig from '@trigen/oxlint-config/typescript-type-checked'
8+
9+
export default defineConfig({
10+
ignorePatterns: [
11+
'**/dist/',
12+
'**/package/',
13+
'**/coverage/',
14+
'**/storybook-static/',
15+
'website/'
16+
],
17+
options: {
18+
typeAware: true,
19+
typeCheck: true
20+
},
21+
env: {
22+
browser: true
23+
},
24+
extends: [
25+
baseConfig,
26+
moduleConfig,
27+
reactConfig,
28+
tsTypeCheckedConfig,
29+
testConfig,
30+
storybookConfig
31+
],
32+
overrides: [
33+
{
34+
// Example data and demos: numbers are data, and the events demo logs to the console
35+
files: ['sandboxes/**', 'stories/**'],
36+
rules: {
37+
'eslint/no-magic-numbers': 'off',
38+
'eslint/no-console': 'off'
39+
}
40+
}
41+
]
42+
})

‎package.json‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@
4949
"storybook": "storybook dev -p 6006 --no-open",
5050
"storybook:build": "storybook build",
5151
"sandboxes:build": "pnpm -r --filter \"./sandboxes/**\" build",
52-
"lint": "eslint \"src/**/*.{ts,tsx}\" \"stories/**/*.{ts,tsx}\" \"sandboxes/**/*.{ts,tsx}\"",
52+
"lint": "oxlint",
5353
"test:unit": "vitest run --coverage",
5454
"test:unit:watch": "vitest watch",
5555
"test:types": "tsc --noEmit",
5656
"test:size": "size-limit",
5757
"test": "run -p lint test:unit test:types",
58-
"format": "prettier --write src",
58+
"format": "oxlint --fix",
5959
"commit": "cz",
6060
"updateGitHooks": "simple-git-hooks"
6161
},
@@ -73,13 +73,13 @@
7373
"@testing-library/dom": "^10.4.0",
7474
"@testing-library/jest-dom": "^6.6.3",
7575
"@testing-library/react": "^16.1.0",
76+
"@trigen/oxlint": "^12.0.0",
77+
"@trigen/oxlint-config": "^12.4.0",
7678
"@trigen/scripts": "^12.0.0",
7779
"@types/faker": "^5.5.8",
7880
"@types/node": "^18.0.0",
7981
"@types/react": "^19.2.2",
8082
"@types/react-dom": "^19.2.2",
81-
"@typescript-eslint/eslint-plugin": "^8.18.0",
82-
"@typescript-eslint/parser": "^8.18.0",
8383
"@vitejs/plugin-react": "^5.0.0",
8484
"@vitest/coverage-v8": "^4.0.0",
8585
"chart.js": "^4.4.7",
@@ -90,19 +90,11 @@
9090
"commitizen": "^4.2.4",
9191
"date-fns": "^2.25.0",
9292
"del-cli": "^7.0.0",
93-
"eslint": "^8.57.1",
94-
"eslint-config-prettier": "^9.1.0",
95-
"eslint-config-standard": "^17.1.0",
96-
"eslint-config-standard-react": "^13.0.0",
97-
"eslint-plugin-import": "^2.25.1",
98-
"eslint-plugin-n": "^17.0.0",
99-
"eslint-plugin-prettier": "^5.2.1",
100-
"eslint-plugin-promise": "^7.0.0",
101-
"eslint-plugin-react": "^7.17.0",
10293
"faker": "^5.5.3",
10394
"happy-dom": "^20.0.0",
10495
"nano-staged": "^0.8.0",
105-
"prettier": "^3.4.2",
96+
"oxlint": "^1.95.0",
97+
"oxlint-tsgolint": "^7.0.2009",
10698
"react": "^19.0.0",
10799
"react-dom": "^19.0.0",
108100
"simple-git-hooks": "^2.6.1",

0 commit comments

Comments
 (0)