Skip to content

Commit

Permalink
eslint: extend from react-scripts config.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Nov 22, 2020
1 parent 338e833 commit 2100fab
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 29 deletions.
36 changes: 22 additions & 14 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"jest": true
},
"extends": [
// extend from react-scripts config
"react-app",
"plugin:react/recommended",
"standard",
"plugin:import/typescript"
Expand Down Expand Up @@ -165,19 +167,6 @@
"fp/no-this": 2,
"fp/no-valueof-field": 2,

// react
"react/jsx-curly-spacing": 2,
"react/jsx-equals-spacing": 2,
"react/jsx-tag-spacing": [
2,
{
"beforeSelfClosing": "allow"
}
],
"react/no-children-prop": 0,
"react/no-unescaped-entities": 0,
"react/prop-types": 0,

// jsdoc
"jsdoc/check-alignment": 2,
"jsdoc/check-indentation": 2,
Expand Down Expand Up @@ -208,6 +197,25 @@
"ClassExpression": true
}
}
]
],

// jrx-a11y
"jsx-a11y/anchor-is-valid": 0,

// react
"react/jsx-curly-spacing": 2,
"react/jsx-equals-spacing": 2,
"react/jsx-tag-spacing": [
2,
{
"beforeSelfClosing": "allow"
}
],
"react/no-children-prop": 0,
"react/no-unescaped-entities": 0,
"react/prop-types": 0,

// react-hooks
"react-hooks/exhaustive-deps": 0
}
}
3 changes: 2 additions & 1 deletion src/components/ContentEditable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ interface ContentEditableProps extends React.HTMLProps<HTMLDivElement>{
* Content Editable Component.
*/
const ContentEditable = ({ style, html, disabled, innerRef, forceUpdate, ...props }: ContentEditableProps) => {
const contentRef = innerRef || useRef<HTMLDivElement>(null)
const newContentRef = useRef<HTMLDivElement>(null)
const contentRef = innerRef || newContentRef
const prevHtmlRef = useRef<string>(html)
const allowInnerHTMLChange = useRef<boolean>(true)

Expand Down
8 changes: 4 additions & 4 deletions src/components/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const editableOfNote = (noteEl: HTMLElement) =>
const Note = ({ context, onFocus }: NoteProps) => {

const state = store.getState()
const hasNote = hasChild(state, context, '=note')

if (!hasNote || isContextViewActive(state, context)) return null

const dispatch = useDispatch()
const noteRef: { current: HTMLElement | null } = useRef(null)
const [justPasted, setJustPasted] = useState(false)

const hasNote = hasChild(state, context, '=note')
if (!hasNote || isContextViewActive(state, context)) return null

const note = attribute(state, context, '=note')

/** Handles note keyboard shortcuts. */
Expand Down
1 change: 1 addition & 0 deletions src/data-providers/data-helpers/getDescendantThoughts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async function* getDescendantThoughts(provider: DataProvider, context: Context,

const contextIds = contexts.map(cx => hashContext(cx))
const providerParents = (await provider.getContextsByIds(contextIds))
// eslint-disable-next-line no-loop-func
.map((parent, i) => parent || {
id: hashContext(contexts[i]),
context: contexts[i],
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/__tests__/archiveThought.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ it('empty thought should be archived if it has descendants', () => {

expect(exported).toBe(`- ${ROOT_TOKEN}
- =archive
-${' '}
- ${''/* prevent trim_trailing_whitespace */}
- b
- a`)

Expand Down
2 changes: 1 addition & 1 deletion src/reducers/__tests__/deleteEmptyThought.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ it('do not delete thought with children', () => {
const exported = exportContext(stateNew, [ROOT_TOKEN], 'text/plain')

expect(exported).toBe(`- ${ROOT_TOKEN}
-${' '}
- ${''/* prevent trim_trailing_whitespace */}
- 1`)

})
Expand Down
4 changes: 2 additions & 2 deletions src/reducers/__tests__/subCategorizeAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ it('subcategorize multiple thoughts', () => {

expect(exported).toBe(`- ${ROOT_TOKEN}
- a
-${' '}
- ${''/* prevent trim_trailing_whitespace */}
- b
- c`)

Expand All @@ -44,7 +44,7 @@ it('subcategorize multiple thoughts in the root', () => {
const exported = exportContext(stateNew, [ROOT_TOKEN], 'text/plain')

expect(exported).toBe(`- ${ROOT_TOKEN}
-${' '}
- ${''/* prevent trim_trailing_whitespace */}
- a
- b`)

Expand Down
4 changes: 2 additions & 2 deletions src/reducers/__tests__/subCategorizeOne.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ it('subcategorize a thought', () => {

expect(exported).toBe(`- ${ROOT_TOKEN}
- a
-${' '}
- ${''/* prevent trim_trailing_whitespace */}
- b`)

})
Expand All @@ -39,7 +39,7 @@ it('subcategorize a thought in the root', () => {
const exported = exportContext(stateNew, [ROOT_TOKEN], 'text/plain')

expect(exported).toBe(`- ${ROOT_TOKEN}
-${' '}
- ${''/* prevent trim_trailing_whitespace */}
- a`)

})
Expand Down
2 changes: 1 addition & 1 deletion src/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const formatKeyboardShortcut = (keyboardOrString: Key | string) => {
const keyboard = typeof keyboardOrString === 'string'
? { key: keyboardOrString as string }
: keyboardOrString
return (keyboard?.alt ? 'Alt' + ' + ' : '') +
return (keyboard?.alt ? 'Alt + ' : '') +
(keyboard.meta ? (isMac ? 'Command' : 'Ctrl') + ' + ' : '') +
(keyboard.control ? 'Control + ' : '') +
(keyboard.option ? 'Option + ' : '') +
Expand Down
2 changes: 1 addition & 1 deletion src/shortcuts/__tests__/newThoughtOrOutdent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ it('empty thought should outdent when hit enter', async () => {
- d
- e
- f
-${' '}`
- `

expect(exported).toEqual(expectedOutput)
})
4 changes: 2 additions & 2 deletions src/util/__tests__/importHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ it('empty thought with nested li\'s', () => {
</li>
`))
.toBe(`
- ` + `
- ${''/* prevent trim_trailing_whitespace */}
- x
- y
`)
Expand Down Expand Up @@ -280,7 +280,7 @@ it('blank thoughts with subthoughts', () => {
- 7/27
- 7/21
- 7/17
- ` /* prevent trim_trailing_whitespace */ + `
- ${''/* prevent trim_trailing_whitespace */}
- Integral Living Room
- Maitri 5
- DevCon
Expand Down

0 comments on commit 2100fab

Please sign in to comment.