Skip to content

Commit

Permalink
Bump dev deps & use bun as test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Apr 30, 2023
1 parent ba7d589 commit 51ea5d9
Show file tree
Hide file tree
Showing 7 changed files with 340 additions and 237 deletions.
Binary file modified bun.lockb
Binary file not shown.
20 changes: 12 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
"prettier": "bun prettier-ci --write",
"prettier-ci": "prettier --ignore-path=.gitignore --check '**/*.{ts,json,md,yml}'",
"test": "src/tests.ts",
"ci": "tsc && bun prettier-ci && bun run test && bun run build"
"ci": "tsc && bun prettier-ci && bun test && bun run build"
},
"prettier": {
"trailingComma": "all"
},
"peerDependencies": {
"eslint": ">=7"
},
"devDependencies": {
"@nabla/tnode": "^0.7.0",
"@types/eslint": "^8.4.10",
"@types/node": "^18.11.9",
"@typescript-eslint/utils": "^5.42.1",
"eslint": "^8.27.0",
"prettier": "^2.7.1",
"typescript": "^4.8.4"
"@nabla/tnode": "^0.9.0",
"@types/eslint": "^8.37.0",
"@types/node": "^18.16.3",
"@typescript-eslint/utils": "^5.59.1",
"bun-types": "^0.5.8",
"eslint": "^8.39.0",
"prettier": "^2.8.8",
"typescript": "^5.0.4"
}
}
10 changes: 2 additions & 8 deletions scripts/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ build({
outdir: "dist",
platform: "node",
target: "node14",
// https://github.com/oven-sh/bun/issues/2037
// external: Object.keys(packageJSON.peerDependencies),
external: ["eslint"],
external: Object.keys(packageJSON.peerDependencies),
}).then(() => {
execSync("cp LICENSE README.md dist/");

Expand All @@ -38,11 +36,7 @@ build({
"react-refresh",
"fast refresh",
],
// https://github.com/oven-sh/bun/issues/2037
// peerDependencies: packageJSON.peerDependencies,
peerDependencies: {
eslint: ">=7",
},
peerDependencies: packageJSON.peerDependencies,
},
null,
2,
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { onlyExportComponents } from "./only-export-components";
import { onlyExportComponents } from "./only-export-components.ts";

export const rules = {
"only-export-components": onlyExportComponents,
Expand Down
19 changes: 4 additions & 15 deletions src/tests.ts → src/only-export-components.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env tnode
import { test } from "bun:test";
import { RuleTester } from "eslint";
import { onlyExportComponents } from "./only-export-components";
import { onlyExportComponents } from "./only-export-components.ts";

const ruleTester = new RuleTester({
parserOptions: {
Expand Down Expand Up @@ -173,22 +174,15 @@ const invalid = [
},
];

let failedTests = 0;

const it = (name: string, cases: Parameters<typeof ruleTester.run>[2]) => {
try {
test(name, () => {
ruleTester.run(
"only-export-components",
// @ts-ignore Mismatch between typescript-eslint and eslint
onlyExportComponents,
cases,
);
console.log(`${name} ✅`);
} catch (e) {
console.log(`${name} ❌`);
console.error(e);
failedTests++;
}
});
};

valid.forEach(({ name, code, filename, options = [] }) => {
Expand All @@ -211,8 +205,3 @@ invalid.forEach(({ name, code, errorId, filename, options = [] }) => {
],
});
});

if (failedTests) {
console.log(`${failedTests} tests failed`);
process.exit(1);
}
19 changes: 9 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
"include": ["src", "scripts"],
"compilerOptions": {
/* Target node 14 */
"target": "ES2020",
"module": "CommonJS",
"lib": ["ES2020"],
"target": "ES2020",
"skipLibCheck": true,
"types": ["bun-types"],

/* Transpile with esbuild */
"noEmit": true,
"moduleResolution": "node16",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,

/* Imports */
"moduleResolution": "node", // Allow `index` imports
"resolveJsonModule": true, // Allow json import
"forceConsistentCasingInFileNames": true, // Avoid difference in case between file name and import
"noEmit": true,

/* Linting */
"skipLibCheck": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"useUnknownInCatchVariables": true
"useUnknownInCatchVariables": true,
"noPropertyAccessFromIndexSignature": true
}
}
Loading

0 comments on commit 51ea5d9

Please sign in to comment.