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

1955 update lint config #1958

Merged
merged 12 commits into from
Nov 21, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions benefit-finder/.eslintignore

This file was deleted.

37 changes: 0 additions & 37 deletions benefit-finder/.eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions benefit-finder/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ yarn-error.log*
# generated files
.jest-test-results.json
storybook-static
.stylelintcache
.eslintcache

# cloned
themes
13 changes: 1 addition & 12 deletions benefit-finder/.stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
"scss/load-no-partial-leading-underscore": null,
"no-descending-specificity": null,
"no-duplicate-selectors": null,
"selector-class-pattern": null,
"font-family-no-missing-generic-family-keyword": [
true,
{
"ignoreFontFamilies": [
"PublicSans-ExtraBold",
"PublicSans-Bold",
"PublicSans-Regular",
"PublicSans-ExtraLight"
]
}
]
"selector-class-pattern": null
}
}
4 changes: 2 additions & 2 deletions benefit-finder/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console */
const { defineConfig } = require('cypress')

module.exports = defineConfig({
Expand All @@ -10,7 +10,7 @@ module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:6006',
excludeSpecPattern: 'cypress/e2e/usagov-public-site/*.cy.js',
setupNodeEvents(on, config) {
setupNodeEvents(on) {
on('task', {
log(message) {
console.log(message)
Expand Down
9 changes: 4 additions & 5 deletions benefit-finder/cypress/e2e/usagov-public-site/links.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const handlerequest = ({ testLink, link }) => {
})
}

const validateErrorCodes = test => {
const validateErrorCodes = () => {
// we verify site is alive and fail on 404 || 503
cy.get('#benefit-finder a[href]').each(link => {
handlerequest({ link })
Expand All @@ -50,16 +50,15 @@ const validateLinks = ({ selectedData, path }) => {
}

// to be removed when uncaught exceptions are addressed
// eslint-disable-next-line n/handle-callback-err
Cypress.on('uncaught:exception', (error, runnable) => {
Cypress.on('uncaught:exception', () => {
return false
})

describe('Verify correct status code handling', () => {
// negate validation on our functional code
Cypress.on('fail', (error, runnable) => {
Cypress.on('fail', error => {
if (JSON.stringify(error).includes('httpstat')) {
// eslint-disable-next-line no-unused-expressions
expect(error).to.not.be.undefined
} else {
throw error
Expand Down
132 changes: 132 additions & 0 deletions benefit-finder/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import js from '@eslint/js'
import globals from 'globals'
import json from 'eslint-plugin-json'
import pluginCypress from 'eslint-plugin-cypress/flat'
import storybook from 'eslint-plugin-storybook'
import reactPlugin from 'eslint-plugin-react'
import eslintConfigPrettier from 'eslint-config-prettier'
import jsxA11y from 'eslint-plugin-jsx-a11y'

// error when starting dev server:
// Error: Key "languageOptions": Key "globals": Global "AudioWorkletGlobalScope " has leading or trailing whitespace.
const GLOBALS_BROWSER_FIX = Object.assign({}, globals.browser, {
AudioWorkletGlobalScope: globals.browser['AudioWorkletGlobalScope '],
})

delete GLOBALS_BROWSER_FIX['AudioWorkletGlobalScope ']

export default [
js.configs.recommended,
json.configs.recommended,
eslintConfigPrettier,
...storybook.configs['flat/recommended'],
pluginCypress.configs.recommended,
reactPlugin.configs.flat.all,
jsxA11y.flatConfigs.recommended,
{
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
...globals.node,
...GLOBALS_BROWSER_FIX,
},
},
},
{
files: ['**/*.spec.js', '**/*.spec.jsx'],
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
...globals.node,
...globals.jest,
},
},
},
{
files: ['**/*.jsx'],
...reactPlugin.configs.flat.recommended,
settings: {
react: {
version: 'detect',
},
},
languageOptions: {
...reactPlugin.configs.flat.recommended.languageOptions,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
...globals.node,
...GLOBALS_BROWSER_FIX,
},
},
rules: {
'react/jsx-indent': 'off',
'react/jsx-indent-props': 'off',
'react/jsx-newline': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/jsx-max-props-per-line': 'off',
'react/jsx-no-bind': 'off',
'react/prop-types': 'off',
'react/function-component-definition': 'off',
'react/react-in-jsx-scope': 'off',
'react/jsx-sort-props': 'off',
'react/button-has-type': 'off',
'react/jsx-no-literals': 'off',
'react/jsx-boolean-value': 'off',
'react/jsx-closing-tag-location': 'off',
'react/self-closing-comp': 'off',
'react/forbid-component-props': 'off',
'react/require-default-props': 'off',
'react/sort-prop-types': 'off',
'react/jsx-props-no-spreading': 'off',
'react/no-multi-comp': 'off',
'react/no-unstable-nested-components': 'off',
'react/no-unused-prop-types': 'off',
'react/forbid-prop-types': 'off',
'react/jsx-max-depth': 'off',
'react/jsx-no-leaked-render': 'off',
'react/no-array-index-key': 'off',
'react/jsx-no-useless-fragment': 'off',
'react/no-danger': 'off',
'react/hook-use-state': 'off',
'react/jsx-curly-newline': 'off',
'react/jsx-curly-brace-presence': 'off',
},
},
{
files: ['**/*.jsx'],
...jsxA11y.flatConfigs.recommended,
languageOptions: {
...jsxA11y.flatConfigs.recommended.languageOptions,
globals: {
...GLOBALS_BROWSER_FIX,
},
},
rules: {
'jsx-a11y/no-noninteractive-tabindex': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/mouse-events-have-key-events': 'off',
},
},
{
ignores: [
'dist',
'build',
'node_modules',
'themes',
'coverage',
'storybook-static',
'package-lock.json',
'!.storybook',
],
},
]
Loading
Loading