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:
parent
44c957f893
commit
bcc504dae0
11 changed files with 17 additions and 5 deletions
|
@ -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',
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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({
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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 '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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';
|
||||||
|
|
||||||
|
|
|
@ -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';
|
||||||
|
|
||||||
|
|
|
@ -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';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue