Skip to content

Commit

Permalink
Update configuration, add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
nhunzaker committed Mar 9, 2017
1 parent 012da24 commit 5199ddb
Show file tree
Hide file tree
Showing 10 changed files with 677 additions and 57 deletions.
24 changes: 24 additions & 0 deletions .editor-config
@@ -0,0 +1,24 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
max_line_length = 80

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Indentation override for all JS under lib directory
[src/**.js]
indent_style = space
indent_size = 2

# Matches the exact files either package.json or .circle.yml
[{package.json,.circle.yml}]
indent_style = space
indent_size = 2
28 changes: 28 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,28 @@
{
"globals": {
"Promise": true,
"jest": true,
"expect": true
},
"env": {
"browser": true,
"node": true,
"mocha": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
}
},
"extends": ["eslint:recommended"],
"rules": {
"semi": [2, "never"],
"quotes": [2, "single"],
"no-console": 0,
"no-unused-vars" : [2, { "args": "none" }]
}
}
1 change: 1 addition & 0 deletions .nvmrc
@@ -0,0 +1 @@
lts/*
66 changes: 39 additions & 27 deletions CONTRIBUTING.md
Expand Up @@ -2,58 +2,70 @@

Thanks you for considering a contribution to React Ink!

## Before Starting

React Ink is built using tools written for
[nodejs](http://nodejs.org). We recommend installing Node with
[nvm](https://github.com/creationix/nvm). this also means that
dependencies are managed with an [`npm`](https://npmjs.org) `package.json`
file.
[nvm](https://github.com/creationix/nvm). Dependencies are managed
through `package.json`.

You can install dependencies with:
You use the same node version we are developing with by running

```bash
npm install
nvm use
```

## Running
> You may need to run `nvm install` if you haven't installed the node version on `.nvmrc`
## Getting Started

All commands should be run using yarn. If you haven't switched to [yarn](https://yarnpkg.com/en/) yet, now's a great time!

A production build can be built by running:
> If you are familiar with npm then using yarn should be a breeze. You can keep using npm if you'd prefer but you will miss out on the safety and security of yarn
You can install dependencies with:

```bash
npm run prepublish
yarn install
```

However most of the time developing with React Ink, you will want
to reference the example app:
## Running the example

Most of the time developing with React Ink, you will want to reference the
example app:

```bash
npm start
yarn start
```

This will host the demo at `http://localhost:8080`.

## Testing
## Deployment

React Ink uses [Karma](https://karma-runner.github.io). You can run tests
with:
The following steps are required to push a new release:

```bash
npm test
```

Be sure to check the `./coverage` folder to verify all code paths are
touched.
1. Update changelog
2. `yarn version <major,minor,patch>`
3. `git push --tags`
4. `npm release release`

## Conventions

**Consider master unsafe**, use [`npm`](https://www.npmjs.com/package/react-ink) for the latest stable version.
**Consider master unsafe**, use [`npm`](https://www.npmjs.com/package/microcosm) for the latest stable version.

### Javascript

React Ink uses ES6 Javascript (compiled using [Babel](babeljs.io)). As
for style, shoot for:
for style:

- No semicolons (enforced by `.eslintrc.json`)
- 2 spaces for indentation (no tabs) (enforced by `.editorconfig`)
- Prefer ' over ", use string interpolation (enforced by `.eslintrc.json`)
- 80 character line length (enforced by `.editorconfig`)

> We recommend using an [editorconfig](http://editorconfig.org/) and [eslint](http://eslint.org/) plugin during development to ensure standards are met.
### Reviews

- No semicolons
- Commas last,
- 2 spaces for indentation (no tabs)
- Prefer ' over ", use string interpolation
- 80 character line length
All changes should be submitted through pull request. Ideally, at
least two :+1:s should be given before a pull request is merge.
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -5,6 +5,7 @@
"main": "dist/ink.js",
"scripts": {
"start": "webpack-dev-server --env=example",
"test": "eslint {src,examples}/**.js",
"build": "webpack -p",
"prepublish": "npm run build"
},
Expand All @@ -21,10 +22,13 @@
"devDependencies": {
"@types/react": "^0.14.56",
"babel-core": "~6",
"babel-eslint": "^7.1.1",
"babel-loader": "~6",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-2": "^6.22.0",
"eslint": "^3.17.1",
"eslint-loader": "^1.6.3",
"react": "^15.4.1",
"react-addons-test-utils": "^15.4.1",
"react-dom": "^15.4.1",
Expand Down
1 change: 1 addition & 0 deletions readme.md
@@ -1,5 +1,6 @@
# React Ink

[![CircleCI](https://img.shields.io/circleci/project/vigetlabs/react-ink.svg?maxAge=2592000)](https://circleci.com/gh/vigetlabs/react-ink)
[![npm](https://img.shields.io/npm/v/react-ink.svg?maxAge=2592000)](https://www.npmjs.com/package/react-ink)
[![npm](https://img.shields.io/npm/dm/react-ink.svg?maxAge=2592000)](https://www.npmjs.com/package/react-ink)

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Expand Up @@ -122,7 +122,7 @@ let Ink = React.createClass({
let { top, bottom, left, right } = el.getBoundingClientRect()
let { color } = window.getComputedStyle(el)

let ctx = this.state.ctx || el.getContext('2d');
let ctx = this.state.ctx || el.getContext('2d')
let density = pixelRatio(ctx)
let height = bottom - top
let width = right - left
Expand Down
8 changes: 4 additions & 4 deletions src/style.js
@@ -1,8 +1,8 @@
module.exports = {
borderRadius: "inherit",
height: "100%",
borderRadius: 'inherit',
height: '100%',
left: 0,
position: "absolute",
position: 'absolute',
top: 0,
width: "100%"
width: '100%'
}
26 changes: 17 additions & 9 deletions webpack.config.js
@@ -1,10 +1,10 @@
var base = require('./webpack.config')
var path = require('path')
const base = require('./webpack.config')
const path = require('path')

module.exports = function (env) {
let isExample = env === 'example'
const isExample = env === 'example'

var config = {
let config = {

entry: {
ink: isExample ? './example/index.js' : './src/index.js'
Expand All @@ -18,11 +18,19 @@ module.exports = function (env) {
},

module: {
rules: [{
test : /\.jsx*$/,
exclude : /node_modules/,
loader : 'babel-loader'
}]
rules: [
{
test : /\.jsx*$/,
exclude : /node_modules/,
loader : 'eslint-loader',
enforce : 'pre'
},
{
test : /\.jsx*$/,
exclude : /node_modules/,
loader : 'babel-loader'
}
]
},

devServer: {
Expand Down

0 comments on commit 5199ddb

Please sign in to comment.