Skip to content

Commit

Permalink
Install eslint for hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne authored and justinlittman committed Aug 5, 2019
1 parent 9e32843 commit a89a684
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
"jest",
"jsx-a11y",
"react",
"react-hooks",
"security"
],
extends: [
Expand Down Expand Up @@ -125,6 +126,8 @@ module.exports = {
"prefer-destructuring": "off",
"prefer-reflect": "off",
"quotes": ["error", "single"],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/jsx-indent": ["error", 2],
"react/jsx-indent-props": ["error", "first"],
"require-await": "off",
Expand Down
8 changes: 7 additions & 1 deletion package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-react": "^7.14.2",
"eslint-plugin-react-hooks": "^1.6.0",
"eslint-plugin-security": "^1.4.0",
"expect-puppeteer": "^4.1.1",
"file-loader": "^3.0.1",
Expand Down
8 changes: 4 additions & 4 deletions src/components/editor/property/InputLiteral.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import { booleanPropertyFromTemplate } from 'utilities/propertyTemplates'
import _ from 'lodash'

const InputLiteral = (props) => {
const inputLiteralRef = useRef(Math.floor(100 * Math.random()))
const [content, setContent] = useState('')
const [lang, setLang] = useState(defaultLanguageId)

// Don't render if don't have property templates yet.
if (!props.propertyTemplate) {
return null
}

const inputLiteralRef = useRef(Math.floor(100 * Math.random()))
const [content, setContent] = useState('')
const [lang, setLang] = useState(defaultLanguageId)

const disabled = !booleanPropertyFromTemplate(props.propertyTemplate, 'repeatable', true)
&& Object.keys(props.items).length > 0

Expand Down
5 changes: 3 additions & 2 deletions src/components/editor/property/InputLookupSinopia.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import _ from 'lodash'
const AsyncTypeahead = asyncContainer(Typeahead)

const InputLookupSinopia = (props) => {
const [isLoading, setLoading] = useState(false)
const [options, setOptions] = useState([])

// Don't render if no property template yet
if (!props.propertyTemplate) {
return null
}

const [isLoading, setLoading] = useState(false)
const [options, setOptions] = useState([])
const isMandatory = booleanPropertyFromTemplate(props.propertyTemplate, 'mandatory', false)
const isRepeatable = booleanPropertyFromTemplate(props.propertyTemplate, 'repeatable', true)

Expand Down
8 changes: 4 additions & 4 deletions src/components/editor/property/InputURI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import { booleanPropertyFromTemplate } from 'utilities/propertyTemplates'
import _ from 'lodash'

const InputURI = (props) => {
const inputLiteralRef = useRef(Math.floor(100 * Math.random()))
const [content, setContent] = useState('')
const [uriError, setURIError] = useState(false)

// Don't render if don't have property templates yet.
if (!props.propertyTemplate) {
return null
}

const inputLiteralRef = useRef(Math.floor(100 * Math.random()))
const [content, setContent] = useState('')
const [uriError, setURIError] = useState(false)

const disabled = !booleanPropertyFromTemplate(props.propertyTemplate, 'repeatable', true)
&& Object.keys(props.items).length > 0

Expand Down

0 comments on commit a89a684

Please sign in to comment.