Skip to content

Commit

Permalink
Refactor scripts (#2465)
Browse files Browse the repository at this point in the history
* Refactor all kinds of scripts

* Update docs to ensure linter passes
  • Loading branch information
dead-claudia committed Jul 27, 2019
1 parent 62172cb commit 48e7fd1
Show file tree
Hide file tree
Showing 23 changed files with 1,695 additions and 340 deletions.
7 changes: 6 additions & 1 deletion .editorconfig
Expand Up @@ -3,8 +3,13 @@ root = true
[*]
charset = utf-8

[*.js]
[*.{js,json,yml,html,md}]
indent_style = tab
tab_width = 4
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
10 changes: 5 additions & 5 deletions .eslintignore
@@ -1,7 +1,7 @@
.vscode/
coverage/
docs/lib/
examples/
/.vscode
/coverage
/docs/lib
/examples
/mithril.js
/mithril.min.js
node_modules/
/node_modules
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -6,5 +6,6 @@ npm-debug.log
.DS_Store
.eslintcache

# These are artifacts from Travis' deploy scripts
# These are artifacts from various scripts
/dist
/archive
25 changes: 10 additions & 15 deletions .travis.yml
Expand Up @@ -16,12 +16,6 @@ install:
# This is to prevent lint-staged/prettier from running on the bundles
- npm rm husky

# Build bundles (so they're always up to date)
before_script:
- npm run build-browser
# Pass -save so it'll update the readme as well
- npm run build-min -- -save

# Run tests, lint, and then check for perf regressions
script:
- npm test
Expand Down Expand Up @@ -90,12 +84,13 @@ deploy:
tags: true
repo: MithrilJS/mithril.js

- provider: npm
skip_cleanup: true
email: me@isiahmeadows.com
api_key:
secure: "uPLbeJTalA/b38srb1VuWnD3eOgeKTkXf8VVUasUXIqc2xub4DSkFm1IVKSVd/rzP7EeO7+gRUs2UteNKlpZJl226IS5mFPSVtC7ViW46WSpYT0wlMsc7hrubMBGTx3/XYpPwtmMlTIGs5ICT7YkGAuju/6i79LDAB+gbnEY8Bc="
on:
tags: true
repo: MithrilJS/mithril.js
condition: "$TRAVIS_TAG != *-*"
# Skip until I can figure out what's going on with docs + version deployment
# - provider: npm
# skip_cleanup: true
# email: me@isiahmeadows.com
# api_key:
# secure: "uPLbeJTalA/b38srb1VuWnD3eOgeKTkXf8VVUasUXIqc2xub4DSkFm1IVKSVd/rzP7EeO7+gRUs2UteNKlpZJl226IS5mFPSVtC7ViW46WSpYT0wlMsc7hrubMBGTx3/XYpPwtmMlTIGs5ICT7YkGAuju/6i79LDAB+gbnEY8Bc="
# on:
# tags: true
# repo: MithrilJS/mithril.js
# condition: "$TRAVIS_TAG != *-*"
4 changes: 2 additions & 2 deletions docs/components.md
Expand Up @@ -466,7 +466,7 @@ var Modal = {

If you do it like above, you could run into issues when using it:

```js
```javascript
var MyModal = {
view: function() {
return m(Modal, {
Expand All @@ -483,7 +483,7 @@ var MyModal = {

Instead, you should forward *single* attributes into vnodes:

```js
```javascript
// PREFER
var Modal = {
// ...
Expand Down
71 changes: 0 additions & 71 deletions docs/generate.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/hyperscript.md
Expand Up @@ -215,7 +215,7 @@ m("a-scene", [
])
```

And yes, this translates to both attributes and properties, and it works just like they would in the DOM. Using [Brick's `brick-deck`](https://brick.mozilla.io/docs/brick-deck) as an example, they have a `selected-index` attribute with a corresponding `selectedIndex` getter/setter property.
And yes, this translates to both attributes and properties, and it works just like they would in the DOM. Using [Brick's `brick-deck`](http://brick.mozilla.io/docs/brick-deck) as an example, they have a `selected-index` attribute with a corresponding `selectedIndex` getter/setter property.

```javascript
m("brick-deck[selected-index=0]", [/* ... */]) // lowercase
Expand Down
10 changes: 5 additions & 5 deletions docs/installation.md
Expand Up @@ -51,7 +51,7 @@ $ npm install webpack webpack-cli --save-dev
```

3. Add a "start" entry to the scripts section in `package.json`.
```js
```javascript
{
// ...
"scripts": {
Expand All @@ -61,7 +61,7 @@ $ npm install webpack webpack-cli --save-dev
```

4. Create `src/index.js` file.
```js
```javascript
import m from "mithril";
m.render(document.body, "hello world");
```
Expand Down Expand Up @@ -113,7 +113,7 @@ m.render(document.body, "hello world")

Modularization is the practice of separating the code into files. Doing so makes it easier to find code, understand what code relies on what code, and test.

CommonJS is a de-facto standard for modularizing JavaScript code, and it's used by Node.js, as well as tools like [Browserify](https://browserify.org/) and [Webpack](https://webpack.js.org/). It's a robust, battle-tested precursor to ES6 modules. Although the syntax for ES6 modules is specified in Ecmascript 6, the actual module loading mechanism is not. If you wish to use ES6 modules despite the non-standardized status of module loading, you can use tools like [Rollup](https://rollupjs.org/) or [Babel](https://babeljs.io/).
CommonJS is a de-facto standard for modularizing JavaScript code, and it's used by Node.js, as well as tools like [Browserify](http://browserify.org/) and [Webpack](https://webpack.js.org/). It's a robust, battle-tested precursor to ES6 modules. Although the syntax for ES6 modules is specified in Ecmascript 6, the actual module loading mechanism is not. If you wish to use ES6 modules despite the non-standardized status of module loading, you can use tools like [Rollup](https://rollupjs.org/) or [Babel](https://babeljs.io/).

Most browser today do not natively support modularization systems (CommonJS or ES6), so modularized code must be bundled into a single JavaScript file before running in a client-side application.

Expand All @@ -125,7 +125,7 @@ npm install webpack webpack-cli --save-dev

Open the `package.json` that you created earlier, and add an entry to the `scripts` section:

```
```json
{
"name": "my-project",
"scripts": {
Expand Down Expand Up @@ -199,7 +199,7 @@ If you open bin/app.js, you'll notice that the Webpack bundle is not minified, s

You can use hooks in your production environment to run the production build script automatically. Here's an example for [Heroku](https://www.heroku.com/):

```
```json
{
"name": "my-project",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion docs/jsx.md
Expand Up @@ -193,7 +193,7 @@ JSX and hyperscript are two different syntaxes you can use for specifying vnodes

You can see the tradeoffs come into play in more complex trees. For instance, consider this hyperscript tree, adapted from a real-world project by [@isiahmeadows](https://github.com/isiahmeadows/) with some alterations for clarity and readability:

```js
```javascript
function SummaryView() {
let tag, posts

Expand Down

0 comments on commit 48e7fd1

Please sign in to comment.