Skip to content

Commit

Permalink
docs: fix renamed rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Handfish committed Feb 4, 2024
1 parent 32d0c4d commit 41091e4
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 66 deletions.
2 changes: 1 addition & 1 deletion apps/docs/src/pages/aliasing_ajel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
ajelAlias: 'blimpy',
sjelAlias: "limpyb",
},
'ajel/ajel-strict-error-instanceof': [
'ajel/ajel-require-error-handling': [
'off',
{
ajelAlias: 'blimpy',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ajel/ajel-strict-error-instanceof
# ajel/ajel-require-error-handling

> This rule enforces narrowing the error type with `instanceof`.
## Summary

The `ajel-strict-error-instanceof` rule ensures that when calling `ajel` or `sjel`, the error variable is properly narrowed using the `instanceof` operator. This helps developers perform more specific error handling and enhances the type safety of the code.
The `ajel-require-error-handling` rule ensures that when calling `ajel` or `sjel`, the error variable is properly narrowed using the `instanceof` operator. This helps developers perform more specific error handling and enhances the type safety of the code.

## Rule Details

Expand All @@ -21,8 +21,8 @@ Properly narrowing the error type with `instanceof` promotes more precise error

## Implementation

- [Rule source](https://github.com/Handfish/ajel/blob/main/packages/eslint-plugin-ajel/src/rules/ajel-strict-error-instanceof.ts)
- [Test source](https://github.com/Handfish/ajel/blob/main/packages/eslint-plugin-ajel/tests/rules/ajel-strict-error-instanceof.ts)
- [Rule source](https://github.com/Handfish/ajel/blob/main/packages/eslint-plugin-ajel/src/rules/ajel-require-error-handling.ts)
- [Test source](https://github.com/Handfish/ajel/blob/main/packages/eslint-plugin-ajel/tests/rules/ajel-require-error-handling.ts)

## Examples

Expand Down
2 changes: 1 addition & 1 deletion packages/ajel-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ajel",
"description": "ajel encourages better error handling via an elslint plugin",
"version": "0.0.17",
"version": "0.0.18",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-ajel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'ajel/ajel-disable-throw': [
'warn',
],
'ajel/ajel-strict-error-instanceof': [
'ajel/ajel-require-error-handling': [
'off',
{
ajelAlias: 'blimpy',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-ajel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-ajel",
"version": "0.0.17",
"version": "0.0.18",
"description": "Eslint plugin for ajel - the library which encourages better error handling via an elslint plugin",
"engines": {
"node": ">=8.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,6 @@ import { Position } from 'estree';
import { earliestUsedPosition } from '../utils/earliestUsedPosition';
import { isPositionEarlier } from '../utils/isPositionEarlier';

//import { ajel } from '../utils/ajel';
//import { sjel } from '../utils/sjel';

//class CustomError extends Error { }
//class CustomError2 extends Error { }
//class CustomError3 extends Error { }

//const testfn = async () => {
// const test = await ajel(Promise.resolve('test'));
// const test2 = sjel(JSON.parse, '{}');
// const test3 = await ajel(Promise.resolve('test'));
// const test5 = sjel((stringvar: string) => stringvar, '{}');

// //------ Test2 SJEL
// if (test2 instanceof CustomError) {
// //We can access the error here in BinaryExpression with var instanceof
// console.log(test2);
// return;
// }

// // Cant Access the test2 variable here
// console.log(test2);
// console.log(test2);

// if (test2 instanceof Error) {
// console.log(test2);
// // This return narrows the type of test2 to its Result
// return;
// }
// // Type is narrowed - no longer a union of Result | Error -> just Result
// console.log(test2);

// //------ Test AJEL
// // Cant Access the test variable here
// console.log(test);
// console.log(test);

// switch (true) {
// case test instanceof CustomError3:
// //We can access the error here in BinaryExpression with var instanceof
// console.log(test);
// break;
// //We support fall through
// case test instanceof CustomError2:
// case test instanceof CustomError:
// console.log(test);
// break;
// case test instanceof Error:
// break;
// }
// console.log(test);

// //---- No handling of AJEL and SJEL returns
// console.log(test3);
// console.log(test5);
//};
//console.log(testfn);

interface ErrorReportInfo {
ajelOrSjel: 'ajel' | 'sjel';
instanceofPosition: Position | undefined;
Expand Down

0 comments on commit 41091e4

Please sign in to comment.