Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderniebuhr authored and astrobot-houston committed Oct 16, 2023
1 parent 57f0748 commit 937119e
Show file tree
Hide file tree
Showing 30 changed files with 1,324 additions and 1,180 deletions.
106 changes: 53 additions & 53 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
const { builtinModules } = require('module');
const { builtinModules } = require("module");

module.exports = {
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'prettier',
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"prettier",
],
parser: '@typescript-eslint/parser',
parser: "@typescript-eslint/parser",
parserOptions: {
project: ['./packages/*/tsconfig.json', './tsconfig.eslint.json'],
project: ["./packages/*/tsconfig.json", "./tsconfig.eslint.json"],
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint', 'prettier', 'no-only-tests'],
plugins: ["@typescript-eslint", "prettier", "no-only-tests"],
rules: {
// These off/configured-differently-by-default rules fit well for us
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
"@typescript-eslint/array-type": ["error", { default: "array-simple" }],
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", ignoreRestSiblings: true },
],
'no-only-tests/no-only-tests': 'error',
'@typescript-eslint/no-shadow': ['error'],
'no-console': 'warn',
"no-only-tests/no-only-tests": "error",
"@typescript-eslint/no-shadow": ["error"],
"no-console": "warn",

// Todo: do we want these?
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/class-literal-property-style': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/sort-type-constituents': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-explicit-any': 'off',
"@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/class-literal-property-style": "off",
"@typescript-eslint/consistent-indexed-object-style": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/prefer-optional-chain": "off",
"@typescript-eslint/prefer-string-starts-ends-with": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/sort-type-constituents": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-explicit-any": "off",

// These rules enabled by the preset configs don't work well for us
'@typescript-eslint/await-thenable': 'off',
'prefer-const': 'off',
"@typescript-eslint/await-thenable": "off",
"prefer-const": "off",
},
overrides: [
{
// Ensure Node builtins aren't included in Astro's server runtime
files: ['packages/astro/src/runtime/**/*.ts'],
files: ["packages/astro/src/runtime/**/*.ts"],
rules: {
'no-restricted-imports': [
'error',
"no-restricted-imports": [
"error",
{
paths: [...builtinModules],
patterns: ['node:*'],
patterns: ["node:*"],
},
],
},
},
{
files: ['packages/**/test/*.js', 'packages/**/*.js'],
files: ["packages/**/test/*.js", "packages/**/*.js"],
env: {
mocha: true,
},
globals: {
globalThis: false, // false means read-only
},
rules: {
'no-console': 'off',
"no-console": "off",
},
},
{
files: ['packages/integrations/**/*.ts'],
files: ["packages/integrations/**/*.ts"],
rules: {
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
"no-console": ["error", { allow: ["warn", "error", "info", "debug"] }],
},
},
{
files: ['benchmark/**/*.js'],
files: ["benchmark/**/*.js"],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'no-console': 'off',
"@typescript-eslint/no-unused-vars": "off",
"no-console": "off",
},
},
],
Expand Down
54 changes: 27 additions & 27 deletions packages/netlify/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@
can tell Astro if it can support it.

```ts
import { AstroIntegration } from './astro';
import { AstroIntegration } from "./astro";

function myIntegration(): AstroIntegration {
return {
name: 'astro-awesome-list',
name: "astro-awesome-list",
// new feature map
supportedAstroFeatures: {
hybridOutput: 'experimental',
staticOutput: 'stable',
serverOutput: 'stable',
hybridOutput: "experimental",
staticOutput: "stable",
serverOutput: "stable",
assets: {
supportKind: 'stable',
supportKind: "stable",
isSharpCompatible: false,
isSquooshCompatible: false,
},
Expand Down Expand Up @@ -176,18 +176,18 @@
can tell Astro if it can support it.

```ts
import { AstroIntegration } from './astro';
import { AstroIntegration } from "./astro";

function myIntegration(): AstroIntegration {
return {
name: 'astro-awesome-list',
name: "astro-awesome-list",
// new feature map
supportedAstroFeatures: {
hybridOutput: 'experimental',
staticOutput: 'stable',
serverOutput: 'stable',
hybridOutput: "experimental",
staticOutput: "stable",
serverOutput: "stable",
assets: {
supportKind: 'stable',
supportKind: "stable",
isSharpCompatible: false,
isSquooshCompatible: false,
},
Expand Down Expand Up @@ -303,11 +303,11 @@

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";

export default defineConfig({
output: 'server',
output: "server",
adapter: netlify(),
build: {
split: true,
Expand Down Expand Up @@ -558,14 +558,14 @@
The ability to customize SSR build configuration more granularly is now available in Astro. You can now customize the output folder for `server` (the server code for SSR), `client` (your client-side JavaScript and assets), and `serverEntry` (the name of the entrypoint server module). Here are the defaults:

```js
import { defineConfig } from 'astro/config';
import { defineConfig } from "astro/config";

export default defineConfig({
output: 'server',
output: "server",
build: {
server: './dist/server/',
client: './dist/client/',
serverEntry: 'entry.mjs',
server: "./dist/server/",
client: "./dist/client/",
serverEntry: "entry.mjs",
},
});
```
Expand All @@ -579,12 +579,12 @@
```js
export default function myIntegration() {
return {
name: 'my-integration',
name: "my-integration",
hooks: {
'astro:config:setup': ({ updateConfig }) => {
"astro:config:setup": ({ updateConfig }) => {
updateConfig({
build: {
server: '...',
server: "...",
},
});
},
Expand Down Expand Up @@ -629,12 +629,12 @@

```js
export function post({ cookies }) {
cookies.set('loggedIn', false);
cookies.set("loggedIn", false);

return new Response(null, {
status: 302,
headers: {
Location: '/login',
Location: "/login",
},
});
}
Expand Down Expand Up @@ -885,8 +885,8 @@
This change adds a Netlify adapter that uses Netlify Functions. You can use it like so:

```js
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";

export default defineConfig({
adapter: netlify(),
Expand Down
48 changes: 27 additions & 21 deletions packages/netlify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ If you prefer to install the adapter manually instead, complete the following tw
// astro.config.mjs
import { defineConfig } from 'astro/config';
+ import netlify from '@astrojs/netlify/functions';

export default defineConfig({
+ output: 'server',
+ adapter: netlify(),
Expand Down Expand Up @@ -86,9 +86,15 @@ In this example, `visitorCountry` and `hasEdgeMiddleware` would both be added to

```ts
// src/netlify-edge-middleware.ts
import type { Context } from 'https://edge.netlify.com';

export default function ({ request, context }: { request: Request; context: Context }) {
import type { Context } from "https://edge.netlify.com";

export default function ({
request,
context,
}: {
request: Request;
context: Context;
}) {
// Return serializable data to add to Astro.locals
return {
visitorCountry: context.geo.country.name,
Expand All @@ -112,11 +118,11 @@ The Netlify adapter builds to a single function by default. Astro 2.7 added supp

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";

export default defineConfig({
output: 'server',
output: "server",
adapter: netlify({
functionPerRoute: true,
}),
Expand All @@ -129,14 +135,14 @@ For static sites you usually don't need an adapter. However, if you use `redirec

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/static';
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/static";

export default defineConfig({
adapter: netlify(),

redirects: {
'/blog/old-post': '/blog/new-post',
"/blog/old-post": "/blog/new-post",
},
});
```
Expand Down Expand Up @@ -195,20 +201,20 @@ We build to the `dist` directory at the base of your project. To change this, us

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";

export default defineConfig({
output: 'server',
output: "server",
adapter: netlify({
dist: new URL('./dist/', import.meta.url),
dist: new URL("./dist/", import.meta.url),
}),
});
```
And then point to the dist in your `netlify.toml`:
```toml
```toml
# netlify.toml
[functions]
directory = "dist/functions"
Expand All @@ -220,11 +226,11 @@ You can enable On-demand Builders using the `builders` option:
```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";

export default defineConfig({
output: 'server',
output: "server",
adapter: netlify({
builders: true,
}),
Expand All @@ -243,16 +249,16 @@ We check for common mime types for audio, image, and video files. To include spe
```js
// src/pages/image.jpg.ts
import fs from 'node:fs';
import fs from "node:fs";

export function GET() {
const buffer = fs.readFileSync('../image.jpg');
const buffer = fs.readFileSync("../image.jpg");

// Return the buffer directly, @astrojs/netlify will base64 encode the body
return new Response(buffer, {
status: 200,
headers: {
'content-type': 'image/jpeg',
"content-type": "image/jpeg",
},
});
}
Expand Down
Loading

0 comments on commit 937119e

Please sign in to comment.