Skip to content

Commit

Permalink
chore: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
43081j committed Mar 9, 2024
1 parent afe5427 commit 260f685
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export default [
];
```

## Rules

- [`optimize/redundant-polyfills`](./docs/rules/redundant-polyfills.md)
- [`optimize/avoid-micro-utilities`](./docs/rules/avoid-micro-utilities.md)

## License

MIT
28 changes: 28 additions & 0 deletions docs/rules/avoid-micro-utilities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Detects possibly redundant micro-utilities, preferring local/inline functionality instead

This rule detects imports of "micro utilities" - very small packages which
provide utilities you could replace with native functionality or your own
code.

## Rule Details

This rule detects possibly redundant micro-utilities.

The following patterns are considered warnings:

```ts
const isNaN = require('is-nan');
isNaN(v);
```

The following patterns are not warnings:

```ts
Number.isNaN(v);
```

## When Not To Use It

If you prefer the cost of pulling in many utility dependencies over
the cost of writing the equivalent snippet yourself, it may be worth disabling
this rule.
32 changes: 32 additions & 0 deletions docs/rules/redundant-polyfills.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Detects possibly redundant polyfills of natively available functionality

This rule detects imports of dependencies which provide functionality now
available natively.

If your package has an `engines` constraint for `node`, it will be taken
into account (i.e. polyfills of functionality your version doesn't yet have
will be allowed).

## Rule Details

This rule detects possibly redundant polyfills.

The following patterns are considered warnings:

```ts
// With no `engines` or `engines.node` is `>=7.0.0`
const entries = require('object.entries');
entries({foo: 'bar'});
```

The following patterns are not warnings:

```ts
// With no `engines` or `engines.node` is `>=7.0.0`
Object.entries({foo: 'bar'});
```

## When Not To Use It

If you need to support much older JS runtimes (node, browsers, etc), this
rule may not be of much use as the polyfills are probably still useful there.

0 comments on commit 260f685

Please sign in to comment.