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

[ESLint] enable unicorn/no-useless-undefined #3121

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = {
'sonarjs/no-identical-functions': 'error',
'sonarjs/no-unused-collection': 'error',
'sonarjs/no-extra-arguments': 'error',

'unicorn/no-useless-undefined': 'error',
// Strict Mode (http://eslint.org/docs/rules/#strict-mode)
strict: 0,

Expand Down
12 changes: 4 additions & 8 deletions packages/cm6-graphql/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { GraphQLSchema } from 'graphql';
import { GqlExtensionsOptions } from './interfaces';

const schemaEffect = StateEffect.define<GraphQLSchema | undefined>();
const schemaStateField = StateField.define<GraphQLSchema | undefined>({
create() {
return undefined;
},
const schemaStateField = StateField.define<GraphQLSchema | void>({
create() {},
update(schema, tr) {
for (const e of tr.effects) {
if (e.is(schemaEffect)) {
Expand All @@ -20,10 +18,8 @@ const schemaStateField = StateField.define<GraphQLSchema | undefined>({
});

const optionsEffect = StateEffect.define<GqlExtensionsOptions | undefined>();
const optionsStateField = StateField.define<GqlExtensionsOptions | undefined>({
create() {
return undefined;
},
const optionsStateField = StateField.define<GqlExtensionsOptions | void>({
create() {},
update(opts, tr) {
for (const e of tr.effects) {
if (e.is(optionsEffect)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-react/src/editor/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export function EditorContextProvider(props: EditorContextProviderProps) {
[storage, tabState, headerEditor],
);

const lastShouldPersistHeadersProp = useRef<boolean | undefined>(undefined);
const lastShouldPersistHeadersProp = useRef<boolean | undefined>();
useEffect(() => {
const propValue = Boolean(props.shouldPersistHeaders);
if (lastShouldPersistHeadersProp.current !== propValue) {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-react/src/execution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function tryParseJsonObject({
errorMessageParse: string;
errorMessageType: string;
}) {
let parsed: Record<string, any> | undefined = undefined;
let parsed: Record<string, any> | undefined;
try {
parsed = json && json.trim() !== '' ? JSON.parse(json) : undefined;
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql/src/components/GraphiQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
props.defaultEditorToolsVisibility === 'variables' ||
props.defaultEditorToolsVisibility === 'headers'
) {
return undefined;
return;
}

if (typeof props.defaultEditorToolsVisibility === 'boolean') {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-language-service-server/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class Logger implements VSCodeLogger {
}

_log(message: string, severityKey: SeverityEnum): void {
const timestamp = new Date().toLocaleString(undefined);
const timestamp = new Date().toLocaleString();
const severity = DIAGNOSTIC_SEVERITY[severityKey];
const { pid } = process;

Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-graphql-execution/src/helpers/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class SourceHelper {
JSON.parse(value);
return null;
} catch {
return undefined;
return;
}
}
} catch {
Expand Down