Skip to content

Commit

Permalink
feat(ui): lint & typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
ixahmedxi committed Jan 26, 2024
1 parent ef83b94 commit fb1a151
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
1 change: 1 addition & 0 deletions packages/config/eslint/base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @type {import('eslint').Linter.Config} */
const config = {
ignorePatterns: ['node_modules', 'dist', '.next', '.astro'],
env: {
es2022: true,
node: true,
Expand Down
1 change: 1 addition & 0 deletions packages/config/eslint/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const config = {
},
rules: {
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
},
},
],
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('eslint').Linter.Config} */
const config = {
root: true,
extends: ['orbitkit/base', 'orbitkit/react'],
};

module.exports = config;
4 changes: 3 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch"
"dev": "tsup --watch",
"lint": "eslint . --cache --max-warnings 0",
"typecheck": "tsc --noEmit --tsBuildInfoFile .tsbuildinfo"
},
"dependencies": {
"@radix-ui/react-avatar": "^1.0.4",
Expand Down
1 change: 1 addition & 0 deletions packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"@/*": ["./src/*"],
},
},
"include": ["**/*.ts", "**/*.tsx", ".eslintrc.cjs"],
"exclude": ["dist", "node_modules"],
}
54 changes: 29 additions & 25 deletions packages/ui/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ const entries = [
},
];

type PackageJson = {
exports: Record<string, unknown>;
main: string;
module: string;
types: string;
};

export default defineConfig({
entry: entries.map((entry) => entry.source),
format: ['esm', 'cjs'],
Expand All @@ -29,31 +36,28 @@ export default defineConfig({
outDir: 'dist',
async onSuccess() {
const packageJson = fs.readFileSync('./package.json', 'utf-8');
const pkg = JSON.parse(packageJson);
pkg.exports = entries.reduce(
(acc: { [key: string]: Record<string, unknown> }, entry) => {
acc[entry.export] = {
import: {
default: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.js'),
types: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.d.ts'),
},
require: {
default: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.cjs'),
types: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.d.cts'),
},
};
return acc;
},
{},
);
const pkg = JSON.parse(packageJson) as PackageJson;
pkg.exports = entries.reduce((acc: Record<string, unknown>, entry) => {
acc[entry.export] = {
import: {
default: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.js'),
types: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.d.ts'),
},
require: {
default: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.cjs'),
types: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.d.cts'),
},
};
return acc;
}, {});

pkg.main = './dist/index.cjs';
pkg.module = './dist/index.js';
Expand Down

0 comments on commit fb1a151

Please sign in to comment.