Skip to content

Commit

Permalink
refactor: add eslint as the default linter
Browse files Browse the repository at this point in the history
  • Loading branch information
darthtrevino committed Jun 14, 2019
1 parent 5817757 commit 5465119
Show file tree
Hide file tree
Showing 34 changed files with 402 additions and 51 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
lib/
dist/
out/
public/
static/
40 changes: 40 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"settings": {
"react": {
"version": "16.8"
}
},
"env": {
"node": true,
"browser": true,
"mocha": true,
"es6": true,
"jest": true
},
"globals": {
"Promise": "readonly"
},
"rules": {
"@typescript-eslint/no-parameter-properties": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/array-type": 0,
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"react/prop-types": 0,
"no-inner-declarations": 0
}
}
12 changes: 6 additions & 6 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"eg2.tslint",
"jpoissonnier.vscode-styled-components"
]
}
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"jpoissonnier.vscode-styled-components"
]
}
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start:packages": "lerna run start --parallel --stream",
"test:packages": "lerna run test --stream",
"release:packages": "lerna run release --stream",
"lint": "lerna run lint --parallel --stream",
"lint": "eslint . --ext .js,.ts,.jsx,.tsx",
"unit_test": "jest --coverage",
"test": "run-s lint build unit_test test:packages",
"lerna:publish": "lerna --registry https://msrp-essex.pkgs.visualstudio.com/_packaging/essex-npm/npm/registry/ publish",
Expand All @@ -35,6 +35,12 @@
"prettier": "^1.18.2",
"rxjs": "^6.5.2",
"ts-jest": "^24.0.2",
"@typescript-eslint/eslint-plugin": "^1.10.2",
"@typescript-eslint/parser": "^1.10.2",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-react-hooks": "^1.6.0",
"tslint": "^5.17.0",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^4.0.0",
Expand All @@ -48,7 +54,7 @@
},
"lint-staged": {
"**/*.{ts,tsx}": [
"tslint --fix",
"eslint --fix",
"prettier --write",
"git add"
]
Expand Down
5 changes: 5 additions & 0 deletions packages/client/builder/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/no-empty-interface": 0
}
}
6 changes: 5 additions & 1 deletion packages/client/builder/src/AxisBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export class AxisBuilder {
private labelFormatValue?: string

// #endregion
constructor(private scaleName: string, private orientValue: AxisOrientation) {

public constructor(
private scaleName: string,
private orientValue: AxisOrientation,
) {
if (!this.scaleName) {
throw new Error('scale name must be defined')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/builder/src/ChartOptionsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@chart-parts/interfaces'

export class ChartOptionsManager {
constructor(private options: ChartOptions = {}) {}
public constructor(private options: ChartOptions = {}) {}

public get ariaTitle() {
return this.options.ariaTitle || 'data visualization using chart-parts'
Expand Down
4 changes: 2 additions & 2 deletions packages/client/builder/src/MarkBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT license. See LICENSE file in the project.
*/

// tslint:disable no-this-assignment unified-signatures
/* eslint-disable no-dupe-class-members */
import {
Mark,
Channels,
Expand Down Expand Up @@ -41,7 +41,7 @@ export class MarkBuilder {
private encodingsValue: MarkEncodings = {}
private metadataValue?: MarkEncoding<Metadata>

constructor(private type: MarkType) {}
public constructor(private type: MarkType) {}

public table(table: string): MarkBuilder {
this.tableValue = table
Expand Down
5 changes: 5 additions & 0 deletions packages/client/interfaces/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/no-empty-interface": 0
}
}
5 changes: 5 additions & 0 deletions packages/client/react/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/no-empty-interface": 0
}
}
2 changes: 1 addition & 1 deletion packages/client/react/src/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface ChartState {
export class Chart extends React.Component<ChartProps, ChartState> {
private pipeline: Orchestrator<React.ReactNode>

constructor(props: ChartProps) {
public constructor(props: ChartProps) {
super(props)
this.pipeline = new Orchestrator(props.renderer)
this.state = { rendered: null }
Expand Down
5 changes: 4 additions & 1 deletion packages/documentation/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{
}
"rules": {
"react/no-unescaped-entities": 0
}
}
1 change: 1 addition & 0 deletions packages/documentation/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async function createPages({ actions, graphql }) {
const result = await retrieveMarkdownPages()

if (result.errors) {
// eslint-disable-next-line no-console
console.error('graphql error', result.errors)
throw new Error('Error invoking graphql for pages')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class LinkTree extends React.Component<
LinkTreeProps,
LinkTreeState
> {
constructor(props: LinkTreeProps) {
public constructor(props: LinkTreeProps) {
super(props)
this.state = { expanded: !!props.expanded, hasBeenManuallyToggled: false }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class SingleMarkTester extends React.Component<
SingleMarkTesterProps,
SingleMarkTesterState
> {
constructor(props: SingleMarkTesterProps) {
public constructor(props: SingleMarkTesterProps) {
super(props)
this.state = { scenegraph: props.initialScenegraph }
}
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/mobile/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": 0
}
}
2 changes: 1 addition & 1 deletion packages/examples/mobile/clear-rn-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const rimraf = require('rimraf')
function clear(pattern) {
return new Promise((resolve, reject) => {
const target = path.join(os.tmpdir(), pattern)
rimraf(target, (err, done) => {
rimraf(target, err => {
console.log(`Cleared Cache at ${target}`)
err ? reject(err) : resolve
})
Expand Down
4 changes: 3 additions & 1 deletion packages/examples/mobile/src/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const pipeline = new Orchestrator(new Renderer())
const renderChart = chart =>
pipeline.renderScenegraph(chart.scenegraph, chart.dimensions)

export default () => (
const Chart = () => (
<FlatList
style={{ flex: 1 }}
data={testCharts}
Expand All @@ -22,3 +22,5 @@ export default () => (
)}
/>
)
Chart.displayName = 'Chart'
export default Chart
1 change: 1 addition & 0 deletions packages/examples/testdata/CAPTURE_UTIL.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* 4) Evaluate scene to console
* 5) Paste this function in
*/
/* eslint-disable */
JSON.stringify(scene, (key, value) => {
if (
key === 'mark' ||
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/web/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/explicit-function-return-type": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface BarChartState {
export class BarChart extends React.Component<{}, BarChartState> {
private chart: SceneNode

constructor(props: {}) {
public constructor(props: {}) {
super(props)
this.state = { hoverRowIndex: undefined }
const isHovered = (index: number) => this.state.hoverRowIndex === index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface BarChartState {
export class BarChartUtc extends React.Component<{}, BarChartState> {
private chart: SceneNode

constructor(props: {}) {
public constructor(props: {}) {
super(props)
this.state = { hoverRowIndex: undefined }
const isHovered = (index: number) => this.state.hoverRowIndex === index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const data = [
export class GroupedBarChart extends React.Component<{}> {
private chart: SceneNode

constructor(props: {}) {
public constructor(props: {}) {
super(props)

this.chart = scene(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface BarChartState {
* Adapted from https://vega.github.io/vega/examples/bar-chart/
*/
export class BarChart extends React.Component<{}, BarChartState> {
constructor(props: {}) {
public constructor(props: {}) {
super(props)
this.state = { hoverRowIndex: undefined }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable
/* eslint-disable @typescript-eslint/camelcase */
import * as React from 'react'
import { VerticalTextAlignment } from '@chart-parts/interfaces'
import {
Expand Down Expand Up @@ -112,7 +112,7 @@ const TEXT_GROUP_HEIGHT = 110
* Adapted from https://vega.github.io/vega/examples/bar-chart/
*/
export class LineChart extends React.Component<{}, BarChartState> {
constructor(props: {}) {
public constructor(props: {}) {
super(props)
this.state = { hoverRowIndex: undefined }
}
Expand Down
4 changes: 2 additions & 2 deletions packages/processing/orchestrator/src/Orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT license. See LICENSE file in the project.
*/

// tslint:disable no-console
/* eslint-disable no-console */
import {
ChartOptions,
SceneNode,
Expand All @@ -16,7 +16,7 @@ import { VirtualSvgConverter } from '@chart-parts/vsvg'
import { createScenegraph } from '@chart-parts/scene'

export class Orchestrator<T> {
constructor(
public constructor(
private renderer: VDomRenderer<T>,
private prerenderer: ScenegraphConverter<any> = new VirtualSvgConverter(),
) {}
Expand Down
2 changes: 1 addition & 1 deletion packages/processing/scene/src/scene/SceneFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
* information for a section of a scene, including dimensions, scales, data, and event handlers
*/
export class SceneFrame {
constructor(
public constructor(
public node: SceneNode,
public mark: Mark | undefined,
public data: DataFrame,
Expand Down
2 changes: 1 addition & 1 deletion packages/processing/scenegraph/src/MarkBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class MarkBuilder {
private nameValue?: string
private zIndexValue?: number

constructor(public markType: MarkType) {}
public constructor(public markType: MarkType) {}

public items(...values: any[]): MarkBuilder {
this.itemsValue.push(
Expand Down
4 changes: 2 additions & 2 deletions packages/util/scales/src/DomainScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export abstract class DomainScale<Domain> implements ScaleBuilder {
: (bindDomain as string[])
}

get tableBind(): string | undefined {
private get tableBind(): string | undefined {
const bind = this.bindDomainValue
if (!bind) {
return undefined
Expand All @@ -109,7 +109,7 @@ export abstract class DomainScale<Domain> implements ScaleBuilder {
return tableName
}

get fieldBind() {
private get fieldBind() {
const bind = this.bindDomainValue
if (!bind) {
return undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/util/shapes/src/Rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SGRectItem } from '@chart-parts/interfaces'
import { Xform } from './util'

export class Rectangle {
constructor(
public constructor(
public x: Xform<SGRectItem, number> = d => d.x || 0,
public y: Xform<SGRectItem, number> = d => d.y || 0,
public width: Xform<SGRectItem, number> = d => d.width || 0,
Expand Down
6 changes: 3 additions & 3 deletions packages/util/shapes/src/arc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Copyright (c) Microsoft. All rights reserved.
* Licensed under the MIT license. See LICENSE file in the project.
*/

export const segmentCache: { [key: string]: any } = {}
export const bezierCache: { [key: string]: any } = {}
/* eslint-disable @typescript-eslint/camelcase */
export const segmentCache: Record<string, any> = {}
export const bezierCache: Record<string, any> = {}

const join = [].join

Expand Down
Loading

0 comments on commit 5465119

Please sign in to comment.