Skip to content

Commit

Permalink
chore: add rule switch-exhaustiveness-check (#9867)
Browse files Browse the repository at this point in the history
* chore: add rule `switch-exhaustiveness-check`

* apply feedback

* routing is always defined
  • Loading branch information
ematipico committed Jan 30, 2024
1 parent 44c957f commit bcc504d
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
plugins: ['@typescript-eslint', 'prettier', 'no-only-tests'],
rules: {
// These off/configured-differently-by-default rules fit well for us
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-unused-vars': [
'warn',
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/assets/services/squoosh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ async function getRotationForEXIF(
case 7:
case 8:
return { type: 'rotate', numRotations: 3 };
default:
return undefined;
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/cli/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ export async function add(names: string[], { flags }: AddOptions) {
case UpdateResult.failure: {
throw createPrettyError(new Error(`Unable to install dependencies`));
}
case UpdateResult.none:
break;
}

const rawConfigPath = await resolveConfigPath({
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export type SSRManifest = {

export type SSRManifestI18n = {
fallback?: Record<string, string>;
routing?: RoutingStrategies;
routing: RoutingStrategies;
locales: Locales;
defaultLocale: string;
};
Expand Down
3 changes: 3 additions & 0 deletions packages/astro/src/preferences/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export function coerce(key: string, value: unknown) {
case 'boolean': {
if (value === 'true' || value === 1) return true;
if (value === 'false' || value === 0) return false;
break;
}
default:
throw new Error(`Incorrect value for ${key}`);
}
return value as any;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ export default {
astroToggle.input.addEventListener('change', setting.changeEvent);
astroToggle.input.checked = settings.config[setting.settingKey];
label.append(astroToggle);
break;
}
default:
break;
}

return label;
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/runtime/server/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export function getPrescripts(result: SSRResult, type: PrescriptType, directive:
)};${islandScript}</script>`;
case 'directive':
return `<script>${getDirectiveScriptText(result, directive)}</script>`;
case null:
break;
}
return '';
}
1 change: 0 additions & 1 deletion packages/astro/src/vite-plugin-astro/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { HoistedScript, TransformResult } from '@astrojs/compiler';
import type { PropagationHint } from '../@types/astro.js';
import type { CompileAstroResult } from './compile.js';

export interface PageOptions {
prerender?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/node/test/encoded.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as assert from 'node:assert/strict';
import { describe, it, before, after } from 'node:test';
import { describe, it, before } from 'node:test';
import nodejs from '../dist/index.js';
import { loadFixture, createRequestAndResponse } from './test-utils.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/node/test/headers.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as assert from 'node:assert/strict';
import { describe, it, before, after } from 'node:test';
import { describe, it, before } from 'node:test';
import nodejs from '../dist/index.js';
import { loadFixture, createRequestAndResponse } from './test-utils.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/node/test/locals.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as assert from 'node:assert/strict';
import { describe, it, before, after } from 'node:test';
import { describe, it, before } from 'node:test';
import nodejs from '../dist/index.js';
import { loadFixture, createRequestAndResponse } from './test-utils.js';

Expand Down

0 comments on commit bcc504d

Please sign in to comment.