Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run prettier on everything #745

Merged
merged 7 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 31 additions & 30 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,38 @@ module.exports = {
'@ephys/eslint-config-typescript/commonjs',
'plugin:mdx/recommended',
],
rules: {
// there are not supported enough in recent browsers to justify enforcing their usage
'prefer-object-has-own': 'off',
'unicorn/prefer-at': 'off',
'unicorn/prefer-string-replace-all': 'off',

'unicorn/prefer-spread': 'off',
'unicorn/no-useless-undefined': 'off',
},
overrides: [{
files: ['*.mdx/**', '*.md/**'],
rules: {
// these rules require proper type-checking and cannot be enabled on code snippets inside markdown files
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/prefer-includes': 'off',
'@typescript-eslint/prefer-readonly': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/require-array-sort-compare': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/consistent-type-exports': 'off',
'@typescript-eslint/prefer-return-this-type': 'off',
overrides: [
{
files: ['*.mdx/**', '*.md/**'],
rules: {
// these rules require proper type-checking and cannot be enabled on code snippets inside markdown files
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/prefer-includes': 'off',
'@typescript-eslint/prefer-readonly': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/require-array-sort-compare': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/consistent-type-exports': 'off',
'@typescript-eslint/prefer-return-this-type': 'off',
},
},
}],
{
files: ['*.d.ts', 'src/pages/*', 'src/theme/**/*'],
rules: {
// in .d.ts files, we don't really have a choice as it's dictated by the file that's being typed.
// For pages and theme files, docusaurus imposes the default export
'import/no-default-export': 'off',
},
},
],
ignorePatterns: [
// archives
'static/v1',
Expand Down
10 changes: 3 additions & 7 deletions .github/ISSUE_TEMPLATE/documentation_issue.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: 📗 Documentation Issue
about: Documentation is unclear, or otherwise insufficient/misleading, examples aren't working as expected
title: ""
labels: ""
assignees: ""
title: ''
labels: ''
assignees: ''
---

## Issue Description
Expand All @@ -14,12 +14,8 @@ Try to be as clear as possible. Don't assume that the maintainers will immediate

### What was unclear/insufficient/not covered in the documentation



### If possible: Provide some suggestion on how we can enhance the docs



### Additional context

<-- Add any other context or screenshots about the issue here. -->
5 changes: 2 additions & 3 deletions .github/workflows/draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ jobs:
node-version: 20.x
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn lint-no-fix
- run: yarn lint-scss-no-fix
- run: yarn typecheck
- run: yarn test:format
- run: yarn test:typings
- run: yarn sync
- run: yarn build
- name: Deploy to Draft to Netlify
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 20.x
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn lint-no-fix
- run: yarn typecheck
- run: yarn test:format
- run: yarn test:typings
- run: yarn sync
- run: yarn build
- name: Prepare Netlify dependencies
Expand Down
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.yarn
static/v5
static/v4
static/v3
static/v2
static/v1
5 changes: 4 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"singleQuote": true
"bracketSameLine": true,
"printWidth": 100,
"singleQuote": true,
"arrowParens": "avoid"
}
4 changes: 2 additions & 2 deletions docs/_fragments/_uuid-support-table.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { DialectTableFilter } from '@site/src/components/dialect-table-filter.ts
<DialectTableFilter>

| | PostgreSQL | MariaDB | MySQL | MSSQL | SQLite | Snowflake | db2 | ibmi |
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|--------|-----------|-----|------|
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ------ | --------- | --- | ---- |
| `uuidV1` | [`uuid_generate_v1`](https://www.postgresql.org/docs/current/uuid-ossp.html) (requires `uuid-ossp`) | [`UUID`](https://mariadb.com/kb/en/uuid/) | [`UUID`](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid) | N/A | N/A | N/A | N/A | N/A |
| `uuidV4` | __pg >= v13__: [`gen_random_uuid`](https://www.postgresql.org/docs/current/functions-uuid.html) <br/>__pg &lt; v13__: [`uuid_generate_v4`](https://www.postgresql.org/docs/current/uuid-ossp.html) (requires `uuid-ossp`) | N/A | N/A | [`NEWID`](https://learn.microsoft.com/en-us/sql/t-sql/functions/newid-transact-sql?view=sql-server-ver16) | N/A | N/A | N/A | N/A |
| `uuidV4` | **pg >= v13**: [`gen_random_uuid`](https://www.postgresql.org/docs/current/functions-uuid.html) <br/>**pg &lt; v13**: [`uuid_generate_v4`](https://www.postgresql.org/docs/current/uuid-ossp.html) (requires `uuid-ossp`) | N/A | N/A | [`NEWID`](https://learn.microsoft.com/en-us/sql/t-sql/functions/newid-transact-sql?view=sql-server-ver16) | N/A | N/A | N/A | N/A |

</DialectTableFilter>
10 changes: 5 additions & 5 deletions docs/associations/association-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ SELECT * FROM `restaurants` WHERE `restaurants`.`status` = 'open' AND `restauran

## BelongsToMany scope

All associations support specifying a scope to filter the target model, but the `BelongsToMany` association
All associations support specifying a scope to filter the target model, but the `BelongsToMany` association
also supports specifying a scope to filter the join table. This is useful when you want to filter based on extra information
stored in the join table.

Expand All @@ -71,7 +71,7 @@ class Person extends Model {}
class Game extends Model {
/** This association will list everyone that worked on the game */
@BelongsToMany(() => Person, {
through: GameAuthor
through: GameAuthor,
})
allAuthors;
}
Expand All @@ -89,10 +89,10 @@ class Game extends Model {
otherKey: 'personId',
})
allAuthors;

/** This association will list everyone that worked on the game as a programmer */
@BelongsToMany(() => Person, {
through: {
through: {
model: GameAuthor,
foreignKey: 'gameId',
otherKey: 'personId',
Expand All @@ -101,7 +101,7 @@ class Game extends Model {
},
})
programmers;

/** This association will list everyone that worked on the game as a designer */
@BelongsToMany(() => Person, {
through: {
Expand Down
16 changes: 8 additions & 8 deletions docs/associations/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ title: Basics

# Association Basics

Sequelize provides what are called __associations__.
These can be declared on your models to define common [__relationships__](https://en.wikipedia.org/wiki/Cardinality_(data_modeling)) between your tables.
Sequelize provides what are called **associations**.
These can be declared on your models to define common [**relationships**](<https://en.wikipedia.org/wiki/Cardinality_(data_modeling)>) between your tables.

The two concepts are closely related, but not the same. __Associations__ are defined in JavaScript between your _models_, while
__relationships__ are defined in your database between your _tables_.
The two concepts are closely related, but not the same. **Associations** are defined in JavaScript between your _models_, while
**relationships** are defined in your database between your _tables_.

Sequelize supports the standard associations: [One-To-One](https://en.wikipedia.org/wiki/One-to-one_%28data_model%29), [One-To-Many](https://en.wikipedia.org/wiki/One-to-many_%28data_model%29) and [Many-To-Many](https://en.wikipedia.org/wiki/Many-to-many_%28data_model%29).

## One-to-one Relationships

In a One-To-One relationship, a row of one table is associated with a single row of another table.
In a One-To-One relationship, a row of one table is associated with a single row of another table.

The most common type of One-To-One relationship is one where one side is mandatory, and the other side is optional.
For instance, a driving license always belongs to a single person, but a person can have zero or one driving licenses <small>(from the same place)</small>.
Expand All @@ -25,7 +25,7 @@ erDiagram
people ||--o| driving_licenses : drivingLicense
```

One-To-One relationships can be created by using __the [`HasOne`](./has-one.md) association__.
One-To-One relationships can be created by using **the [`HasOne`](./has-one.md) association**.

## One-to-many Relationships

Expand All @@ -38,7 +38,7 @@ erDiagram
people ||--o{ cities : birthplace
```

One-To-Many relationships can be created by using __the [`HasMany`](./has-many.md) association__.
One-To-Many relationships can be created by using **the [`HasMany`](./has-many.md) association**.

## Many-to-many Relationships

Expand All @@ -51,4 +51,4 @@ erDiagram
people }o--o{ toots : likedToots
```

Many-To-Many relationships can be created by using __the [`BelongsToMany`](./belongs-to-many.md) association__.
Many-To-Many relationships can be created by using **the [`BelongsToMany`](./belongs-to-many.md) association**.
51 changes: 32 additions & 19 deletions docs/associations/belongs-to-many.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: BelongsToMany

# The BelongsToMany Association

The BelongsToMany association is used to create a [Many-To-Many relationship](https://en.wikipedia.org/wiki/Many-to-many_(data_model)) between two models.
The BelongsToMany association is used to create a [Many-To-Many relationship](<https://en.wikipedia.org/wiki/Many-to-many_(data_model)>) between two models.

In a Many-To-Many relationship, a row of one table is associated with _zero, one or more_ rows of another table, and vice versa.

Expand All @@ -16,7 +16,7 @@ erDiagram
people }o--o{ toots : likedToots
```

Because foreign keys can only point to a single row, Many-To-Many relationships are implemented using a junction table (called __through table__ in Sequelize), and are
Because foreign keys can only point to a single row, Many-To-Many relationships are implemented using a junction table (called **through table** in Sequelize), and are
really just two One-To-Many relationships.

```mermaid
Expand Down Expand Up @@ -54,7 +54,7 @@ and will receive the two foreign keys: `userId` and `tootId`.

:::caution String `through` option

The `through` option is used to specify the through __model__, not the through __table__.
The `through` option is used to specify the through **model**, not the through **table**.
We recommend that you follow the same naming conventions as other models (i.e. PascalCase & singular):

```ts
Expand All @@ -72,11 +72,17 @@ class Person extends Model<InferAttributes<Person>, InferCreationAttributes<Pers

## Customizing the Junction Table

The junction table can be customized by creating the model yourself, and passing it to the `through` option.
The junction table can be customized by creating the model yourself, and passing it to the `through` option.
This is useful if you want to add additional attributes to the junction table.

```ts
import { Model, DataTypes, InferAttributes, InferCreationAttributes, NonAttribute } from '@sequelize/core';
import {
Model,
DataTypes,
InferAttributes,
InferCreationAttributes,
NonAttribute,
} from '@sequelize/core';
import { BelongsToMany, Attribute, NotNull } from '@sequelize/core/decorators-legacy';
import { PrimaryKey } from './attribute.js';

Expand Down Expand Up @@ -150,7 +156,7 @@ erDiagram
Person }o--o{ Toot : "⬇️ likedToots / ⬆️ likers"
```

Their names are automatically generated based on the name of the BelongsToMany association,
Their names are automatically generated based on the name of the BelongsToMany association,
and the name of its inverse association.

You can customize the names of these associations by using the `throughAssociations` options:
Expand All @@ -167,11 +173,11 @@ class Person extends Model<InferAttributes<Person>, InferCreationAttributes<Pers
// 1️⃣ The name of the association going from the source model (Person)
// to the through model (LikedToot)
fromSource: 'likedTootsLikers',
// 2️⃣ The name of the association going from the through model (LikedToot)

// 2️⃣ The name of the association going from the through model (LikedToot)
// to the source model (Person)
toSource: 'liker',

// 3️⃣ The name of the association going from the target model (Toot)
// to the through model (LikedToot)
fromTarget: 'likersLikedToots',
Expand All @@ -188,8 +194,8 @@ class Person extends Model<InferAttributes<Person>, InferCreationAttributes<Pers

## Foreign Keys Names

Sequelize will generate foreign keys automatically based on the names of your associations.
It is the name of your association + the name of the attribute the association is pointing to (which defaults to the primary key).
Sequelize will generate foreign keys automatically based on the names of your associations.
It is the name of your association + the name of the attribute the association is pointing to (which defaults to the primary key).

In the example above, the foreign keys would be `likerId` and `likedTootId`, because the associations are called `likedToots` and `likers`,
and the primary keys referenced by the foreign keys are both called `id`.
Expand Down Expand Up @@ -220,7 +226,7 @@ class Person extends Model<InferAttributes<Person>, InferCreationAttributes<Pers
By default, Sequelize will use the primary key of the source & target models as the attribute the foreign key references.
You can customize this by using the `sourceKey` & `targetKey` option.

The `sourceKey` option is the attribute from the model on which the association is defined,
The `sourceKey` option is the attribute from the model on which the association is defined,
and the `targetKey` is the attribute from the target model.

```ts
Expand All @@ -243,7 +249,7 @@ class Person extends Model<InferAttributes<Person>, InferCreationAttributes<Pers

## Through Pair Unique Constraint

The BelongsToMany association creates a unique key on the foreign keys of the through model.
The BelongsToMany association creates a unique key on the foreign keys of the through model.

This unique key name can be changed using the `through.unique` option. You can also set it to `false` to disable the unique constraint altogether.

Expand Down Expand Up @@ -337,7 +343,10 @@ There are two versions of this method:
- `add<PluralAssociationName>`: Associates multiple new models.

```ts
import { BelongsToManyAddAssociationMixin, BelongsToManyAddAssociationsMixin } from '@sequelize/core';
import {
BelongsToManyAddAssociationMixin,
BelongsToManyAddAssociationsMixin,
} from '@sequelize/core';

class Author extends Model<InferAttributes<Author>, InferCreationAttributes<Author>> {
@BelongsToMany(() => Book, { through: 'BookAuthor' })
Expand Down Expand Up @@ -386,9 +395,11 @@ There are two versions of this method:
- `remove<SingularAssociationName>`: Removes a single associated model.
- `remove<PluralAssociationName>`: Removes multiple associated models.


```ts
import { BelongsToManyRemoveAssociationMixin, BelongsToManyRemoveAssociationsMixin } from '@sequelize/core';
import {
BelongsToManyRemoveAssociationMixin,
BelongsToManyRemoveAssociationsMixin,
} from '@sequelize/core';

class Author extends Model<InferAttributes<Author>, InferCreationAttributes<Author>> {
@BelongsToMany(() => Book, { through: 'BookAuthor' })
Expand Down Expand Up @@ -462,8 +473,7 @@ In the example above, we did not need to specify the `postId` attribute. This is
If you use TypeScript, you need to let TypeScript know that the foreign key is not required. You can do so using the second generic argument of the `BelongsToManyCreateAssociationMixin` type.

```ts
BelongsToManyCreateAssociationMixin<Book, 'postId'>
^ Here
BelongsToManyCreateAssociationMixin<Book, 'postId'> ^ Here;
```

:::
Expand All @@ -476,7 +486,10 @@ The association checker is used to check if a model is associated with another m
- `has<PluralAssociationName>`: Checks whether all the specified models are associated.

```ts
import { BelongsToManyHasAssociationMixin, BelongsToManyHasAssociationsMixin } from '@sequelize/core';
import {
BelongsToManyHasAssociationMixin,
BelongsToManyHasAssociationsMixin,
} from '@sequelize/core';

class Author extends Model<InferAttributes<Author>, InferCreationAttributes<Author>> {
@BelongsToMany(() => Book, { through: 'BookAuthor' })
Expand Down
Loading
Loading