Skip to content

Commit

Permalink
feat: Add opt-in-sort rule (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhamlin authored Feb 5, 2023
1 parent 3c8e8c8 commit df80288
Show file tree
Hide file tree
Showing 12 changed files with 1,357 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ESLint Plugin

[![npm version](https://badge.fury.io/js/eslint-plugin-adamhamlin.svg)](https://badge.fury.io/js/eslint-plugin-adamhamlin)
[![CI Status Badge](https://github.com/adamhamlin/eslint-plugin/actions/workflows/ci.yaml/badge.svg)](https://github.com/adamhamlin/eslint-plugin/actions/workflows/ci.yaml)

My collection of miscellaneous custom ESLint rules!
Expand All @@ -26,6 +27,7 @@ Then configure the rules you want to use under the rules section.
{
"rules": {
"adamhamlin/no-empty-block-comment": "error",
"adamhamlin/opt-in-sort": "error",
"adamhamlin/forbid-pattern-everywhere": [
"error",
{
Expand All @@ -40,8 +42,9 @@ Then configure the rules you want to use under the rules section.

This plugin makes the following lint rules available:

- [forbid-pattern-everywhere](./docs/rules/forbid-pattern-everywhere.md) - Specified pattern(s) are disallowed **everywhere**--in variables, functions, literals, property names, classes, types, interfaces, etc.
- [no-emppty-block-comment](./docs/rules/no-empty-block-comment.md) - Block comments must have non-empty content.
- [opt-in-sort](./docs/rules/opt-in-sort.md) - Enforce sorting of object keys, array values, or TS enums/interfaces/types by adding the `@sort` annotation.
- [forbid-pattern-everywhere](./docs/rules/forbid-pattern-everywhere.md) - Specified pattern(s) are disallowed **everywhere**--in variables, functions, literals, property names, classes, types, interfaces, etc.

<!-- begin auto-generated rules list -->

Expand Down
15 changes: 15 additions & 0 deletions __tests__/misc-utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as MiscUtils from '../src/utils/misc-utils';

describe('Misc Utils', () => {
describe('assertIsDefined', () => {
it('No error when value is defined', () => {
expect(() => MiscUtils.assertDefined(5)).not.toThrow();
});

it('Assertion error thrown when value is nullish', () => {
const expectedError = new MiscUtils.AssertionError('Value is null or undefined.');
expect(() => MiscUtils.assertDefined(null)).toThrow(expectedError);
expect(() => MiscUtils.assertDefined(undefined)).toThrow(expectedError);
});
});
});
Loading

0 comments on commit df80288

Please sign in to comment.