Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up linting #29

Merged
merged 5 commits into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 85 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,88 @@
"name": "takenote",
"version": "0.1.0",
"private": false,
"scripts": {
"build": "react-scripts build",
"coveralls": "react-scripts test --ci --coverage --watchAll=false && cat ./coverage/lcov.info | coveralls",
"eject": "react-scripts eject",
"postinstall": "patch-package",
"start": "react-scripts start",
"test": "react-scripts test"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}": [
"eslint --fix",
"git add"
],
"**/*.{json,css,scss,md}": [
"prettier --write",
"git add"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"prettier": {
"bracketSpacing": true,
"printWidth": 100,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
},
"eslintConfig": {
"extends": [
"react-app",
"plugin:import/errors",
"plugin:import/typescript",
"plugin:import/warnings",
"plugin:prettier/recommended",
"prettier/react"
],
"plugins": [
"import"
],
"rules": {
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"unknown"
],
"newlines-between": "always"
}
]
},
"settings": {
"import/resolver": {
"node": {
"paths": [
"src"
]
}
}
}
},
"dependencies": {
"@types/codemirror": "0.0.78",
"@types/jest": "24.0.18",
Expand Down Expand Up @@ -33,52 +115,13 @@
"typescript": "3.6.3",
"uuid": "^3.3.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"postinstall": "patch-package",
"coveralls": "react-scripts test --ci --coverage --watchAll=false && cat ./coverage/lcov.info | coveralls"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx,json,css,scss,md}": [
"prettier --single-quote --trailing-comma es5 --print-width 100 --tab-width 2 --no-semi --write",
"git add"
]
},
"prettier": {
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100,
"tabWidth": 2,
"semi": false,
"bracketSpacing": true
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@testing-library/jest-dom": "^4.1.2",
"@testing-library/react": "^9.3.0",
"coveralls": "^3.0.7",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.1.1",
"husky": "^3.0.9",
"jest": "^24.9.0",
"lint-staged": "^9.4.2",
Expand Down
2 changes: 1 addition & 1 deletion src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Actions } from 'constants/enums'
import { NoteItem, CategoryItem } from 'types'
import { CategoryItem, NoteItem } from 'types'

//==============================================================================
// Notes
Expand Down
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NoteItem, CategoryItem } from 'types'
import { CategoryItem, NoteItem } from 'types'

export const requestNotes = () => {
return new Promise((resolve, reject) => {
Expand Down
3 changes: 2 additions & 1 deletion src/containers/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useEffect } from 'react'
import { Dispatch } from 'redux'
import { connect } from 'react-redux'

import KeyboardShortcuts from 'containers/KeyboardShortcuts'
import AppSidebar from 'containers/AppSidebar'
import NoteList from 'containers/NoteList'
import NoteEditor from 'containers/NoteEditor'
import { loadNotes, loadCategories } from 'actions'
import { KeyboardProvider } from '../contexts/KeyboardContext'
import { KeyboardProvider } from 'contexts/KeyboardContext'

interface AppProps {
loadNotes: () => void
Expand Down
3 changes: 2 additions & 1 deletion src/containers/AppSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Dispatch } from 'redux'
import { connect } from 'react-redux'
import kebabCase from 'lodash/kebabCase'
import { Trash2, Book, Folder, X, UploadCloud, Plus, Settings, Bookmark } from 'react-feather'

import { Folders } from 'constants/enums'
import { CategoryItem, NoteItem, ApplicationState } from 'types'
import {
Expand All @@ -16,7 +17,7 @@ import {
syncState,
} from 'actions'
import { newNote } from 'helpers'
import { useKeyboard } from '../contexts/KeyboardContext'
import { useKeyboard } from 'contexts/KeyboardContext'

const iconColor = 'rgba(255, 255, 255, 0.3)'

Expand Down
3 changes: 2 additions & 1 deletion src/containers/KeyboardShortcuts.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react'
import { Dispatch } from 'redux'
import { connect } from 'react-redux'

import { addNote, swapNote, toggleTrashedNote, syncState } from 'actions'
import { NoteItem, CategoryItem, ApplicationState } from 'types'
import { newNote, getNoteTitle, downloadNote } from 'helpers'
import { useKey } from 'helpers/hooks'
import { useKeyboard } from '../contexts/KeyboardContext'
import { useKeyboard } from 'contexts/KeyboardContext'

interface KeyboardShortcutsProps {
addNote: (note: NoteItem) => void
Expand Down
7 changes: 4 additions & 3 deletions src/containers/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { Dispatch } from 'redux'
import { connect } from 'react-redux'
import { Controlled as CodeMirror } from 'react-codemirror2'
import moment from 'moment'

import { updateNote } from 'actions'
import { NoteItem, ApplicationState } from 'types'

import options from 'constants/codeMirrorOptions'

import 'codemirror/lib/codemirror.css'
import 'codemirror/theme/base16-light.css'
import 'codemirror/mode/gfm/gfm.js'
import 'codemirror/addon/selection/active-line.js'
import 'codemirror/mode/gfm/gfm'
import 'codemirror/addon/selection/active-line'

interface NoteEditorProps {
loading: boolean
Expand Down
1 change: 1 addition & 0 deletions src/containers/NoteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'
import { Dispatch } from 'redux'
import { connect } from 'react-redux'
import { MoreHorizontal } from 'react-feather'

import { folderMap } from 'constants/index'
import { Folders } from 'constants/enums'
import { swapNote, swapCategory, pruneNotes, addCategoryToNote } from 'actions'
Expand Down
4 changes: 3 additions & 1 deletion src/containers/NoteOptions.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react'
import NoteOptions, { NoteOptionsProps } from './NoteOptions'

import NoteOptions, { NoteOptionsProps } from 'containers/NoteOptions'

import { renderWithRouter } from '../../tests/helpers'

const wrap = (props: NoteOptionsProps) => renderWithRouter(<NoteOptions {...props} />)
Expand Down
9 changes: 5 additions & 4 deletions src/containers/NoteOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react'
import { Dispatch } from 'redux'
import { connect } from 'react-redux'
import { Dispatch } from 'redux'
import { ArrowUp, Bookmark, Download, Trash } from 'react-feather'
import { toggleTrashedNote, toggleFavoriteNote } from 'actions'
import { NoteItem, ApplicationState } from 'types'
import { getNoteTitle, downloadNote } from 'helpers'

import { toggleFavoriteNote, toggleTrashedNote } from 'actions'
import { downloadNote, getNoteTitle } from 'helpers'
import { ApplicationState, NoteItem } from 'types'

export interface NoteOptionsProps {
clickedNote: NoteItem
Expand Down
1 change: 1 addition & 0 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import uuid from 'uuid/v4'
import moment from 'moment'

import { NoteItem } from 'types'
import { Folders } from 'constants/enums'

Expand Down
8 changes: 4 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './styles/index.scss'
import 'styles/index.scss'

import React from 'react'
import { render } from 'react-dom'
Expand All @@ -7,9 +7,9 @@ import { BrowserRouter as Router } from 'react-router-dom'
import { applyMiddleware, compose, createStore } from 'redux'
import createSagaMiddleware from 'redux-saga'

import App from './containers/App'
import rootReducer from './reducers'
import rootSaga from './sagas'
import App from 'containers/App'
import rootReducer from 'reducers'
import rootSaga from 'sagas'

const sagaMiddleware = createSagaMiddleware()
const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/categoryReducer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Actions } from 'constants/enums'
import { CategoryState, CategoryActionTypes } from 'types'
import { CategoryActionTypes, CategoryState } from 'types'

const initialState: CategoryState = {
categories: [],
Expand Down
1 change: 1 addition & 0 deletions src/reducers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { combineReducers, Reducer } from 'redux'

import noteReducer from 'reducers/noteReducer'
import categoryReducer from 'reducers/categoryReducer'
import syncReducer from 'reducers/syncReducer'
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/noteReducer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Actions, Folders } from 'constants/enums'
import { NoteItem, NoteState, NotesActionTypes } from 'types'
import { NoteItem, NotesActionTypes, NoteState } from 'types'
import { sortByLastUpdated } from 'helpers'

const initialState: NoteState = {
Expand Down
14 changes: 8 additions & 6 deletions src/sagas/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { put, all, takeLatest } from 'redux-saga/effects'
// eslint-disable-next-line import/named
import { all, put, takeLatest } from 'redux-saga/effects'

import { Actions } from 'constants/enums'
import {
loadNotesSuccess,
loadNotesError,
loadCategoriesSuccess,
loadCategoriesError,
syncStateSuccess,
loadCategoriesSuccess,
loadNotesError,
loadNotesSuccess,
syncStateError,
syncStateSuccess,
} from 'actions'
import { SyncStateAction } from 'types'
import { requestNotes, requestCategories, saveState } from 'api'
import { requestCategories, requestNotes, saveState } from 'api'

function* fetchNotes() {
try {
Expand Down