UNPKG

3.5 kBMarkdownView Raw
1# esnext-scripts
2
3Opinionated ESNext application scripts and configurations.
4
5[![CircleCI](https://circleci.com/gh/jimzhan/esnext-scripts.svg?style=svg)](https://circleci.com/gh/jimzhan/esnext-scripts)
6[![npm version](https://badge.fury.io/js/esnext-scripts.svg)](https://www.npmjs.com/package/esnext-scripts)
7[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
8[![Styled with Prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
9[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
10[![npm downloads](https://img.shields.io/npm/dt/esnext-scripts.svg)](https://www.npmjs.com/package/esnext-scripts)
11
12
13## Install
14
15```shell
16npm install esnext-scripts
17```
18
19or `yarn`
20
21```shell
22yarn add esnext-scripts
23```
24
25## What?
26
27`esnext-scripts` is set of pre-configured helpers for your next generation Javascript application. With it, you can now fully focus on your valuable implementations instead of playing around with various settings & helpers over and over again. Batteries included:
28
29- Latest EMACScript supports backed by:
30 * [babel-preset-env](https://babeljs.io/docs/en/babel-preset-env/)
31 * [babel-preset-stage-1](https://babeljs.io/docs/en/babel-preset-stage-1)
32 * [babel-preset-react](https://babeljs.io/docs/en/babel-preset-react)
33- A mostly reasonable approach to JavaScript by:
34 * [ESLint](https://eslint.org/)
35 * [StandardJS Style Guide](https://standardjs.com)
36 * [Prettier](https://prettier.io/)
37- Delightful JavaScript Testing with
38 * [Jest](https://github.com/facebook/jest)
39 * [Enzyme](https://github.com/airbnb/enzyme)
40
41
42## Why?
43
44> How much time you had spent on configuring your application boilerplate to make it support the "future" JavaScript spec. each time you start a new project?
45
46> How many times you had been confused by the obsolete `babel` settings (plugins, presets) or even worse, your applications got broken?
47
48
49## How?
50
51### Available commands
52
53
54- `esnext build <src> <out>` - compile an input directory of modules into an output directory.
55- `esnext exec <script> [--watch]` - execute a Node.js script with ESNext supports **NOTE** for development ONLY.
56- `esnext format <glob>` - format files find by the given `glob` pattern via `prettier`.
57- `esnext lint [optional-folder]` - start linting with `standardjs` rules set.
58- `esnext test` - start executing your `Jest` test specs.
59
60
61### Available config
62
63
64- `eslint`
65
66
67### Sample Usage
68
691. `.eslintrc.js`
70
71```
72const config = require('esnext-scripts')
73
74module.exports = config.eslint
75```
76
77
782. A sample structure of React application folder.
79
80```
81- src/
82 App.jsx
83 App.test.jsx
84```
85
86`App.test.jsx`.
87
88```javascript
89import React from 'react'
90import { shallow } from 'enzyme'
91import App from './App'
92
93describe('<App />', () => {
94 it('renders <App /> component', () => {
95 const wrapper = shallow(<App>Application</App>)
96 expect(wrapper).toBeTruthy()
97 })
98}
99```
100
101`package.json`.
102
103```json
104 "lint-staged": {
105 "**/*.{js,jsx}": [
106 "esnext format 'src/**/*.js",
107 "esnext lint --fix"
108 ]
109 },
110 "husky": {
111 "hooks": {
112 "pre-commit": "lint-staged",
113 "commit-msg": "commitlint --env HUSKY_GIT_PARAMS"
114 }
115 },
116 "scripts": {
117 "lint": "esnext lint",
118 "lint:other-folder": "esnext lint other-folder",
119 "test": "esnext test"
120 },
121```
122
123
124### License
125
126> MIT License 2019 © Jim Zhan