Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

Commit

Permalink
Mithril 2.x, remove ESLint and Jest
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurClemens committed Aug 5, 2019
1 parent ef03ca1 commit a26aaae
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 115 deletions.
32 changes: 0 additions & 32 deletions .eslintrc

This file was deleted.

21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# mithril-starter-rollup

Project setup with:
* [Mithril](http://mithril.js.org)
* [Mithril 2.x](http://mithril.js.org)
* [Rollup](http://rollupjs.org) for optimized module bundles
* [Babel](http://babeljs.io) for transpiling es2015 to es5
* [LiveReload](https://github.com/livereload/livereload-js) to view code changes directly in the browser
* [Jest](https://facebook.github.io/jest/) to run BDD tests and create component snapshots
* [ESLint](http://eslint.org) to find syntax errors and get a standardized coding style

A couple of styles are included using [Tachyon](http://tachyons.io/), but these can simply be replaced with your own CSS solution.

Expand All @@ -29,23 +27,11 @@ Script commands defined in `package.json`:
* `serve`: serves the build directory at [localhost:5000](http://localhost:5000/)
* `dev`: starts a local webserver; creates a bundle in `dist/js/` that is being updated with each code change; calls LiveReload to refresh the browser after code changes are built

Call `npm run dev` and open a web page at [localhost:8080](http://localhost:8080/). The port number is set by environment variable `PORT` in `package.json`.
Call `npm run dev` and open a web page at [localhost:3000](http://localhost:3000/). The port number is set by environment variable `PORT` in `package.json`.

When making changes, the terminal will show lint errors, if any.



## Testing

See [mithril-jest](https://github.com/ArthurClemens/mithril-jest) for a short overview of Jest.

* `npm run test`: starts a test run (only useful to know if tests are passing)
* `npm run test:watch`: starts an interactive session with the option to evaluate and update existing snapshots

To run tests alongside the `watch` command, use a separate terminal window.



## Configuration files

`scripts` contains a couple of Rollup configuration files. The scripts use `rollup.base.js` as base configuration.
Expand All @@ -69,9 +55,8 @@ Optional environment variables:
* `PORT` (Number): sets the http server port when running the `dev` script


Other configuration files:
Other configuration file:
* `.babelrc`: Babel configuration
* `.eslintrc`: ESLint configuration


## License
Expand Down
2 changes: 1 addition & 1 deletion dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/bundle.js.map

Large diffs are not rendered by default.

41 changes: 15 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mithril-starter-rollup",
"version": "1.0.5",
"description": "Mithril Starter Project with Rollup, Babel, LiveReload and ESLint",
"version": "1.1.0",
"description": "Mithril Starter Project with Rollup, Babel and LiveReload",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -14,46 +14,35 @@
"serve": "http-server -p 5000 dist",
"rollup": "rollup -c ./scripts/rollup.umd.js --environment DEPS:1 && rollup -c ./scripts/rollup.es.js --environment DEPS:1",
"clean": "rimraf dist/js/*",
"dev": "rollup -c ./scripts/rollup.watch.js --environment DEPS:1,PORT:8080,WATCH_DIR:./dist/ --watch",
"test": "jest src/**",
"test:watch": "jest src/** --watch"
"dev": "rollup -c ./scripts/rollup.watch.js --environment DEPS:1,PORT:3000,WATCH_DIR:./dist/ --watch"
},
"files": [
"dist",
"README.md"
],
"jest": {
"verbose": true,
"testURL": "http://localhost/"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/plugin-external-helpers": "^7.2.0",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/register": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/register": "^7.5.5",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.8.0",
"es-module-loader": "^2.3.0",
"http-server": "^0.11.1",
"jest": "^24.8.0",
"mithril-jest": "^1.0.3",
"rimraf": "^2.6.3",
"rollup": "^1.14.4",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-eslint": "^6.0.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-node-resolve": "^5.0.1",
"rollup": "^1.18.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.0.2",
"rollup-plugin-livereload": "^1.0.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-pathmodify": "^1.0.1",
"rollup-plugin-serve": "^1.0.1",
"rollup-plugin-terser": "^5.0.0",
"rollup-plugin-terser": "^5.1.1",
"rollup-watch": "^4.3.1"
},
"dependencies": {
"mithril": "^1.1.6"
"mithril": "^2.0.3"
}
}
16 changes: 8 additions & 8 deletions scripts/rollup.base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from "fs";
import babel from "rollup-plugin-babel";
import { eslint } from "rollup-plugin-eslint";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import pathmodify from "rollup-plugin-pathmodify";
Expand All @@ -9,7 +8,7 @@ export const pkg = JSON.parse(fs.readFileSync("./package.json"));
if (!pkg) {
throw("Could not read package.json");
}
const env = process.env; // eslint-disable-line no-undef
const env = process.env;
const input = env.INPUT || "index.js";
const name = env.NAME || pkg.name;
const external = Object.keys(pkg.dependencies || {});
Expand Down Expand Up @@ -40,12 +39,17 @@ export const createConfig = ({ includeDepencies }) => ({
main: true,
}),

// Make sure that Mithril is included only once (if passed in INCLUDES env variable)
pathmodify({
aliases: [
{
id: "mithril/stream",
resolveTo: "node_modules/mithril/stream.js"
}
resolveTo: "node_modules/mithril/stream/stream.js"
},
{
id: "mithril",
resolveTo: "node_modules/mithril/mithril.js"
},
]
}),

Expand All @@ -54,10 +58,6 @@ export const createConfig = ({ includeDepencies }) => ({
include: "node_modules/**"
}),

eslint({
cache: true
}),

babel({
exclude: "node_modules/**"
})
Expand Down
2 changes: 1 addition & 1 deletion scripts/rollup.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ https://github.com/rollup/rollup/wiki/jsnext:main
import { pkg, createConfig } from "./rollup.base.js";

const includeDepencies = !!parseInt(process.env.DEPS, 10) || false; // Use `false` if you are creating a library, or if you are including external script in html
const env = process.env; // eslint-disable-line no-undef
const env = process.env;

const baseConfig = createConfig({ includeDepencies });
const targetConfig = Object.assign({}, baseConfig, {
Expand Down
2 changes: 1 addition & 1 deletion scripts/rollup.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Build to an Universal Module Definition
import { pkg, createConfig } from "./rollup.base.js";
import { terser } from "rollup-plugin-terser";

const env = process.env; // eslint-disable-line no-undef
const env = process.env;
const includeDepencies = !!parseInt(env.DEPS, 10) || false; // Use `false` if you are creating a library, or if you are including external script in html
const createSourceMap = env.SOURCEMAP !== undefined
? !!parseInt(env.SOURCEMAP, 10)
Expand Down
2 changes: 1 addition & 1 deletion scripts/rollup.watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import umdConfig from "./rollup.umd.js";
import livereload from "rollup-plugin-livereload";
import serve from "rollup-plugin-serve";

const env = process.env; // eslint-disable-line no-undef
const env = process.env;

const watchDir = env.WATCH_DIR;
if (!watchDir) {
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const Index = {
m(CSS.page, [
m(CSS.pageTitle, "Home"),
m(CSS.list, links.map(link => (
m(CSS.listItem, m(CSS.link, {
m(CSS.listItem, m(m.route.Link, {
selector: CSS.link,
href: link.path,
oncreate: m.route.link
}, link.name))
)))
])
};

m.route.prefix("#");
m.route.prefix = "#";
const mountNode = document.querySelector("#app");
const routes = {
"/": Index
Expand Down
21 changes: 0 additions & 21 deletions src/page/__tests__/page.spec.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const Page = {
view: ({ attrs }) =>
m(CSS.page, [
m(CSS.pageTitle, attrs.title || "Page"),
m(CSS.link, {
m(m.route.Link, {
href: "/",
oncreate: m.route.link
selector: CSS.link,
}, "Back")
])
};
Expand Down

0 comments on commit a26aaae

Please sign in to comment.