Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

19 changes: 0 additions & 19 deletions .eslintrc.cjs

This file was deleted.

2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

43 changes: 43 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.8/schema.json",
"extends": ["./modules/dev-tools/src/configuration/biome.jsonc"],
"files": {
"includes": [
"!**/dist/**",
"!**/build/**",
"!**/.cache/**",
"modules/**/*.js",
"modules/**/*.jsx",
"modules/**/*.ts",
"modules/**/*.tsx",
"scripts/**/*.js",
"scripts/**/*.jsx",
"scripts/**/*.ts",
"scripts/**/*.tsx",
"!**/test-case-*.ts"
]
},
"linter": {
"rules": {
"a11y": {
"recommended": false
},
"correctness": {
"useExhaustiveDependencies": "off",
"useHookAtTopLevel": "off"
},
"suspicious": {
"noArrayIndexKey": "off",
"noConsole": "off"
}
}
},
"overrides": [
{
"includes": ["modules/docusaurus-website/**/*.tsx"],
"javascript": {
"jsxRuntime": "reactClassic"
}
}
]
}
3 changes: 1 addition & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Welcome

ocular is a set of tools to help build and publish open source frameworks. It contains:
- a `dev-tools` module that installs and provides base configurations for tools like webpack, babel, lerna, eslint prettier etc.
- a `dev-tools` module that installs and provides base configurations for tools such as Biome, Vite, esbuild and lerna.
- a `gatsby-theme-ocular` module that contains a markdown to HTML converter to make it easy to build websites.
## About ocular-dev-tools

Expand All @@ -26,4 +26,3 @@ We wanted:
Happy documenting!

To find out more, go to [get started](get-started.md)

6 changes: 0 additions & 6 deletions docs/table-of-contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@
{
"entry": "modules/dev-tools/docs/api-reference/get-babel-config"
},
{
"entry": "modules/dev-tools/docs/api-reference/get-eslint-config"
},
{
"entry": "modules/dev-tools/docs/api-reference/get-prettier-config"
},
{
"entry": "modules/dev-tools/docs/api-reference/get-webpack-config"
}
Expand Down
49 changes: 17 additions & 32 deletions modules/dev-tools/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Dev tools for vis.gl open source Javascript frameworks
Contains developer targets for building, cleaning, linting, testing and publishing frameworks.

* The testing script has a number of modes, it can run tests on both browser and node, it can run test on src or built distributions etc.
* The linting feature supports both code and markdown, and runs both eslint and prettier.
* The linting feature uses Biome to format and lint JavaScript and TypeScript.
* Supports both single module repos (all code in src) and monorepos (code in `modules/<module-name>/src`).

Note: flow is not currently integrated into ocular-dev-tools as we restrict its use to React related code bases.
Expand All @@ -14,8 +14,7 @@ Note: flow is not currently integrated into ocular-dev-tools as we restrict its

ocular installs the necessary dependencies and provides working default configurations for

- eslint
- prettier
- Biome
- ts-node
- vite

Expand Down Expand Up @@ -58,7 +57,7 @@ After installing you can set up your build scripts in package.json as follows:
| [`ocular-bootstrap`](docs/dev-tools/cli/ocular-bootstrap) | `bootstrap` | Install dependencies for monorepos |
| [`ocular-clean`](docs/dev-tools/cli/ocular-clean) | `clean` | Remove all transpiled files in preparation for a new build. |
| [`ocular-build`](docs/dev-tools/cli/ocular-build) | `build` | Transpile all modules. |
| [`ocular-lint`](docs/dev-tools/cli/ocular-lint) | `lint` | Run eslint & prettier on the code base. |
| [`ocular-lint`](docs/dev-tools/cli/ocular-lint) | `lint` | Format and lint the code base with Biome. |
| [`ocular-test`](docs/dev-tools/cli/ocular-test) | `test` | Run tests. |
| [`ocular-metrics`](docs/dev-tools/cli/ocular-metrics) | `metrics` | Bundle the source and report the bundle size. |
| [`ocular-publish`](docs/dev-tools/cli/ocular-publish) | `publish` | Publish the packages, create git tag and push. |
Expand All @@ -73,9 +72,8 @@ To provide maximum control to the user, ocular build scripts use config files in
A file `.ocularrc.js` can be placed at the root of the package to customize the dev scripts. The config file may export a JSON object that contains the following keys, or a callback function that returns such object:

- `esm` (Boolean) - set if tests should run using Node.js's ES module resolution. By default `true` if and only if `type: "module"` is found in the root package.json.
- `lint` - options to control eslint behavior
- `lint` - options to control Biome's target paths
+ `paths` (Arrray) - directories to include when linting. Default `['modules', 'src']`
+ `extensions` (Array) - file extensions to include when linting. Default `['js', 'md']`
- `aliases` (Object) - Module aliases to use in tests. Any import from a submodule is mapped to its source. Use this object to define additional mappings, for example `"test-data": "./test/sample-data`.
- `nodeAliases` (Object) - Module aliases to use in node tests only.
- `typescript`
Expand All @@ -95,35 +93,22 @@ A file `.ocularrc.js` can be placed at the root of the package to customize the
- `browserTest` (Object) - options for browser tests. Passed to [BrowserTestDriver.run](https://uber-web.github.io/probe.gl/#/documentation/api-reference-testing/browsertestdriver).


#### eslint
#### Biome

You may extend the default eslint config with a `.eslintrc.js` or `eslint.config.js` at the project root:
`ocular-lint` uses `biome.json` or `biome.jsonc` at the project root when present. A project may
extend the shared vis.gl defaults and add repository-specific file selection and rule overrides:

```js
// .eslintrc.js
const {getEslintConfig} = require('ocular-dev-tools/configuration');

module.exports = getEslintConfig({
react: '18.0',
// specify custom configs
overrides: {}
});
```

#### prettier

You may extend the default eslint config with a `.prettier.js` or `prettier.config.js` at the project root:

```js
// .prettier.js
const {getPrettierConfig} = require('ocular-dev-tools/configuration');

module.exports = getPrettierConfig({
// specify custom configs
overrides: {}
});
```jsonc
{
"$schema": "https://biomejs.dev/schemas/2.4.8/schema.json",
"extends": ["@vis.gl/dev-tools/biome.jsonc"],
"files": {
"includes": ["modules/**/*.js", "modules/**/*.ts", "test/**/*.ts"]
}
}
```

When no project configuration exists, `ocular-lint` uses the packaged defaults directly.
#### vite

If `vite.config.js` is found at the root of the package, it is used to bundle units tests and benchmark tests for the browser. Otherwise, a default vite config is used.
Expand All @@ -137,5 +122,5 @@ To enable ESM mode:

- Add `type: 'module'` to the root `package.json` and each submodule's `package.json`s.
- Add `compilerOptions.module: 'esnext'` to `tsconfig.json`.
- ES5-style `require()` and `module.exports` must be removed from all `.js` files. Some dev dependencies, for example eslint, may not support ESM syntax. In this case, rename the config files to use the `.cjs` extension so that they can be imported successfully.
- ES5-style `require()` and `module.exports` must be removed from all `.js` files. Dependencies that do not support ESM syntax may still require `.cjs` configuration files.
- When importing directly from a non-TypeScript file, the file extension must be specified. E.g. `import './init'` now becomes `import './init.js'`.
26 changes: 0 additions & 26 deletions modules/dev-tools/docs/api-reference/get-eslint-config.md

This file was deleted.

19 changes: 0 additions & 19 deletions modules/dev-tools/docs/api-reference/get-prettier-config.md

This file was deleted.

9 changes: 6 additions & 3 deletions modules/dev-tools/docs/cli/ocular-lint.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# ocular-lint

Run eslint & prettier on the code base.
Format and lint JavaScript and TypeScript with Biome.

```bash
ocular-lint [mode]
```

## Modes

- `full` (default) - run on all files.
- `full` (default) - run on all configured paths.
- `pre-commit` - only run on changed files since the last commit.
- `fix` - run prettier and eslint --fix on all files.
- `fix` - apply Biome's safe lint fixes and formatting changes.

## Configuration

[Configurations](#ocular-dev-tools-1): `lint`

`ocular-lint` loads `biome.json` or `biome.jsonc` from the project root. If neither exists, it
uses the configuration shipped by `@vis.gl/dev-tools`.
8 changes: 8 additions & 0 deletions modules/dev-tools/docs/upgrade-guide.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Upgrade Guide

## @vis.gl/dev-tools 2.0.0

`ocular-lint` now uses Biome for both formatting and linting. Remove project ESLint and Prettier
configuration and add a root `biome.jsonc` that extends `@vis.gl/dev-tools/biome.jsonc`.

The `getESLintConfig` and `getPrettierConfig` exports have been removed. Biome configuration is
shared as JSON instead of through JavaScript configuration builders.

## ocular-dev-tools 1.0.0

Functional entry points replace subpath imports
16 changes: 2 additions & 14 deletions modules/dev-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./configuration": {
"types": "./dist/configuration/index.d.ts",
"require": "./dist/configuration/index.cjs",
"import": "./dist/configuration/index.js"
}
"./biome.jsonc": "./src/configuration/biome.jsonc"
},
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
Expand All @@ -50,23 +46,16 @@
"dependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.0",
"@esbuild-plugins/node-modules-polyfill": "^0.2.0",
"@biomejs/biome": "^2.4.8",
"@probe.gl/test-utils": "^4.0.6",
"c8": "^7.12.0",
"coveralls": "^3.0.3",
"deepmerge": "^4.2.2",
"esbuild": "^0.16.7",
"esbuild-plugin-external-global": "^1.0.1",
"eslint": "^8.52.0",
"eslint-config-prettier": "^8.0.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-markdown": "^2.2.0",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.0.0",
"glob": "^7.1.4",
"lerna": "^8.1.0",
"minimatch": "^3.0.0",
"prettier": "^3.2.0",
"semver": "^7.6.0",
"tap-spec": "^5.0.0",
"tape": "^4.11.0",
Expand All @@ -75,7 +64,6 @@
"ts-patch": "^3.1.2",
"tsconfig-paths": "^4.1.1",
"typescript": "^5.2.2",
"typescript-eslint": "^7.7.0",
"vite": "^4.5.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion modules/dev-tools/scripts/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function main() {

if (modules) {
packages = packages.concat(
modules.map(function (module) {
modules.map((module) => {
const version = getTargetVersion(packageAndVersion, module.name);
return {
name: module.name,
Expand Down
2 changes: 1 addition & 1 deletion modules/dev-tools/scripts/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function run() {
if (env.watch) {
buildConfig.watch = true;
await esbuild.build(buildConfig);
/* eslint-disable no-console */
// biome-ignore lint/suspicious/noConsole: Verbose mode intentionally prints bundle diagnostics.
console.log('watching...');
} else {
const result = await esbuild.build(buildConfig);
Expand Down
Loading
Loading