Skip to content

Commit 36c2127

Browse files
committed
feat: integrate newest eslint
1 parent 25272a2 commit 36c2127

18 files changed

+841
-1095
lines changed

.eslintrc.cjs

-20
This file was deleted.

e2e/apiMocks/unauthenticated_learningpath.spec.ts_contains_content.har

+1-1
Large diffs are not rendered by default.

e2e/apiMocks/unauthenticated_resource.spec.ts_contains_content.har

+1-1
Large diffs are not rendered by default.

e2e/apiMocks/unauthenticated_topic.spec.ts_contains_article_header_and_introduction.har

+1-1
Large diffs are not rendered by default.

e2e/apiMocks/unauthenticated_topic.spec.ts_show_have_functioning_language_box.har

+1-1
Large diffs are not rendered by default.

eslint.config.mjs

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Copyright (c) 2024-present, NDLA.
3+
*
4+
* This source code is licensed under the GPLv3 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
*/
8+
9+
// @ts-check
10+
11+
import config from "eslint-config-ndla";
12+
import tseslint from "typescript-eslint";
13+
import graphqlPlugin from "@graphql-eslint/eslint-plugin";
14+
15+
export default tseslint.config(
16+
...config,
17+
{
18+
ignores: ["**/graphqlTypes.ts", "**/schema.graphql"],
19+
},
20+
{
21+
files: ["**/*.graphql"],
22+
rules: {
23+
"header/header": "off",
24+
},
25+
},
26+
{
27+
files: ["**/*.{js,mjs,cjs,ts,jsx,tsx,mts,cts,mtsx,ctsx}"],
28+
processor: graphqlPlugin.processor,
29+
},
30+
{
31+
files: ["**/*.graphql"],
32+
languageOptions: {
33+
parser: graphqlPlugin.parser,
34+
parserOptions: {
35+
graphQLConfig: {
36+
schema: "./src/schema.graphql",
37+
documents: ["./src/**/*.{ts,tsx}"],
38+
},
39+
},
40+
},
41+
plugins: {
42+
"@graphql-eslint": graphqlPlugin,
43+
},
44+
rules: {
45+
...graphqlPlugin.configs["flat/operations-recommended"].rules,
46+
...graphqlPlugin.configs["flat/schema-recommended"].rules,
47+
// TODO: Consider enabling these later
48+
"@graphql-eslint/selection-set-depth": "off",
49+
"@graphql-eslint/require-selections": "off",
50+
},
51+
},
52+
);

package.json

+16-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"test": "vitest --run",
1414
"tdd": "vitest",
1515
"lint": "yarn format-check && yarn lint-es",
16-
"lint-es": "eslint --cache --cache-location '.eslintcache/' --ext .js,.jsx,.ts,.tsx --max-warnings=0 src e2e",
16+
"lint-es": "eslint --cache --cache-location '.eslintcache/' --max-warnings=0 src e2e",
1717
"format": "prettier '{src,e2e}/**/*(*.js|*.jsx|*.ts|*.tsx|*.graphql)' --write",
1818
"format-check": "prettier '{src,e2e}/**/*(*.js|*.jsx|*.ts|*.tsx|*.graphql)' --check",
1919
"start": "NODE_OPTIONS='--preserve-symlinks' concurrently 'yarn start:tsc' 'tsx src/index.ts'",
@@ -41,9 +41,9 @@
4141
"@graphql-codegen/schema-ast": "^4.0.2",
4242
"@graphql-codegen/typescript": "^4.0.6",
4343
"@graphql-codegen/typescript-operations": "^4.2.0",
44-
"@graphql-eslint/eslint-plugin": "^3.20.1",
45-
"@ndla/preset-panda": "^0.0.44",
46-
"@ndla/scripts": "^2.1.2",
44+
"@graphql-eslint/eslint-plugin": "4.0.0-alpha.16",
45+
"@ndla/preset-panda": "^0.0.45",
46+
"@ndla/scripts": "^2.1.3",
4747
"@ndla/types-backend": "^0.2.88",
4848
"@ndla/types-embed": "^5.0.4-alpha.0",
4949
"@ndla/types-taxonomy": "^1.0.33",
@@ -61,8 +61,8 @@
6161
"babel-plugin-graphql-tag": "^3.3.0",
6262
"concurrently": "^8.2.2",
6363
"esbuild": "^0.20.2",
64-
"eslint": "^8.57.0",
65-
"eslint-config-ndla": "^5.0.3",
64+
"eslint": "^9.15.0",
65+
"eslint-config-ndla": "^6.0.0-alpha.0",
6666
"jsdom": "^24.0.0",
6767
"nock": "^14.0.0-beta.5",
6868
"postcss": "^8.4.39",
@@ -73,6 +73,7 @@
7373
"sirv": "^2.0.4",
7474
"tsx": "^4.7.2",
7575
"typescript": "^5.6.3",
76+
"typescript-eslint": "^8.16.0",
7677
"vite": "^5.2.9",
7778
"vitest": "^1.5.0"
7879
},
@@ -88,17 +89,17 @@
8889
"@fontsource/source-sans-pro": "^4.5.9",
8990
"@fontsource/source-serif-pro": "^4.5.7",
9091
"@lexical/react": "^0.12.4",
91-
"@ndla/article-converter": "^10.0.75-alpha.0",
92+
"@ndla/article-converter": "^10.0.76-alpha.0",
9293
"@ndla/core": "^5.0.2",
93-
"@ndla/hooks": "^2.1.9",
94-
"@ndla/icons": "^8.0.43-alpha.0",
95-
"@ndla/licenses": "^8.0.3-alpha.0",
96-
"@ndla/primitives": "^1.0.56-alpha.0",
97-
"@ndla/safelink": "^7.0.57-alpha.0",
94+
"@ndla/hooks": "^2.1.10",
95+
"@ndla/icons": "^8.0.44-alpha.0",
96+
"@ndla/licenses": "^8.0.4-alpha.0",
97+
"@ndla/primitives": "^1.0.57-alpha.0",
98+
"@ndla/safelink": "^7.0.58-alpha.0",
9899
"@ndla/styled-system": "^0.0.27",
99-
"@ndla/tracker": "^5.0.11-alpha.0",
100-
"@ndla/ui": "^56.0.72-alpha.0",
101-
"@ndla/util": "^5.0.0-alpha.0",
100+
"@ndla/tracker": "^5.0.12-alpha.0",
101+
"@ndla/ui": "^56.0.73-alpha.0",
102+
"@ndla/util": "^5.0.1-alpha.0",
102103
"@sentry/react": "^8.32.0",
103104
"cross-env": "^7.0.3",
104105
"express": "^5.0.0",

src/components/DefaultErrorMessage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import {
1515
ErrorMessageActions,
1616
} from "@ndla/primitives";
1717
import { SafeLink } from "@ndla/safelink";
18-
import { PageContainer } from "./Layout/PageContainer";
1918
import { Status } from "../components";
2019
import { SKIP_TO_CONTENT_ID } from "../constants";
20+
import { PageContainer } from "./Layout/PageContainer";
2121

2222
interface MessageRootProps {
2323
applySkipToContentId?: boolean;

src/components/Learningpath/LearningpathEmbed.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const LearningpathEmbed = ({ learningpathStep, skipToContentId, subjectId, bread
9494
learningpathStepQuery,
9595
{
9696
variables: {
97-
articleId: articleId ?? learningpathStep.resource?.article?.id.toString()!,
97+
articleId: articleId ?? learningpathStep.resource?.article?.id.toString() ?? "",
9898
resourceId: taxId ?? "",
9999
includeResource: !!taxId,
100100
transformArgs: {
@@ -226,7 +226,6 @@ const articleFragment = gql`
226226
created
227227
updated
228228
articleType
229-
metaDescription
230229
requiredLibraries {
231230
name
232231
url

src/components/Learningpath/LearningpathIframe.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const LearningpathIframe = ({ html, url }: Props) => {
8686
const iframe = getIframeDOM();
8787
if (iframe) {
8888
const newHeight = parseInt(evt.data.height, 10);
89-
iframe.style.height = `${newHeight}px`; // eslint-disable-line no-param-reassign
89+
iframe.style.height = `${newHeight}px`;
9090
}
9191
};
9292

src/containers/ArticlePage/ArticlePage.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ const ArticlePage = ({ resource, errors, skipToContentId, loading }: Props) => {
242242
authors={authors}
243243
suppliers={article.copyright?.rightsholders}
244244
published={article.published}
245-
license={article.copyright?.license?.license ?? ""}
246245
licenseBox={
247246
<LicenseBox article={article} copyText={copyText} printUrl={printUrl} oembed={article.oembed} />
248247
}

src/containers/MyNdla/Arena/PostsPage.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ const PostsPage = () => {
6565

6666
const [subscribeToTopic] = useArenaFollowTopicMutation();
6767
const [unsubscribeFromTopic] = useArenaUnfollowTopicMutation();
68-
const { replyToTopic } = useArenaReplyToTopicMutation(arenaTopic?.id!);
68+
const { replyToTopic } = useArenaReplyToTopicMutation(arenaTopic?.id ?? -1);
6969

7070
const createReply = useCallback(
7171
async (data: Partial<ArenaFormValues>, postId?: number) => {
72+
if (!arenaTopic?.id) return;
7273
const newReply = await replyToTopic({
73-
variables: { topicId: arenaTopic?.id!, content: data.content ?? "", postId: postId },
74+
variables: { topicId: arenaTopic.id, content: data.content ?? "", postId: postId },
7475
});
7576

7677
// TODO: Replace this with `setFocusId(newReply.data.replyToTopicV2.id)` when nodebb dies
@@ -131,15 +132,15 @@ const PostsPage = () => {
131132
arenaCategory?.breadcrumbs?.map((crumb) => ({ name: crumb.title, id: `category/${crumb.id}` })) ?? [];
132133
const crumbs = [...parentCrumbs, { name: arenaTopic?.title ?? "", id: topicId ?? "" }];
133134

134-
if (loading || !arenaTopic?.posts?.items) return <PageSpinner />;
135+
if (loading || !arenaTopic?.posts?.items?.[0]) return <PageSpinner />;
135136

136137
return (
137138
<StyledMyNdlaPageWrapper>
138139
<HelmetWithTracker title={t("htmlTitles.arenaPostPage", { name: arenaTopic?.title })} />
139140
<MyNdlaBreadcrumb breadcrumbs={crumbs} page={"arena"} />
140141
<div>
141142
<MainPostCard
142-
post={arenaTopic?.posts?.items[0]!}
143+
post={arenaTopic.posts.items[0]}
143144
topic={arenaTopic}
144145
onFollowChange={onFollowChange}
145146
setFocusId={setFocusId}

src/containers/TopicPage/MovedTopicPage.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ MovedTopicPage.fragments = {
126126
name
127127
path
128128
url
129-
name
130129
breadcrumbs
131130
meta {
132131
metaDescription

src/containers/TopicPage/MultidisciplinarySubjectArticle.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ const MultidisciplinarySubjectArticle = ({ node }: Props) => {
211211
authors={authors}
212212
suppliers={article.copyright?.rightsholders}
213213
published={article.published}
214-
license={article.copyright?.license?.license ?? ""}
215214
licenseBox={<LicenseBox article={article} copyText={copyText} oembed={article.oembed} />}
216215
/>
217216
<NoSSR fallback={null}>

src/iframe/__tests__/__snapshots__/IframeArticlePage-test.tsx.snap

+7-12
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,16 @@ exports[`IframeArticlePage with article renderers correctly 1`] = `
5252
class="mbs_medium pbs_xsmall bd-t_1px_solid bd-c_stroke.subtle"
5353
>
5454
<div
55-
class="d_flex flex-d_column-reverse gap_3xsmall w_100% jc_space-between py_xsmall textStyle_body.medium tabletWide:flex-d_row"
55+
class="d_flex flex-d_column gap_3xsmall w_100% jc_space-between py_xsmall textStyle_body.medium [&_[data-contributors="false"]]:ms_auto tabletWide:flex-d_row"
5656
>
57+
<span
58+
property="cc:attributionName"
59+
>
60+
Skrevet av Someone.
61+
</span>
5762
<div
58-
class="d_flex gap_xsmall"
63+
data-contributors="true"
5964
>
60-
<span>
61-
by-sa
62-
</span>
63-
<span
64-
property="cc:attributionName"
65-
>
66-
Skrevet av Someone.
67-
</span>
68-
</div>
69-
<div>
7065
Sist faglig oppdatert 09.01.2018
7166
</div>
7267
</div>

src/lti/LtiEmbed.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
*
77
*/
88

9+
import { LtiData, LtiItem } from "../interfaces";
910
import LtiBasicLaunch from "./components/LtiBasicLaunch";
1011
import LtiDeepLinking from "./components/LtiDeepLinking";
1112
import LtiDefault from "./components/LtiDefault";
12-
import { LtiData, LtiItem } from "../interfaces";
1313

1414
interface Props {
1515
item: LtiItem;

src/util/brightcoveHelpers.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const getContributorGroups = (licenseInfos: string[]) => {
4444
if (contributorFields.length !== 2) return { type: "", name: contributorFields[0]! };
4545
const [type, name] = contributorFields;
4646
const contributorType = Object.keys(contributorTypes.nb!).find(
47-
(key) => contributorTypes.nb![key] === mapContributorType(type?.trim()!),
47+
(key) => contributorTypes.nb![key] === mapContributorType((type as string).trim()),
4848
);
4949
return { type: contributorType || "", name: name || "" };
5050
};

0 commit comments

Comments
 (0)