bec-react-types
v0.1.7
Published
Shared TypeScript types for BEC React applications
Readme
bec-react-types
Shared TypeScript types and utilities published by BECOM Electronics.
Installation
npm install bec-react-typesAPI
Types
ApplicationError
A class representing a structured application error.
class ApplicationError {
code?: string;
message: string;
}FunctionBoxItem
A type representing an item in a function box selection list.
type FunctionBoxItem = {
code: string;
description: string;
};Services
ApplicationErrorFactory(message, code?)
Factory function that creates an ApplicationError instance.
import { ApplicationErrorFactory } from 'bec-react-types';
const error = ApplicationErrorFactory('Something went wrong', 'ERR_001');
// error.message === 'Something went wrong'
// error.code === 'ERR_001'Building
npm run buildOutput is written to dist/.
License
Copyright © BECOM Electronics tseslint.configs.strictTypeChecked, // Optionally, add this for stylistic rules tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},}, ])
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])