Skip to content

Commit 37a5c30

Browse files
committed
chore: Enable eslint-plugin-import for frontend and tests
1 parent fac1504 commit 37a5c30

File tree

6 files changed

+23
-6
lines changed

6 files changed

+23
-6
lines changed

eslint.config.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import path from 'node:path';
12
import globals from 'globals';
23
import pluginJs from '@eslint/js';
34
import pluginReact from 'eslint-plugin-react';
@@ -50,10 +51,16 @@ export default [
5051
},
5152
{
5253
files: ['frontend/**/*.{js,jsx}'],
54+
...importPlugin.flatConfigs.recommended,
5355
settings: {
5456
react: {
5557
version: 'detect',
5658
},
59+
'import/resolver': {
60+
webpack: {
61+
config: path.resolve('.', './webpack.config.js'),
62+
},
63+
},
5764
},
5865
languageOptions: {
5966
...pluginReact.configs.flat.recommended.languageOptions,
@@ -73,7 +80,11 @@ export default [
7380
},
7481
{
7582
files: ['test/**/*.{js,jsx}', '**/*.test.{js,jsx}', '**/*.spec.{js,jsx}'],
83+
...importPlugin.flatConfigs.recommended,
7684
...testingLibrary.configs['flat/react'],
85+
languageOptions: {
86+
ecmaVersion: 'latest',
87+
},
7788
},
7889
pluginReact.configs.flat['jsx-runtime'],
7990
pluginReact.configs.flat.recommended,
@@ -87,6 +98,11 @@ export default [
8798
react: {
8899
version: 'detect',
89100
},
101+
'import/resolver': {
102+
node: {
103+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
104+
},
105+
},
90106
},
91107
rules: {
92108
'no-await-in-loop': 'error',

frontend/pages/sites/$siteId/SideNav.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const SideNav = ({ config, siteId }) => (
2020
>
2121
<ul className="usa-sidenav-list usa-list--unstyled">
2222
{config.map((conf) => {
23+
// eslint-disable-next-line import/namespace
2324
const IconComponent = icons[conf.icon];
2425
return (
2526
<li className="margin-y-2" key={conf.route}>

frontend/pages/sites/$siteId/builds/Build.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import buildActions from '@actions/buildActions';
88

99
import GithubBuildBranchLink from '@shared/GithubBuildBranchLink';
1010
import GithubBuildShaLink from '@shared/GithubBuildShaLink';
11-
import { IconView } from '@shared/icons';
1211
import {
1312
IconCheckCircle,
1413
IconClock,
@@ -17,6 +16,7 @@ import {
1716
IconX,
1817
IconRebuild,
1918
IconReport,
19+
IconView,
2020
} from '@shared/icons';
2121

2222
import { SITE, BUILD } from '@propTypes';

frontend/pages/sites/$siteId/settings/BranchConfig.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
22
import PropTypes from 'prop-types';
3-
import yaml from 'js-yaml';
3+
import { dump } from 'js-yaml';
44
import ExpandableArea from '@shared/ExpandableArea';
55
import LoadingIndicator from '@shared/LoadingIndicator';
66
import notificationActions from '@actions/notificationActions';
@@ -9,7 +9,7 @@ import { capitalize } from '@util';
99
function formatConfig(config) {
1010
if (!config) return '';
1111

12-
return yaml.dump(config);
12+
return dump(config);
1313
}
1414

1515
function BranchConfig({ id, branch, config, context, handleUpdate, isExpanded }) {

frontend/util/buildStatusNotifier.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import io from 'socket.io-client';
1+
import { io } from 'socket.io-client';
22

33
import globals from '../globals';
44

frontend/util/validators.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yaml from 'js-yaml';
1+
import { load } from 'js-yaml';
22
import { hasOrgs } from '../selectors/organization';
33

44
const validAddRepoSiteForm = ({ repoOrganizationId, repoUrl }, { organizations }) => {
@@ -30,7 +30,7 @@ const validBasicAuthPassword = (s) =>
3030

3131
function isValidYaml(yamlString) {
3232
try {
33-
yaml.load(yamlString);
33+
load(yamlString);
3434
} catch (_) {
3535
// for Sequelize validators, we need to throw an error
3636
// on invalid values

0 commit comments

Comments
 (0)