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

🚨 Forbedret ESLint-oppsett #2265

Merged
merged 51 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
77a37a9
:arrow_up: Bumped eslint
KenAJoh Sep 5, 2023
2752a99
:truck: Flyttet eslint-config og ts-plugin
KenAJoh Sep 5, 2023
48a75fc
oppdatert eslintrc, fikset noen feil
HalvorHaugan Sep 5, 2023
428f742
flere fikser
HalvorHaugan Sep 6, 2023
b1ba620
fikset tabs og timeline
HalvorHaugan Sep 7, 2023
38cb82d
fikset mesteparten i website
HalvorHaugan Sep 7, 2023
fffd09c
mer fiksing
HalvorHaugan Sep 8, 2023
22dfbd3
Merge branch 'main' into eslint-update
HalvorHaugan Sep 8, 2023
a25a586
Merge branch 'main' into eslint-update
HalvorHaugan Sep 8, 2023
3707e8b
fiks fiks
HalvorHaugan Sep 8, 2023
9087e74
fjern unødvendige overrides, legg til storybook-plugin
HalvorHaugan Sep 8, 2023
db77f84
Unngå eslint-disable react-hooks/rules-of-hooks
HalvorHaugan Sep 8, 2023
48a75c1
Fjern eslint-stats
HalvorHaugan Sep 8, 2023
f7e9064
:fire: Fjernet re-export av aksel logo
KenAJoh Sep 10, 2023
636e81f
:bug: Fjernet unødvendig optional-chaning
KenAJoh Sep 10, 2023
3ecb89f
:bug: Fjernet require-import i tailwind
KenAJoh Sep 10, 2023
3cddb50
:art: Allowcomputed i randomicons
KenAJoh Sep 10, 2023
4fdd524
:bug: Togglegroup videresender nå id riktig
KenAJoh Sep 10, 2023
298c93a
:art: omit children fra loader
KenAJoh Sep 10, 2023
a1bbcdc
:art: Omit children fra useCheckbox
KenAJoh Sep 10, 2023
7046b56
:fire: Fjernet unødvendig test
KenAJoh Sep 10, 2023
f8c4227
:art: Bedre assertion av htmlSize i select
KenAJoh Sep 10, 2023
5a2f3ff
:label: Bedre export av typer i dropdown
KenAJoh Sep 10, 2023
5eb999b
:bug: datepicker tester
KenAJoh Sep 10, 2023
036ad1e
:fire: fjernet unødvendig test
KenAJoh Sep 10, 2023
11c5b0c
:art: Omit children og id fra datepickerstandalone
KenAJoh Sep 10, 2023
ada53af
:art: Omit onClick fra accordionItem
KenAJoh Sep 10, 2023
bae26fd
:recycle: bruker const i css-imports
KenAJoh Sep 10, 2023
7d4cd1b
:label: bruker names import fra jscodeshift
KenAJoh Sep 10, 2023
8424662
:fire: Cleanup av ubrukte props og filer
KenAJoh Sep 10, 2023
c0f2952
:bug: riktig import for dropdowntoggle
KenAJoh Sep 10, 2023
059b419
:bug: Fikset transform-call i codemod
KenAJoh Sep 10, 2023
a1ea42e
Merge branch 'main' into eslint-update
HalvorHaugan Sep 11, 2023
ddf39c1
fixes
HalvorHaugan Sep 12, 2023
d78b1f7
fix
HalvorHaugan Sep 12, 2023
ec0d6e6
rc
HalvorHaugan Sep 12, 2023
0bd31aa
fix combobox
HalvorHaugan Sep 12, 2023
1b1dbfa
Fjern unødvendige eslint-kommentarer
HalvorHaugan Sep 12, 2023
3e14445
comments
HalvorHaugan Sep 12, 2023
c8af38c
Merge branch 'main' into eslint-update
HalvorHaugan Sep 12, 2023
da941d0
yarn lock
HalvorHaugan Sep 12, 2023
f3bede0
upgrades
HalvorHaugan Sep 12, 2023
f0506df
kommentar
HalvorHaugan Sep 12, 2023
2f49125
:art: Add React to storybook config
KenAJoh Sep 13, 2023
ae2f03d
validate-docs
HalvorHaugan Sep 13, 2023
eb45b59
todo
HalvorHaugan Sep 13, 2023
f009c08
changeset
HalvorHaugan Sep 13, 2023
14e99eb
Merge branch 'main' into eslint-update
HalvorHaugan Sep 13, 2023
e464894
fix import in Box
HalvorHaugan Sep 13, 2023
466a3fd
Merge branch 'main' into eslint-update
HalvorHaugan Sep 13, 2023
14d8522
Merge branch 'main' into eslint-update
HalvorHaugan Sep 14, 2023
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
9 changes: 9 additions & 0 deletions .changeset/five-icons-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@navikt/ds-react": minor
---

:recycle: Refaktorering og småfikser

- Refaktorering som følge av nye ESLint-regler
- AccordionItem/ToggleGroup: Støtte for 'id'-prop
- MonthPicker: Mer presis type for 'onMonthSelect' prop
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.storybook
93 changes: 93 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// TODO: Convert to new format: https://eslint.org/docs/latest/use/configure/migration-guide
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
//"plugin:react/jsx-runtime", // Not sure if this will cause problems for projects not using the new JSX transform
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:storybook/recommended",
// TODO: Look into opinionated stylistic plugin
// TODO: Replace @typescript-eslint/recommended with @typescript-eslint/recommended-type-checked
HalvorHaugan marked this conversation as resolved.
Show resolved Hide resolved
],
settings: { react: { version: "detect" } },
rules: {
"import/no-unresolved": "off",
"react/jsx-curly-brace-presence": [
"error",
{ propElementValues: "always" },
],
// TODO add: "object-shorthand": "error",
// TODO: Consider adding the rule "id-length"
// Temporary:
"react/prop-types": "off",
"react/display-name": "off",
"import/no-named-as-default": "off",
},
reportUnusedDisableDirectives: true,
overrides: [
{
files: ["**/*.ts?(x)"],
extends: ["plugin:@typescript-eslint/recommended"],
rules: {
"@typescript-eslint/no-explicit-any": "off", // Temporary
},
},
{
files: ["**/*.test.*", "**/__tests__/*"],
extends: ["plugin:jest/recommended", "plugin:testing-library/react"],
},
{
files: ["aksel.nav.no/website/**"],
env: {
browser: true,
es2021: true,
},
extends: ["plugin:@next/next/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: "module",
},
rules: {
"react/no-unknown-property": [2, { ignore: ["jsx", "global"] }],
"react/react-in-jsx-scope": "off",
"@next/next/no-html-link-for-pages": [
"error",
"aksel.nav.no/website/pages/",
],
"@typescript-eslint/ban-ts-comment": "off", // Temporary
},
},
{
files: ["aksel.nav.no/website/pages/eksempler/**"],
rules: {
"jsx-a11y/anchor-is-valid": "off",
},
},
],
globals: {
Locale: "readonly",
JSX: "readonly",
},
ignorePatterns: [
"node_modules",
"lib",
"public",
"examples",
"esm",
"cjs",
"dist",
"**/codemod/**/*.js",
],
};
1 change: 1 addition & 0 deletions .storybook/preview.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import "@navikt/ds-css/index.css";
import "./layout.css";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-anonymous-default-export */
import fs from "fs";
import { Plugin } from "vite";

Expand Down
21 changes: 0 additions & 21 deletions @navikt/aksel-icons/figma-plugin/src/common/network/init.ts

This file was deleted.

21 changes: 0 additions & 21 deletions @navikt/aksel-icons/figma-plugin/src/common/network/messages.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions @navikt/aksel-icons/figma-plugin/src/common/network/sides.ts

This file was deleted.

2 changes: 0 additions & 2 deletions @navikt/aksel-icons/figma-plugin/src/plugin/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

figma.showUI(__html__, { width: 480, height: 600 });

figma.ui.onmessage = (msg) => {
Expand Down
8 changes: 4 additions & 4 deletions @navikt/aksel-icons/figma-plugin/src/ui/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/react-in-jsx-scope */
import { Heading, Search, ToggleGroup } from "@navikt/ds-react";
import Fuse from "fuse.js";
import { useEffect, useMemo, useState } from "react";
Expand Down Expand Up @@ -59,9 +60,8 @@ const App = () => {
}, [toggle, query, strokeIcons, fillIcons]);

const onCreate = (id: string, name: string) => {
let svg = document.getElementById(id)?.outerHTML;
let size = 24;
// eslint-disable-next-line no-restricted-globals
const svg = document.getElementById(id)?.outerHTML;
const size = 24;
parent.postMessage(
{
pluginMessage: {
Expand Down Expand Up @@ -154,7 +154,7 @@ const App = () => {
</Heading>
<div className="icons-wrapper">
{sub.icons.map((i) => {
const T = Icons[`${i.id}Icon`];
const T = Icons[`${i.id}Icon`]; // eslint-disable-line import/namespace
if (T === undefined) {
console.log(i);
return null;
Expand Down
4 changes: 1 addition & 3 deletions @navikt/aksel-icons/util/useId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ function useGlobalId(idOverride?: string): string | undefined {
return id;
}

// eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814
const maybeReactUseId: undefined | (() => string) = (React as any)[
// eslint-disable-next-line no-useless-concat
"useId" + ""
"useId" + "" // Workaround for https://github.com/webpack/webpack/issues/14814
];
/**
*
Expand Down
2 changes: 1 addition & 1 deletion @navikt/aksel-stylelint/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const flattenObject = (obj) => {
const tokenCSSFile = "./index.css";
const tokenJsonFile = "./tokens.json";

let allowedTokenNames = [];
const allowedTokenNames = [];

export const addTokens = (
tokenJSONFile: string,
Expand Down
2 changes: 1 addition & 1 deletion @navikt/aksel/src/codemod/transforms/v1.0.0/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import renameProps from "../../../utils/rename-props";
* @param {import('jscodeshift').FileInfo} file
* @param {import('jscodeshift').API} api
*/
export default function transformer(file, api, options) {
export default function transformer(file, api) {
const j = api.jscodeshift;
let localName = "SpeechBubble";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getLineTerminator } from "../../../utils/lineterminator";
* @param {import('jscodeshift').FileInfo} file
* @param {import('jscodeshift').API} api
*/
export default function transformer(file, api, options) {
export default function transformer(file, api) {
const j = api.jscodeshift;
let localName = "Pagination";

Expand Down Expand Up @@ -62,7 +62,7 @@ export default function transformer(file, api, options) {
(x) => x.name.name === "data-version" && x.value.value === "v1"
);

parent.value.openingElement?.attributes.forEach((x, index) => {
parent.value.openingElement?.attributes.forEach((x) => {
let didUpdate = false;
if (x.name?.name === "size" && x.type === "JSXAttribute" && !skip) {
/* addExplicitStandardProp */
Expand Down
8 changes: 4 additions & 4 deletions @navikt/aksel/src/codemod/transforms/v1.0.0/preset/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import transformPagination from "../pagination/pagination";
* @param {import('jscodeshift').FileInfo} file
* @param {import('jscodeshift').API} api
*/
export default function transformer(file, api, options) {
file.source = transformTabs(file, api, options);
file.source = transformChat(file, api, options);
file.source = transformPagination(file, api, options);
export default function transformer(file, api) {
file.source = transformTabs(file, api);
file.source = transformChat(file, api);
file.source = transformPagination(file, api);

return file.source;
}
2 changes: 1 addition & 1 deletion @navikt/aksel/src/codemod/transforms/v1.0.0/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import renameProps from "../../../utils/rename-props";
* @param {import('jscodeshift').FileInfo} file
* @param {import('jscodeshift').API} api
*/
export default function transformer(file, api, options) {
export default function transformer(file, api) {
const j = api.jscodeshift;
let localName = "Tabs";
let iconPositionProp = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { tokens } from "../../../tokens-map.mjs";
* @param {import('jscodeshift').FileInfo} file
* @param {import('jscodeshift').API} api
*/
export default function transformer(file, api) {
export default function transformer(file) {
let src = file.source;

tokens.forEach((tok) => {
// eslint-disable-next-line no-useless-concat
const rgx = new RegExp("(" + `${tok[0]}:` + ")", "gm");
src = src.replace(rgx, `--v2-migration${tok[0].replace("--", "__")}:`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getLineTerminator } from "../../../utils/lineterminator";
* @param {import('jscodeshift').API} api
*/
export default function transformer(file: JSCodeshift, api) {
let src = file.source;
const src = file.source;

const j = api.jscodeshift as JSCodeshift;

Expand Down
Loading