Skip to content

Commit 68b9410

Browse files
justin808claude
andcommitted
Fix ESLint errors caught by stricter type checking
- Replace deprecated tsEslint.config() with defineConfig() from eslint/config - Remove redundant String() call in licenseValidator.ts - Fix redundant type constituents in union types: - Remove unnecessary | undefined from optional property return types - Simplify BaseFullObjectType to avoid duplicate key union - Remove unused eslint-disable directives that are no longer needed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent bbb5e38 commit 68b9410

File tree

10 files changed

+14
-18
lines changed

10 files changed

+14
-18
lines changed

eslint.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'node:path';
2-
import { globalIgnores } from 'eslint/config';
2+
import { defineConfig, globalIgnores } from 'eslint/config';
33
import jest from 'eslint-plugin-jest';
44
import prettierRecommended from 'eslint-plugin-prettier/recommended';
55
import testingLibrary from 'eslint-plugin-testing-library';
@@ -16,7 +16,7 @@ const compat = new FlatCompat({
1616
allConfig: js.configs.all,
1717
});
1818

19-
const config = tsEslint.config([
19+
const config = defineConfig([
2020
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2121
includeIgnoreFile(path.resolve(__dirname, '.gitignore')),
2222
globalIgnores([

packages/react-on-rails-pro-node-renderer/src/shared/licenseValidator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export function getValidatedLicenseData(): LicenseData {
234234
*/
235235
export function isEvaluation(): boolean {
236236
const data = getValidatedLicenseData();
237-
const plan = String(data.plan || '');
237+
const plan = data.plan ?? '';
238238
return plan !== 'paid' && !plan.startsWith('paid_');
239239
}
240240

packages/react-on-rails-pro-node-renderer/src/worker/vm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export type RenderResult = string | Readable | { exceptionMessage: string };
7171
declare global {
7272
// This works on node 16+
7373
// https://stackoverflow.com/questions/35074713/extending-typescript-global-object-in-node-js/68328575#68328575
74-
// eslint-disable-next-line vars-on-top, no-var
74+
// eslint-disable-next-line vars-on-top
7575
var ReactOnRails: ROR | undefined;
7676
}
7777

packages/react-on-rails/src/base/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Fix: Use only react-on-rails OR react-on-rails-pro, not both.`);
167167
}
168168
},
169169

170-
option<K extends keyof ReactOnRailsOptions>(key: K): ReactOnRailsOptions[K] | undefined {
170+
option<K extends keyof ReactOnRailsOptions>(key: K): ReactOnRailsOptions[K] {
171171
return this.options[key];
172172
},
173173

packages/react-on-rails/src/base/full.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ export type ReactOnRailsFullSpecificFunctions = Pick<
2424
/**
2525
* Full object type that includes all base methods plus real SSR implementations.
2626
* Derived from ReactOnRailsInternal by picking base methods and SSR methods.
27+
* Note: BaseClientObjectType already includes serverRenderReactComponent and handleError,
28+
* so ReactOnRailsFullSpecificFunctions is a subset.
2729
* @public
2830
*/
29-
export type BaseFullObjectType = Pick<
30-
ReactOnRailsInternal,
31-
keyof BaseClientObjectType | keyof ReactOnRailsFullSpecificFunctions
32-
>;
31+
export type BaseFullObjectType = Pick<ReactOnRailsInternal, keyof BaseClientObjectType>;
3332

3433
export function createBaseFullObject(
3534
registries: Parameters<typeof createBaseClientObject>[0],

packages/react-on-rails/src/buildConsoleReplay.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare global {
1616
* @internal Exported for tests and for Ruby helper to wrap with nonce
1717
*/
1818
export function consoleReplay(
19-
customConsoleHistory: (typeof console)['history'] | undefined = undefined,
19+
customConsoleHistory: (typeof console)['history'] = undefined,
2020
numberOfMessagesToSkip = 0,
2121
): string {
2222
// console.history is a global polyfill used in server rendering.
@@ -54,9 +54,8 @@ export function consoleReplay(
5454
return lines.join('\n');
5555
}
5656

57-
/* eslint-disable default-param-last */
5857
export default function buildConsoleReplay(
59-
customConsoleHistory: (typeof console)['history'] | undefined = undefined,
58+
customConsoleHistory: (typeof console)['history'] = undefined,
6059
numberOfMessagesToSkip = 0,
6160
nonce?: string,
6261
): string {
@@ -66,4 +65,3 @@ export default function buildConsoleReplay(
6665
}
6766
return wrapInScriptTags('consoleReplayLog', consoleReplayJS, nonce);
6867
}
69-
/* eslint-enable default-param-last */

packages/react-on-rails/src/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { ReactOnRailsInternal, RailsContext } from './types/index.ts';
22

33
declare global {
4-
/* eslint-disable no-var,vars-on-top,no-underscore-dangle */
4+
/* eslint-disable vars-on-top,no-underscore-dangle */
55
var ReactOnRails: ReactOnRailsInternal | undefined;
66
var __REACT_ON_RAILS_EVENT_HANDLERS_RAN_ONCE__: boolean;
7-
/* eslint-enable no-var,vars-on-top,no-underscore-dangle */
7+
/* eslint-enable vars-on-top,no-underscore-dangle */
88
}
99

1010
let currentRailsContext: RailsContext | null = null;

packages/react-on-rails/src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ export interface ReactOnRailsInternal extends ReactOnRails {
362362
* @param key
363363
* @returns option value
364364
*/
365-
option<K extends keyof ReactOnRailsOptions>(key: K): ReactOnRailsOptions[K] | undefined;
365+
option<K extends keyof ReactOnRailsOptions>(key: K): ReactOnRailsOptions[K];
366366
/**
367367
* Allows retrieval of the store generator by name. This is used internally by ReactOnRails after
368368
* a Rails form loads to prepare stores.

react_on_rails/spec/dummy/client/app/components/HelloWorldRedux.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class HelloWorldRedux extends React.Component {
1919

2020
handleChange() {
2121
const name = this.nameDomRef.value;
22-
// eslint-disable-next-line react/destructuring-assignment
22+
2323
this.props.actions.updateName(name);
2424
}
2525

react_on_rails/spec/dummy/client/app/startup/HelloWorldES5.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const HelloWorldES5 = createReactClass({
1212
},
1313

1414
getInitialState() {
15-
// eslint-disable-next-line react/destructuring-assignment
1615
return this.props.helloWorldData;
1716
},
1817

0 commit comments

Comments
 (0)