Skip to content

Commit

Permalink
fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed Dec 29, 2024
1 parent 6bd8f0c commit db2914c
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 65 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

50 changes: 0 additions & 50 deletions .eslintrc

This file was deleted.

2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"eslint.alwaysShowStatus": true,
"eslint.format.enable": true,
"eslint.codeActionsOnSave.mode": "problems",
"editor.formatOnSave": true,

"flow.enabled": false,

Expand All @@ -19,6 +20,7 @@

"jestrunner.debugOptions": {"args": ["--watch"]},
"jestrunner.configPath": "jest.config.js",

"cSpell.words": [
"astring",
"lcov",
Expand Down
1 change: 0 additions & 1 deletion demo/src/hooks/useContext.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import React from 'react';
import createStepLogger from '../createStepLogger';

Expand Down
2 changes: 1 addition & 1 deletion demo/src/ssr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import DemoComponent from './DemoComponent';

export default {
description: 'Server Side (hydrate)',
fn({ reactDomRoot, whyDidYouRender }) {
fn({ reactDomRoot, domElement, whyDidYouRender }) {
const stepLogger = createStepLogger();

fetch('/ssrComponent')
Expand Down
65 changes: 65 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const reactPlugin = require('eslint-plugin-react');
const js = require('@eslint/js');
const globals = require('globals');
const { includeIgnoreFile } = require('@eslint/compat');
const pluginCypress = require('eslint-plugin-cypress/flat');

// TODO: remove once all deps are using the latest version
globals.browser['AudioWorkletGlobalScope'] = globals.browser['AudioWorkletGlobalScope '];
delete globals.browser['AudioWorkletGlobalScope '];


module.exports = [
includeIgnoreFile(__dirname +'/.gitignore'),
js.configs.recommended,
pluginCypress.configs.globals,
{
plugins: {
cypress: pluginCypress
},
rules: {
'cypress/unsafe-to-chain-command': 'error'
},
},
{
...reactPlugin.configs.flat.recommended,
languageOptions: {
...reactPlugin.configs.flat.recommended.languageOptions,
globals: {
...globals.browser,
...globals.jest,
...globals.node,
...globals.console,
flushConsoleOutput: 'readable',
},
},
rules: {
'semi': ['error', 'always'],
'curly': 'error',
'no-var': 'error',
'quotes': ['error', 'single'],
'no-console': 'error',
'no-debugger': 'warn',
'react/jsx-uses-vars': 'error',
'react/jsx-uses-react': 'error',
'no-unused-vars': ['error', {
'ignoreRestSiblings': true,
'varsIgnorePattern': '^_',
'argsIgnorePattern': '^_',
'caughtErrorsIgnorePattern': '^_',
'destructuredArrayIgnorePattern': '^_'
}],
'eol-last': 'error',
'object-curly-spacing': ['error', 'always'],
'react/prop-types': 'off',
'react/display-name': 'off',
'space-before-function-paren': ['error', 'never'],
'space-before-blocks': ['error', 'always'],
'space-in-parens': ['error', 'never'],
'comma-dangle': ['error', 'only-multiline'],
'func-call-spacing': ['error', 'never'],
'no-multi-spaces': 'error',
'indent': ['error', 2]
}
}
];
4 changes: 2 additions & 2 deletions jest.polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
*/

const { TextDecoder, TextEncoder } = require('node:util');
// eslint-disable-next-line no-undef
Object.defineProperties(globalThis, {
TextDecoder: { value: TextDecoder },
TextEncoder: { value: TextEncoder },
});

const { Blob, File } = require('node:buffer');
// eslint-disable-next-line no-undef
Object.defineProperties(globalThis, {
Blob: { value: Blob },
File: { value: File },
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"build": "cross-env NODE_ENV=production rollup --config --bundleConfigAsCjs",
"test": "jest --config=jest.config.js",
"test:ci": "yarn test --coverage",
"lint": "eslint . --ext=js --max-warnings 0 --cache --cache-location .cache/eslint-cache",
"lint": "eslint . --max-warnings 0 --cache --cache-location .cache/eslint-cache",
"clear": "rimraf .cache dist demo/dist",
"watch": "concurrently --names \"Serve,Test\" \"npm:start\" \"npm:test:watch\"",
"checkHealth": "yarn lint && yarn test",
Expand Down Expand Up @@ -82,6 +82,7 @@
"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.26.3",
"@eslint/compat": "^1.2.4",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.2",
Expand Down
3 changes: 1 addition & 2 deletions src/patches/patchClassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import wdyrStore from '../wdyrStore';

import { checkIfInsideAStrictModeTree } from '../utils';
import getUpdateInfo from '../getUpdateInfo';
import { getCurrentOwner } from '../helpers';

export default function patchClassComponent(ClassComponent, { displayName, defaultProps }) {
class WDYRPatchedClassComponent extends ClassComponent {
Expand Down Expand Up @@ -61,7 +60,7 @@ export default function patchClassComponent(ClassComponent, { displayName, defau

try {
WDYRPatchedClassComponent.displayName = displayName;
} catch (e) {
} catch (_e) {
// not crucial if displayName couldn't be set
}

Expand Down
2 changes: 1 addition & 1 deletion src/patches/patchForwardRefComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function patchForwardRefComponent(ForwardRefComponent, { displayN

try {
WDYRForwardRefFunctionalComponent.displayName = displayName;
} catch (e) {
} catch (_e) {
// not crucial if displayName couldn't be set
}

Expand Down
2 changes: 1 addition & 1 deletion src/patches/patchFunctionalOrStrComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function patchFunctionalOrStrComponent(FunctionalOrStringComponen

try {
WDYRFunctionalComponent.displayName = displayName;
} catch (e) {
} catch (_e) {
// not crucial if displayName couldn't be set
}

Expand Down
4 changes: 2 additions & 2 deletions src/patches/patchMemoComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function patchMemoComponent(MemoComponent, { displayName, default

try {
PatchedInnerComponent.displayName = getDisplayName(WrappedFunctionalComponent);
} catch (e) {
} catch (_e) {
// not crucial if displayName couldn't be set
}

Expand All @@ -41,7 +41,7 @@ export default function patchMemoComponent(MemoComponent, { displayName, default

try {
WDYRMemoizedFunctionalComponent.displayName = displayName;
} catch (e) {
} catch (_e) {
// not crucial if displayName couldn't be set
}

Expand Down
2 changes: 1 addition & 1 deletion tests/librariesTests/styled-components.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console */
import React from 'react';
import styled from 'styled-components/dist/styled-components.js';
import * as rtl from '@testing-library/react';
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,11 @@
resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.1.tgz#cfc6cffe39df390a3841cde2abccf92eaa7ae0e0"
integrity sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==

"@eslint/compat@^1.2.4":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@eslint/compat/-/compat-1.2.4.tgz#b69b0d76ce73fe66d7f8633c406acea151f5c559"
integrity sha512-S8ZdQj/N69YAtuqFt7653jwcvuUj131+6qGLUyDqfDg1OIoBQ66OCuXC473YQfO2AaxITTutiRQiDwoo7ZLYyg==

"@eslint/config-array@^0.19.0":
version "0.19.1"
resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.19.1.tgz#734aaea2c40be22bbb1f2a9dac687c57a6a4c984"
Expand Down

0 comments on commit db2914c

Please sign in to comment.