Skip to content

Commit

Permalink
Initial upgrades and updates to config rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Chanel Henley committed Jan 14, 2025
1 parent 3281a15 commit 2f55fd0
Show file tree
Hide file tree
Showing 58 changed files with 1,651 additions and 742 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

80 changes: 0 additions & 80 deletions .eslintrc.cjs

This file was deleted.

85 changes: 85 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Run `npx @eslint/config-inspector` to inspect the config.

import globals from 'globals';
import js from '@eslint/js';
import importPlugin from 'eslint-plugin-import';
import jsdoc from 'eslint-plugin-jsdoc';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import reactPlugin from 'eslint-plugin-react';
import pluginCypress from 'eslint-plugin-cypress/flat';
import eslintConfigPrettier from 'eslint-config-prettier';
import babelParser from '@babel/eslint-parser';

export default [
{
ignores: ['\*_/**fixtures**/_.js', 'serviceWorker.js']
},
js.configs.recommended,
importPlugin.flatConfigs.recommended,
jsdoc.configs['flat/recommended'],
jsxA11y.flatConfigs.recommended,
reactPlugin.configs.flat.recommended,
pluginCypress.configs.recommended,
eslintConfigPrettier,

{
languageOptions: {
ecmaVersion: 2023,
parser: babelParser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
},
settings: {
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.js', '.jsx', '.ts', '.d.ts', '.tsx']
},
},
react: {
version: 'detect',
},
},
rules: {
'id-length': ['error', { min: 2 }],
'jsdoc/require-hyphen-before-param-description': ['warn', 'always'],
'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }],
'no-console': ['warn'],
'no-use-before-define': ['error','nofunc'],
'no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: false,
},
],
'no-var': ['error'],
'prefer-const': ['error'],
radix: ['error'],
'react/jsx-no-leaked-render': [
'error',
{ validStrategies: ['coerce', 'ternary'] },
],
'react/no-multi-comp': ['error', { ignoreStateless: true }],
'react/no-unstable-nested-components': ['error'],
'react/self-closing-comp': ['error'],
'react/boolean-prop-naming': ['error', { validateNested: true }],
'react/default-props-match-prop-types': [
'error',
{ allowRequiredDefaults: true },
],
'react/jsx-curly-brace-presence': ['error'],
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
},
},
];
22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"devDependencies": {
"@babel/cli": "^7.26.4",
"@babel/core": "^7.24.7",
"@babel/eslint-parser": "^7.24.7",
"@babel/eslint-parser": "^7.26.5",
"@babel/preset-react": "^7.26.3",
"@babel/runtime": "^7.26.0",
"@cfpb/browserslist-config": "0.0.3",
Expand All @@ -55,12 +55,15 @@
"cypress": "^13.17.0",
"d3": "^7.9.0",
"dayjs": "^1.11.10",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint": "^9.18.0",
"eslint-config-prettier": "^10.0.1",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-cypress": "^3.2.0",
"eslint-plugin-jsdoc": "^48.2.5",
"eslint-plugin-react-redux": "^4.1.0",
"eslint-plugin-cypress": "^4.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^50.6.1",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.4",
"globals": "^15.14.0",
"highcharts": "11.4.8",
"history": "^5.3.0",
"husky": "^9.1.7",
Expand Down Expand Up @@ -91,8 +94,8 @@
"release-it": "^17.3.0",
"sass": "^1.83.0",
"string-replace-loader": "^3.1.0",
"stylelint": "^16.12.0",
"stylelint-config-standard": "^36.0.0",
"stylelint": "^16.13.2",
"stylelint-config-standard": "^37.0.0",
"stylelint-config-standard-scss": "^14.0.0"
},
"lint-staged": {
Expand Down Expand Up @@ -142,5 +145,6 @@
"registry": "https://registry.npmjs.org/"
},
"proxy": "https://www.consumerfinance.gov",
"dependencies": {}
"dependencies": {},
"type": "module"
}
4 changes: 2 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import './css/App.scss';
import { ReactElement } from 'react';
import { Route, BrowserRouter as Router, Routes } from 'react-router-dom';
import { ComplaintDetail } from './components/ComplaintDetail/ComplaintDetail';
import { SearchComponents } from './components/Search/SearchComponents';

/**
* Main App Component
*
* @returns {JSX.Element} Main app
* @returns {ReactElement} Main application component
*/
const App = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/actions/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Analytics = {
if (Analytics.tagManagerIsLoaded) {
window.dataLayer.push(dataLayerOptions);
} else if (callback && typeof callback === 'function') {
callback(); // eslint-disable-line callback-return, no-inline-comments, max-len
callback();
}
},

Expand Down
1 change: 0 additions & 1 deletion src/actions/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export function normalizeRouteParams(params) {
* @returns {Function} a series of actions to execute
*/
export function changeRoute(path, params) {
// eslint-disable-next-line complexity
return function (dispatch, getState) {
const store = getState();
const normalized = normalizeRouteParams(params);
Expand Down
1 change: 0 additions & 1 deletion src/api/params/params.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable camelcase */
import { clamp, removeNullProperties } from '../../utils';
import { enforceValues } from '../../utils/reducers';
// ----------------------------------------------------------------------------
Expand Down
8 changes: 3 additions & 5 deletions src/components/Charts/RowChart/RowChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const RowChart = ({
const wrapText = (text, width, viewMore) => {
// ignore test coverage since this is code borrowed from d3 mbostock
// text wrapping functions
/* eslint-disable complexity */

/* istanbul ignore next */
text.each(function () {
const innerText = d3.select(this);
Expand All @@ -73,7 +73,6 @@ export const RowChart = ({
.attr('y', y)
.attr('dy', dy + 'em');

// eslint-disable-next-line no-cond-assign
while ((word = words.pop())) {
line.push(word);
tspan.text(line.join(' '));
Expand All @@ -85,7 +84,7 @@ export const RowChart = ({
.append('tspan')
.attr('x', spanWidth)
.attr('y', y)
// eslint-disable-next-line no-mixed-operators

.attr('dy', ++lineNumber * lineHeight + dy + 'em')
.text(word);
wrapCount++;
Expand All @@ -97,12 +96,11 @@ export const RowChart = ({
.select(innerText.node().parentNode)
.select('.view-more-background');
const oldHeight = viewMoreBackground.attr('height');
// eslint-disable-next-line no-mixed-operators

const newHeight = parseFloat(oldHeight) + wrapCount * 12;
viewMoreBackground.attr('height', newHeight);
}
});
/* eslint-enable complexity */
};

const collapseARow = (rowName) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialogs/DataExport/dataExportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function buildSomeResultsUri(format, size, state) {

params.size = size;
params.format = format;
// eslint-disable-next-line camelcase

params.no_aggs = true;

// Remove unnecessary pagination query params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const AggregationBranch = ({ fieldName, item, subitems }) => {
disabled: item.isDisabled,
key: slugify(item.key, sub.key),
value: sub.key,
// eslint-disable-next-line camelcase

doc_count: sub.doc_count,
}));

Expand Down Expand Up @@ -132,7 +132,6 @@ export const AggregationBranch = ({ fieldName, item, subitems }) => {
AggregationBranch.propTypes = {
fieldName: PropTypes.string.isRequired,
item: PropTypes.shape({
// eslint-disable-next-line camelcase
doc_count: PropTypes.number.isRequired,
key: PropTypes.string.isRequired,
value: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ const appliedFilters = ({ fieldName, item, aggs, filters }) => {
// check the parent only, and uncheck the rest so that the fake check
// will take affect
const [parentFilter, childFilter] = item.key.split(SLUG_SEPARATOR);
/* eslint-disable no-unexpected-multiline */

// TODO: reformat to not need the unexpected multiline.
const subItems = aggs
.find((agg) => agg.key === parentFilter)
['sub_' + fieldName + '.raw'].buckets.map((agg) => agg.key)
.sort();
/* eslint-enable no-unexpected-multiline */

const parentKey = parentFilter + SLUG_SEPARATOR;
const selectedFilters = filters
Expand Down Expand Up @@ -121,7 +120,6 @@ export const AggregationItem = ({ fieldName, item }) => {
AggregationItem.propTypes = {
fieldName: PropTypes.string.isRequired,
item: PropTypes.shape({
// eslint-disable-next-line camelcase
doc_count: PropTypes.number.isRequired,
key: PropTypes.string.isRequired,
value: PropTypes.string,
Expand Down
1 change: 0 additions & 1 deletion src/components/Filters/Date/CompanyReceivedFilter.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CompanyReceivedFilter } from './CompanyReceivedFilter';
import React from 'react';
import { merge } from '../../../testUtils/functionHelpers';
import { queryState } from '../../../reducers/query/querySlice';
import * as filterActions from '../../../reducers/query/querySlice';
Expand Down
1 change: 0 additions & 1 deletion src/components/Filters/FilterPanel/FilterPanel.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { FilterPanel } from './FilterPanel';
import { merge } from '../../../testUtils/functionHelpers';
import { viewState } from '../../../reducers/view/viewSlice';
Expand Down
1 change: 0 additions & 1 deletion src/components/Filters/Issue/Issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { MoreOrLess } from '../MoreOrLess/MoreOrLess';
import { AggregationBranch } from '../Aggregation/AggregationBranch/AggregationBranch';
import { useGetAggregations } from '../../../api/hooks/useGetAggregations';

// eslint-disable-next-line react/prop-types
export const Issue = () => {
const dispatch = useDispatch();
const [dropdownOptions, setDropdownOptions] = useState([]);
Expand Down
2 changes: 2 additions & 0 deletions src/components/Filters/MoreOrLess/MoreOrLess.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import PropTypes from 'prop-types';
import { createElement, useState } from 'react';

//TODO: will make much less complex in implementation
// eslint-disable-next-line complexity
export const MoreOrLess = ({
listComponent,
listComponentProps = {},
Expand Down
1 change: 0 additions & 1 deletion src/components/Filters/Product/Product.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const generateOptions = (
return options;
};

// eslint-disable-next-line react/prop-types
export const Product = () => {
const { data } = useGetAggregations();
// See if there are an active product filters
Expand Down
2 changes: 1 addition & 1 deletion src/components/Filters/StickyOptions/StickyOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const zeroCounts = (cache) => {
Object.keys(cache).forEach((key) => {
result[key] = {
...cache[key],
// eslint-disable-next-line camelcase

doc_count: 0,
};
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/List/ListPanel/ListPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sizes, sorts } from '../../../constants';
import { ActionBar } from '../../ActionBar/ActionBar';
import { ComplaintCard } from '../ComplaintCard/ComplaintCard';
import { useDispatch, useSelector } from 'react-redux';
import ErrorBlock from '../../Warnings/Error';
import { ErrorBlock } from '../../Warnings/Error';
import { FilterPanel } from '../../Filters/FilterPanel/FilterPanel';
import { FilterPanelToggle } from '../../Filters/FilterPanel/FilterPanelToggle';
import { Loading } from '../../Loading/Loading';
Expand Down
Loading

0 comments on commit 2f55fd0

Please sign in to comment.