Skip to content

Commit

Permalink
feat(lint): add tslint with react lint checks (#13)
Browse files Browse the repository at this point in the history
Closes #7
  • Loading branch information
Hotell authored Aug 3, 2016
1 parent 3317ed8 commit daad65f
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 10 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"description": "An React Scaffold featuring React (Tests, Dev/Prod), Visual Basic 6.0, Ava, NYC, TypeScript, TsLint, and Webpack2 by @ngParty Team",
"main": "index.js",
"scripts": {
"pretest": "npm run lint",
"test": "tsc && ava --verbose",
"test:watch": "tsc -w & ava --verbose --watch",
"cover": "nyc npm test",
"cover:watch": "nodemon --quiet --watch src --ext ts,tsx --exec npm run cover",
"check-coverage": "nyc --check-coverage --statements 80 --branches 80 --functions 80 --lines 80 npm test",
"lint": "tslint \"src/**/*.tsx\" \"src/**/*.ts\"",
"start": "webpack-dev-server --env.dev --hot"
},
"repository": {
Expand Down Expand Up @@ -58,6 +60,8 @@
"nyc": "7.1.0",
"react-addons-test-utils": "15.3.0",
"sinon": "1.17.5",
"tslint": "3.14.0",
"tslint-react": "0.4.0",
"typescript": "2.0.0",
"webpack": "2.1.0-beta.20",
"webpack-config-utils": "2.0.0",
Expand Down
4 changes: 1 addition & 3 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import test, { TestContext } from 'ava';
import * as React from 'react';
import { shallow } from 'enzyme';
import * as React from 'react';

import { App } from './App';

test( 'has a Hello message', ( t: TestContext ) => {
const wrapper = shallow(<App/>);
t.is( wrapper.contains(<div>Hello from Sofia!</div>), true );
} );


3 changes: 1 addition & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Component } from 'react';

export class App extends Component<any, any> {
render() {
return <div>Hello from Sofia!</div>
return <div>Hello from Sofia!</div>;
}
}

9 changes: 4 additions & 5 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react'
import { render } from 'react-dom'
import * as React from 'react';
import { render } from 'react-dom';

import { App } from './App'

render(<App />, document.getElementById('app'))
import { App } from './App';

render(<App />, document.getElementById('app'));
123 changes: 123 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"extends": ["tslint:latest", "tslint-react"],
"rules": {

"jsx-no-lambda": true,
"jsx-alignment": true,
"jsx-no-string-ref": true,
"jsx-self-close": true,

"arrow-parens": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": true,
"forin": true,
"indent": [
true,
"spaces"
],
"label-position": true,
"label-undefined": true,
"max-line-length": [
true,
120
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-switch-case-fall-through": true,
"trailing-comma": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-unused-variable": false,
"no-unreachable": true,
"no-use-before-declare": false,
"no-var-keyword": true,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"radix": true,
"semicolon": true,
"triple-equals": [
true,
"allow-null-check"
],
"use-strict": true,
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
],
"variable-name": [
true,
"ban-keywords",
"allow-leading-underscore"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-type",
"check-typecast"
],
"quotemark": [
true,
"single",
"jsx-double"
],
"member-access": false,
"member-ordering": [
true,
"variables-before-functions"
],
"one-variable-per-declaration": [
true
],
"no-namespace": [
true,
"allow-declarations"
],
"no-invalid-this": [
true,
"check-function-in-method"
]
}
}

0 comments on commit daad65f

Please sign in to comment.