Skip to content

Commit d21c7e8

Browse files
authored
chore: refactors functionality for better maintainability (#335)
1 parent bc2d364 commit d21c7e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3164
-3280
lines changed

.codependencerc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
"codecov",
77
"codependence",
88
"commitizen",
9-
"conventional-changelog-cli",
109
"eslint",
1110
"eslint-config-prettier",
12-
"husky",
1311
"mocha",
1412
"nyc",
1513
"path-exists-cli",

.github/CHANGELOG.md

Lines changed: 0 additions & 265 deletions
This file was deleted.

.github/blocks/all.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

.husky/commit-msg

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/post-merge

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Modern JavaScript builds assume proper transpilation via tools like Babel. ES Ch
8080

8181
## What features does ES Check check for?
8282

83-
ES Check validates syntax by default. Add `--checkFeatures` for ES version-specific feature checking. View supported [features](./constants.js).
83+
ES Check validates syntax by default. Add `--checkFeatures` for ES version-specific feature checking. View supported [features](./lib/helpers/detectFeatures/constants/es-features/).
8484

8585
---
8686

@@ -638,15 +638,69 @@ ES Check is a small utility using powerful tools that [Isaac Z. Schlueter](https
638638

639639
---
640640

641-
## Contributing
641+
## Source Maps
642642

643-
ES Check has 7 dependencies: [acorn and acorn-walk](https://github.com/ternjs/acorn/), [fast-glob](https://github.com/mrmlnc/fast-glob), [supports-color](https://github.com/chalk/supports-color), [winston](https://github.com/winstonjs/winston), [browserslist](https://github.com/browserslist/browserslist), and [commander](https://github.com/tj/commander). To contribute, file an [issue](https://github.com/yowainwright/es-check/issues) or submit a pull request.
643+
ES Check supports source maps for better error reporting. When a `.map` file exists alongside your JavaScript file, ES Check will automatically map error positions from transpiled code back to the original source:
644644

645-
To update es versions, check out these lines of code [here](https://github.com/yowainwright/es-check/blob/main/index.js#L92-L153) and [here (in acorn.js)](https://github.com/acornjs/acorn/blob/3221fa54f9dea30338228b97210c4f1fd332652d/acorn/src/acorn.d.ts#L586).
645+
```sh
646+
es-check es5 './dist/bundle.js'
647+
```
646648

647-
To update es feature detection, update these files [here](./utils.js) and [here](./constants.js) as enabled feature testing using [acorn walk](https://github.com/acornjs/acorn/blob/master/acorn-walk/README.md).
649+
If `bundle.js.map` exists, errors will reference the original source file and line numbers instead of the minified positions. This helps quickly identify issues in your source code.
650+
651+
## Contributing
648652

649-
[tests](./test.js) to go with new version and/or feature detection updates are great to have!
653+
ES Check has only 4 core dependencies: [acorn](https://github.com/ternjs/acorn/) for JavaScript parsing, [fast-brake](https://github.com/stackblitz/fast-brake) for lightweight feature detection, [fast-glob](https://github.com/mrmlnc/fast-glob) for file globbing, and [browserslist](https://github.com/browserslist/browserslist) for browser targeting.
654+
655+
The CLI, logging, and source map support are implemented with custom lightweight solutions using Node.js built-ins to minimize dependencies. To contribute, file an [issue](https://github.com/yowainwright/es-check/issues) or submit a pull request.
656+
657+
### Codebase Architecture
658+
659+
ES Check follows a modular architecture with clear separation of concerns:
660+
661+
```
662+
lib/
663+
├── cli/
664+
│ ├── index.js
665+
│ ├── handler.js
666+
│ ├── utils.js
667+
│ └── constants.js
668+
├── check-runner/
669+
│ ├── index.js
670+
│ └── utils.js
671+
├── constants/
672+
│ ├── versions.js
673+
│ └── index.js
674+
├── helpers/
675+
│ ├── detectFeatures/
676+
│ │ ├── index.js
677+
│ │ └── constants/
678+
│ │ ├── es-features/
679+
│ │ ├── polyfills.js
680+
│ │ └── index.js
681+
│ ├── ast.js
682+
│ ├── files.js
683+
│ ├── logger.js
684+
│ ├── parsers.js
685+
│ └── sourcemap.js
686+
├── browserslist.js
687+
├── cache.js
688+
├── config.js
689+
└── index.js
690+
```
691+
692+
### Contributing to ES Features
693+
694+
To update ES version support:
695+
- Update [ES version mappings](./lib/constants/versions.js)
696+
- Reference [Acorn ES version support](https://github.com/acornjs/acorn/blob/3221fa54f9dea30338228b97210c4f1fd332652d/acorn/src/acorn.d.ts#L586)
697+
698+
To update ES feature detection:
699+
- Add features to [version-specific files](./lib/helpers/detectFeatures/constants/es-features/) (e.g., `6.js` for ES6 features)
700+
- Update [polyfill patterns](./lib/helpers/detectFeatures/constants/polyfills.js) if needed
701+
- Feature detection uses [acorn walk](https://github.com/acornjs/acorn/blob/master/acorn-walk/README.md)
702+
703+
Tests are located in `tests/unit/` and mirror the `lib/` structure. Please add tests for new features!
650704

651705
### Contributors
652706

lib/browserslist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const browserslist = require("browserslist");
2-
const { BROWSER_TO_ES_VERSION } = require("./constants");
2+
const { BROWSER_TO_ES_VERSION } = require("./constants/versions");
33

44
/**
55
* Determines the ES version supported by a specific browser and version

0 commit comments

Comments
 (0)