Skip to content

Commit

Permalink
reuse my biome config
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Oct 18, 2024
1 parent aecc4d3 commit 1c3628b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 54 deletions.
27 changes: 1 addition & 26 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.0/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"noNonNullAssertion": "off",
"noParameterAssign": "off"
},
"suspicious": {
"noExplicitAny": "off"
}
}
},
"formatter": {
"lineWidth": 100,
"indentStyle": "space"
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "none"
}
},
"extends": ["@arthurfiorette/biomejs-config"],
"files": {
"ignore": [
"build/**/*",
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"author": "Arthur Fiorette <[email protected]>",
"sideEffects": false,
"type": "module",
"source": "./src/index.ts",
"exports": {
".": {
"require": "./dist/index.cjs",
Expand All @@ -28,20 +27,21 @@
"jsdelivr": "./dist/index.bundle.js",
"unpkg": "./dist/index.bundle.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"scripts": {
"benchmark": "cd benchmark && pnpm start",
"build": "bash build.sh",
"docs:build": "vitepress build docs",
"docs:dev": "vitepress dev docs --port 1227",
"docs:serve": "vitepress serve docs",
"test": "c8 --reporter lcov --reporter text node --import ./test/setup.js --enable-source-maps --test test/**/*.test.ts",
"test:only": "c8 --reporter lcov --reporter text node --import ./test/setup.js --enable-source-maps --test-only",
"version": "auto-changelog -p && cp CHANGELOG.md docs/src/others/changelog.md && git add CHANGELOG.md docs/src/others/changelog.md",
"format": "biome format --write .",
"lint": "biome check .",
"lint:ci": "biome ci .",
"lint:fix": "biome check --write --unsafe .",
"lint:ci": "biome ci ."
"test": "c8 --reporter lcov --reporter text node --import ./test/setup.js --enable-source-maps --test test/**/*.test.ts",
"test:only": "c8 --reporter lcov --reporter text node --import ./test/setup.js --enable-source-maps --test-only",
"version": "auto-changelog -p && cp CHANGELOG.md docs/src/others/changelog.md && git add CHANGELOG.md docs/src/others/changelog.md"
},
"resolutions": {
"colors": "1.4.0"
Expand All @@ -52,6 +52,7 @@
"object-code": "1.3.3"
},
"devDependencies": {
"@arthurfiorette/biomejs-config": "1.0.5",
"@biomejs/biome": "1.9.4",
"@swc-node/register": "1.9.0",
"@swc/helpers": "0.5.13",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 6 additions & 23 deletions test/interceptors/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import assert from 'node:assert';
import { describe, it, mock } from 'node:test';
import { setTimeout } from 'node:timers/promises';
import type { AxiosAdapter, AxiosResponse } from 'axios';
import type {
CacheRequestConfig,
InternalCacheRequestConfig
} from '../../src/cache/axios.js';
import type { CacheRequestConfig, InternalCacheRequestConfig } from '../../src/cache/axios.js';
import { Header } from '../../src/header/headers.js';
import { buildMemoryStorage } from '../../src/index.js';
import type { LoadingStorageValue } from '../../src/storage/types.js';
Expand Down Expand Up @@ -113,10 +110,7 @@ describe('Request Interceptor', () => {
});

it('Cache expiration', async () => {
const axios = mockAxios(
{},
{ [Header.CacheControl]: 'max-age=1,stale-while-revalidate=10' }
);
const axios = mockAxios({}, { [Header.CacheControl]: 'max-age=1,stale-while-revalidate=10' });

await axios.get('http://test.com', {
cache: { interpretHeader: true }
Expand Down Expand Up @@ -267,9 +261,7 @@ describe('Request Interceptor', () => {
adapter: async (config: InternalCacheRequestConfig) => {
await setTimeout(10);

const response = (await (axios.defaults.adapter as AxiosAdapter)(
config
)) as AxiosResponse;
const response = (await (axios.defaults.adapter as AxiosAdapter)(config)) as AxiosResponse;

// Changes the response to be different from `true` (default)
response.data = 'overridden response';
Expand Down Expand Up @@ -424,10 +416,7 @@ describe('Request Interceptor', () => {
assert.equal(req1.cached, false);
assert.equal(req1.stale, undefined);

const [req2, req3] = await Promise.all([
axios.get('some-other'),
axios.get('some-other')
]);
const [req2, req3] = await Promise.all([axios.get('some-other'), axios.get('some-other')]);

assert.equal(req2.cached, false);
assert.equal(req2.stale, undefined);
Expand All @@ -449,20 +438,14 @@ describe('Request Interceptor', () => {
assert.equal(req1.cached, false);
assert.equal(req1.stale, undefined);

const [req2, req3] = await Promise.all([
axios.get('some-other'),
axios.get('some-other')
]);
const [req2, req3] = await Promise.all([axios.get('some-other'), axios.get('some-other')]);

assert.equal(req2.cached, false);
assert.equal(req2.stale, undefined);
assert.ok(req3.cached);
assert.equal(req3.stale, false);

const [req4, req5] = await Promise.all([
axios.get('other/url'),
axios.get('other/url')
]);
const [req4, req5] = await Promise.all([axios.get('other/url'), axios.get('other/url')]);

assert.equal(req4.cached, false);
assert.equal(req4.stale, undefined);
Expand Down

0 comments on commit 1c3628b

Please sign in to comment.