Skip to content

Commit 17897f4

Browse files
justin808claude
andcommitted
Fix ESLint violations in Pro packages
Fixes CI failures in Pro lint-js-and-ruby workflow by addressing: 1. Deprecated tsEslint.config() usage - migrated to flat config array 2. Unnecessary String() conversion in licenseValidator.ts 3. Unused eslint-disable directives in multiple files 4. Properly scoped type-checked rules to TypeScript files only Changes: - eslint.config.ts: Removed deprecated tsEslint.config() wrapper, properly spread arrays from compat.extends() and tsEslint.configs - licenseValidator.ts:237: Removed redundant String() call on already-string value - vm.ts:74: Removed unused 'no-var' from eslint-disable comment - buildConsoleReplay.ts:57,68: Removed unused default-param-last directives - context.ts:4: Removed unused 'no-var' from eslint-disable comment 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e5113c3 commit 17897f4

File tree

5 files changed

+29
-17
lines changed

5 files changed

+29
-17
lines changed

eslint.config.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const compat = new FlatCompat({
1616
allConfig: js.configs.all,
1717
});
1818

19-
const config = tsEslint.config([
19+
const config = [
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([
@@ -61,7 +61,7 @@ const config = tsEslint.config([
6161
files: ['**/*.[jt]s', '**/*.[jt]sx', '**/*.[cm][jt]s'],
6262
},
6363
js.configs.recommended,
64-
compat.extends('eslint-config-shakacode'),
64+
...compat.extends('eslint-config-shakacode'),
6565
{
6666
languageOptions: {
6767
globals: {
@@ -194,11 +194,19 @@ const config = tsEslint.config([
194194
'import/no-unresolved': 'off',
195195
},
196196
},
197+
...tsEslint.configs.strictTypeChecked.map((c) => {
198+
// Only apply type-checked rules to TypeScript files
199+
if (c.files) {
200+
return c;
201+
}
202+
return {
203+
...c,
204+
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
205+
};
206+
}),
197207
{
198208
files: ['**/*.ts{x,}', '**/*.[cm]ts'],
199209

200-
extends: tsEslint.configs.strictTypeChecked,
201-
202210
languageOptions: {
203211
parserOptions: {
204212
projectService: true,
@@ -278,14 +286,20 @@ const config = tsEslint.config([
278286
'react/no-deprecated': 'off',
279287
},
280288
},
289+
{
290+
...jest.configs['flat/recommended'],
291+
files: ['packages/*/tests/**', '**/*.test.{js,jsx,ts,tsx}'],
292+
},
293+
{
294+
...jest.configs['flat/style'],
295+
files: ['packages/*/tests/**', '**/*.test.{js,jsx,ts,tsx}'],
296+
},
297+
{
298+
...testingLibrary.configs['flat/dom'],
299+
files: ['packages/*/tests/**', '**/*.test.{js,jsx,ts,tsx}'],
300+
},
281301
{
282302
files: ['packages/*/tests/**', '**/*.test.{js,jsx,ts,tsx}'],
283-
284-
extends: [
285-
jest.configs['flat/recommended'],
286-
jest.configs['flat/style'],
287-
testingLibrary.configs['flat/dom'],
288-
],
289303

290304
rules: {
291305
// Allows Jest mocks before import
@@ -306,6 +320,6 @@ const config = tsEslint.config([
306320
// must be the last config in the array
307321
// https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#configuration-new-eslintconfigjs
308322
prettierRecommended,
309-
]);
323+
];
310324

311325
export default config;

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/buildConsoleReplay.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export function consoleReplay(
5454
return lines.join('\n');
5555
}
5656

57-
/* eslint-disable default-param-last */
5857
export default function buildConsoleReplay(
5958
customConsoleHistory: (typeof console)['history'] | undefined = undefined,
6059
numberOfMessagesToSkip = 0,
@@ -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;

0 commit comments

Comments
 (0)