0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

chore: add rule switch-exhaustiveness-check (#9867)

* chore: add rule `switch-exhaustiveness-check`

* apply feedback

* routing is always defined
This commit is contained in:
Emanuele Stoppa 2024-01-30 08:35:08 +00:00 committed by GitHub
parent 44c957f893
commit bcc504dae0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 17 additions and 5 deletions

View file

@ -16,6 +16,7 @@ module.exports = {
plugins: ['@typescript-eslint', 'prettier', 'no-only-tests'], plugins: ['@typescript-eslint', 'prettier', 'no-only-tests'],
rules: { rules: {
// These off/configured-differently-by-default rules fit well for us // 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/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-unused-vars': [ '@typescript-eslint/no-unused-vars': [
'warn', 'warn',

View file

@ -48,6 +48,8 @@ async function getRotationForEXIF(
case 7: case 7:
case 8: case 8:
return { type: 'rotate', numRotations: 3 }; return { type: 'rotate', numRotations: 3 };
default:
return undefined;
} }
} }

View file

@ -211,6 +211,8 @@ export async function add(names: string[], { flags }: AddOptions) {
case UpdateResult.failure: { case UpdateResult.failure: {
throw createPrettyError(new Error(`Unable to install dependencies`)); throw createPrettyError(new Error(`Unable to install dependencies`));
} }
case UpdateResult.none:
break;
} }
const rawConfigPath = await resolveConfigPath({ const rawConfigPath = await resolveConfigPath({

View file

@ -60,7 +60,7 @@ export type SSRManifest = {
export type SSRManifestI18n = { export type SSRManifestI18n = {
fallback?: Record<string, string>; fallback?: Record<string, string>;
routing?: RoutingStrategies; routing: RoutingStrategies;
locales: Locales; locales: Locales;
defaultLocale: string; defaultLocale: string;
}; };

View file

@ -66,7 +66,10 @@ export function coerce(key: string, value: unknown) {
case 'boolean': { case 'boolean': {
if (value === 'true' || value === 1) return true; if (value === 'true' || value === 1) return true;
if (value === 'false' || value === 0) return false; if (value === 'false' || value === 0) return false;
break;
} }
default:
throw new Error(`Incorrect value for ${key}`);
} }
return value as any; return value as any;
} }

View file

@ -161,7 +161,10 @@ export default {
astroToggle.input.addEventListener('change', setting.changeEvent); astroToggle.input.addEventListener('change', setting.changeEvent);
astroToggle.input.checked = settings.config[setting.settingKey]; astroToggle.input.checked = settings.config[setting.settingKey];
label.append(astroToggle); label.append(astroToggle);
break;
} }
default:
break;
} }
return label; return label;

View file

@ -42,6 +42,8 @@ export function getPrescripts(result: SSRResult, type: PrescriptType, directive:
)};${islandScript}</script>`; )};${islandScript}</script>`;
case 'directive': case 'directive':
return `<script>${getDirectiveScriptText(result, directive)}</script>`; return `<script>${getDirectiveScriptText(result, directive)}</script>`;
case null:
break;
} }
return ''; return '';
} }

View file

@ -1,6 +1,5 @@
import type { HoistedScript, TransformResult } from '@astrojs/compiler'; import type { HoistedScript, TransformResult } from '@astrojs/compiler';
import type { PropagationHint } from '../@types/astro.js'; import type { PropagationHint } from '../@types/astro.js';
import type { CompileAstroResult } from './compile.js';
export interface PageOptions { export interface PageOptions {
prerender?: boolean; prerender?: boolean;

View file

@ -1,5 +1,5 @@
import * as assert from 'node:assert/strict'; 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 nodejs from '../dist/index.js';
import { loadFixture, createRequestAndResponse } from './test-utils.js'; import { loadFixture, createRequestAndResponse } from './test-utils.js';

View file

@ -1,5 +1,5 @@
import * as assert from 'node:assert/strict'; 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 nodejs from '../dist/index.js';
import { loadFixture, createRequestAndResponse } from './test-utils.js'; import { loadFixture, createRequestAndResponse } from './test-utils.js';

View file

@ -1,5 +1,5 @@
import * as assert from 'node:assert/strict'; 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 nodejs from '../dist/index.js';
import { loadFixture, createRequestAndResponse } from './test-utils.js'; import { loadFixture, createRequestAndResponse } from './test-utils.js';