Skip to content

Commit

Permalink
EDSC-3840: Updates eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
macrouch committed Jul 12, 2023
1 parent 2383780 commit aa69ba9
Show file tree
Hide file tree
Showing 39 changed files with 5,255 additions and 3,995 deletions.
83 changes: 1 addition & 82 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,6 @@
"jest": true,
"cypress/globals": true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"requireConfigFile": false
}
},
"plugins": [
"react",
"cypress"
],
"ignorePatterns": ["dist"],
"rules": {
// Setting a max line-length
"max-len": [1, 100, 2, {
"ignoreComments": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}],

// Disallow all semicolons on line endings
"semi": ["error", "never"],

// Allow both .js and .jsx extensions
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],

// Allow shadow declarations
"no-shadow": "off",

// Disallow dangling commas
"comma-dangle": ["error", "never"],

// Require spacing in object literals
"object-curly-spacing": ["error", "always"],

// Allow class methods that dont use 'this'
"class-methods-use-this": "off",

// Allow console log messages
"no-console": "off",

// Allow extranious dependencies
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],

// Allow named default exports
"import/no-named-as-default": "off",

// Allow files with no default export
"import/prefer-default-export": "off",

// Disable the depricated label-has-for rule
"jsx-a11y/label-has-for": "off",

// Use the correct version of this rule, rather than label-has-for
"jsx-a11y/label-has-associated-control": [
2,
{
"labelComponents": [
"label"
],
"labelAttributes": [
"htmlFor"
],
"controlComponents": [
"input"
]
}
],

// Allowing cyclic dependancies
"import/no-cycle": "off",

"react/jsx-props-no-spreading": ["error", {
"custom": "ignore"
}],

"react/function-component-definition": "off"
},

"overrides": [
{
Expand All @@ -96,11 +18,8 @@
}
],

// Use AirBnb settings as a base
"extends": [
"airbnb",
"plugin:react/recommended",
"plugin:cypress/recommended"
"@edsc"
],

// Define version settings
Expand Down
1 change: 1 addition & 0 deletions cypress/component/Checkbox.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe('Checkbox component', () => {

cy.get('input')
.should('have.attr', 'disabled')

cy.get('.help-text')
.should('have.text', 'Click Back to Search and upload a KML or Shapefile to enable this option.')
})
Expand Down
20 changes: 17 additions & 3 deletions cypress/component/Constraint.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,31 @@ function readXml(file) {

const resolver = buildXPathResolverFn(doc)

return { input, model, resolver }
return {
input,
model,
resolver
}
}

const nonConstraintElements = () => {
const { input, model, resolver } = readXml(textfieldXml)
return { elements: input.children, model, resolver }

return {
elements: input.children,
model,
resolver
}
}

const constraintElements = (file) => {
const { input, model, resolver } = readXml(file)
return { elements: input.children, model, resolver }

return {
elements: input.children,
model,
resolver
}
}

const setup = (overrideProps, model, resolver) => {
Expand Down
17 changes: 11 additions & 6 deletions cypress/component/EDSCEchoForm.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const WrapperComponent = (initialProps) => {
defaultRawModel: null
})
}

const handleChangePrepopulatedValues = () => {
setProps({
...props,
Expand All @@ -33,19 +34,23 @@ const WrapperComponent = (initialProps) => {
type="button"
title="Reset Form"
id="resetform"
onClick={() => {
handleResetForm()
}}
onClick={
() => {
handleResetForm()
}
}
>
Reset Form
</button>
<button
type="button"
title="Change Pre-populated Values"
id="changeprepopulatedvalues"
onClick={() => {
handleChangePrepopulatedValues()
}}
onClick={
() => {
handleChangePrepopulatedValues()
}
}
>
Change Pre-populated Values
</button>
Expand Down
5 changes: 4 additions & 1 deletion cypress/component/ElementWrapper.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ function readXml(file) {
const modelResult = document.evaluate('//*[local-name()="instance"]', doc)
const model = modelResult.iterateNext()

return { input, model }
return {
input,
model
}
}

const setup = (overrideProps) => {
Expand Down
1 change: 1 addition & 0 deletions cypress/component/Group.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('Group component', () => {
cy.get('label')
.should('have.text', 'Text input')
.and('have.attr', 'for', 'textinput')

cy.get('.group__body').find('.help-text').should('have.text', 'Helpful text')
})
})
6 changes: 4 additions & 2 deletions cypress/component/InputField.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ describe('InputField component', () => {
parentRef: 'parentRef'
})

cy.get('input').focus().blur()
cy.get('input').focus()
cy.get('input').blur()

cy.get('@onUpdateModelSpy')
.should('have.been.calledOnce')
Expand All @@ -97,7 +98,8 @@ describe('InputField component', () => {
it('onChange sets the state', () => {
setup()

cy.get('input').clear().type('New Value')
cy.get('input').clear()
cy.get('input').type('New Value')

cy.get('input').should('have.value', 'New Value')
})
Expand Down
1 change: 1 addition & 0 deletions cypress/component/Number.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ describe('Number component', () => {
cy.get('label')
.should('have.text', 'Test Field')
.and('have.attr', 'for', 'testfield')

cy.get('.help-text').should('have.text', 'Helpful text')
})
})
2 changes: 2 additions & 0 deletions cypress/component/Output.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe('Output component', () => {
cy.get('label')
.should('have.text', 'Test Field')
.and('have.attr', 'for', 'testfield')

cy.get('.help-text').should('have.text', 'Helpful text')
})

Expand All @@ -76,6 +77,7 @@ describe('Output component', () => {
cy.get('label')
.should('have.text', 'Test Field')
.and('have.attr', 'for', 'testfield')

cy.get('.help-text').should('have.text', 'Helpful text')
})

Expand Down
1 change: 1 addition & 0 deletions cypress/component/Range.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('Range component', () => {
cy.get('label')
.should('have.text', 'Test Field')
.and('have.attr', 'for', 'testfield')

cy.get('.help-text').should('have.text', 'Helpful text')

cy.get('.range__min').should('have.text', '0')
Expand Down
1 change: 1 addition & 0 deletions cypress/component/Secret.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('SecretField component', () => {
cy.get('label')
.should('have.text', 'Test Field')
.and('have.attr', 'for', 'testfield')

cy.get('.help-text').should('have.text', 'Helpful text')
})
})
6 changes: 6 additions & 0 deletions cypress/component/Select.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('Select component', () => {
cy.get('#testfield').children('option').first()
.should('have.value', 'test value 1')
.and('have.text', 'test label 1')

cy.get('#testfield').children('option').last()
.should('have.value', 'test value 2')
.and('have.text', 'test label 2')
Expand All @@ -94,9 +95,11 @@ describe('Select component', () => {
cy.get('#testfield').children('option').first()
.should('have.value', '-- No selection --')
.and('have.text', ' -- No selection -- ')

cy.get('#testfield').children('option').eq(1)
.should('have.value', 'test value 1')
.and('have.text', 'test label 1')

cy.get('#testfield').children('option').last()
.should('have.value', 'test value 2')
.and('have.text', 'test label 2')
Expand All @@ -122,9 +125,11 @@ describe('Select component', () => {
cy.get('#testfield').children('option').first()
.should('have.value', '-- Select a value --')
.and('have.text', ' -- Select a value -- ')

cy.get('#testfield').children('option').eq(1)
.should('have.value', 'test value 1')
.and('have.text', 'test label 1')

cy.get('#testfield').children('option').last()
.should('have.value', 'test value 2')
.and('have.text', 'test label 2')
Expand Down Expand Up @@ -152,6 +157,7 @@ describe('Select component', () => {
cy.get('#testfield').children('option').first()
.should('have.value', 'test value 1')
.and('have.text', 'test label 1')

cy.get('#testfield').children('option').last()
.should('have.value', 'test value 2')
.and('have.text', 'test label 2')
Expand Down
7 changes: 5 additions & 2 deletions cypress/component/TextArea.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ describe('TextArea component', () => {
cy.get('label')
.should('have.text', 'Test Field')
.and('have.attr', 'for', 'testfield')

cy.get('.help-text').should('have.text', 'Helpful text')
})

it('onBlur calls onUpdateModel', () => {
setup(textareaXml)

cy.get('#testfield').focus().blur()
cy.get('#testfield').focus()
cy.get('#testfield').blur()

cy.get('@onUpdateModelSpy')
.should('have.been.calledOnce')
Expand All @@ -84,7 +86,8 @@ describe('TextArea component', () => {
it('onChange sets the state', () => {
setup(textareaXml)

cy.get('#testfield').clear().type('New Value')
cy.get('#testfield').clear()
cy.get('#testfield').type('New Value')

cy.get('#testfield').should('have.value', 'New Value')
})
Expand Down
5 changes: 4 additions & 1 deletion cypress/component/TextField.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ describe('TextField component', () => {
cy.get('label')
.should('have.text', 'Test Field')
.and('have.attr', 'for', 'testfield')

cy.get('.help-text').should('have.text', 'Helpful text')
})

it('renders constraint errors', () => {
setup(textFieldWithPatternConstraintXml, { value: '' })

cy.get('#testfield').clear().type('invalid').blur()
cy.get('#testfield').clear()
cy.get('#testfield').type('invalid')
cy.get('#testfield').blur()

cy.get('.invalid-feedback').should('have.text', 'Value must be "test value"')
})
Expand Down
11 changes: 9 additions & 2 deletions cypress/component/Tree.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/* eslint-disable react/react-in-jsx-scope, react/jsx-no-constructed-context-values */
import murmurhash from 'murmurhash'

import { treeWithMaxParametersXml, treeWithNestedDisabledFieldsXml, treeXml } from '../mocks/FormElement'
import {
treeWithMaxParametersXml,
treeWithNestedDisabledFieldsXml,
treeXml
} from '../mocks/FormElement'
import { Tree } from '../../src/components/Tree/Tree'
import { EchoFormsContext } from '../../src/context/EchoFormsContext'
import { parseXml } from '../../src/util/parseXml'
Expand Down Expand Up @@ -96,7 +100,10 @@ describe('Tree component', () => {
'have.been.calledOnceWith',
'parentRef',
'testfield',
{ value: ['/Parent1', '/Parent1/Child1'], valueElementName: 'data_layer' }
{
value: ['/Parent1', '/Parent1/Child1'],
valueElementName: 'data_layer'
}
)
})

Expand Down
Loading

0 comments on commit aa69ba9

Please sign in to comment.