Skip to content

Commit

Permalink
fix: update eslint config to flatconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed Sep 13, 2024
1 parent f63854d commit 7b179fd
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 175 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

71 changes: 0 additions & 71 deletions .eslintrc

This file was deleted.

102 changes: 102 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import _import from 'eslint-plugin-import';
import jsxA11Y from 'eslint-plugin-jsx-a11y';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: [
'**/build/',
'**/dist/',
'**/node_modules',
'**/.snapshots/',
'**/*.min.js',
'**/storybook-static',
],
},
...compat.extends(
'eslint:recommended',
'prettier',
'plugin:@typescript-eslint/recommended',
),
{
plugins: {
import: fixupPluginRules(_import),
'jsx-a11y': jsxA11Y,
'@typescript-eslint': typescriptEslint,
},

languageOptions: {
globals: {
...globals.node,
...globals.browser,
},

parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',

parserOptions: {
ecmaFeatures: {
legacyDecorators: true,
jsx: true,
},
},
},

settings: {
react: {
version: '18',
},
},

rules: {
'space-before-function-paren': 'off',
'react/prop-types': 'off',
'react/jsx-handler-names': 'off',
'react/jsx-fragments': 'off',
'react/no-unused-prop-types': 'off',
'import/export': 'off',
'no-unused-vars': 'off',

'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],

'@typescript-eslint/explicit-function-return-type': 'off',
'no-use-before-define': 'off',
},
},
{
files: ['**/*.ts', '**/*.tsx'],

rules: {
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
},
],
},
},
];
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
"@emotion/cache": "~11.13.1",
"@emotion/react": "11.13.3",
"@emotion/styled": "11.13.0",
"@eslint/compat": "1.1.1",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.10.0",
"@graasp/sdk": "4.28.0",
"@graasp/stylis-plugin-rtl": "2.2.0",
"@mui/icons-material": "5.16.7",
Expand Down Expand Up @@ -141,13 +144,14 @@
"concurrently": "9.0.1",
"cross-env": "7.0.3",
"date-fns": "3.6.0",
"eslint": "^8.57.0",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsx-a11y": "6.10.0",
"eslint-plugin-n": "17.10.2",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.1.0",
"globals": "15.9.0",
"http-server": "14.1.1",
"husky": "9.1.6",
"jsdom": "25.0.0",
Expand Down
7 changes: 1 addition & 6 deletions src/TextEditor/TextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,10 @@ const TextEditor = ({
const onTextChange = (text: string): void => {
// keep track of the current content
setContent(text);
// eslint-disable-next-line no-unused-expressions
onChange?.(text);
};

const onCancelClick = (): void => {
// eslint-disable-next-line no-unused-expressions
onCancel?.(content);
setContent(initialValue);
};
Expand Down Expand Up @@ -127,10 +125,7 @@ const TextEditor = ({
</Button>
<SaveButton
id={saveButtonId}
onClick={() => {
// eslint-disable-next-line no-unused-expressions
onSave?.(content);
}}
onClick={() => onSave?.(content)}
text={saveButtonText}
savedText={savedButtonText}
hasChanges={content !== initialValue}
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useFullscreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export const useFullscreen = (): FullscreenHookType => {
.requestFullscreen()
.then(() => setIsFullscreen(true))
.catch((err) => {
// eslint-disable-next-line no-console
console.log(
console.error(
`Error attempting to enable fullscreen mode: ${err.message} (${err.name})`,
);
});
Expand Down
2 changes: 0 additions & 2 deletions src/items/appItemHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const useAppCommunication = ({

switch (type) {
case POST_MESSAGE_KEYS.GET_AUTH_TOKEN: {
// eslint-disable-next-line no-unused-expressions
port.postMessage(
JSON.stringify({
type: POST_MESSAGE_KEYS.GET_AUTH_TOKEN_SUCCESS,
Expand Down Expand Up @@ -127,7 +126,6 @@ const useAppCommunication = ({

// Transfer port2 to the iframe
// provide port2 to app and item's data
// eslint-disable-next-line no-unused-expressions
iFrameRef?.current?.contentWindow?.postMessage(
JSON.stringify({
type: POST_MESSAGE_KEYS.GET_CONTEXT_SUCCESS,
Expand Down
Loading

0 comments on commit 7b179fd

Please sign in to comment.