Skip to content

Commit

Permalink
🐛 fix: small fixes for 5.2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Pauline <[email protected]>
  • Loading branch information
pauliesnug committed Jan 21, 2025
1 parent 5557108 commit a6a52d8
Show file tree
Hide file tree
Showing 47 changed files with 2,118 additions and 800 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ node_modules/

# Build Artifacts
dist/
docs/
test_out/
*.tsbuildinfo
*.zip
Expand All @@ -35,7 +34,6 @@ test_out/
*.heapsnapshot
*.log
coverage/
docs/

# Ignore package locks
package-lock.json
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@
],

"npm.packageManager": "pnpm",
"eslint.options": { "flags": ["unstable_ts_config"] }
}
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,30 @@
"meta:create": "pnpm turbo gen create-package --args"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.2",
"@arethetypeswrong/cli": "^0.17.3",
"@flowr/eslint": "workspace:^",
"@turbo/gen": "^2.3.3",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.10.5",
"@vitest/coverage-v8": "^2.1.8",
"@vitest/ui": "^2.1.8",
"bumpp": "^9.10.0",
"@types/node": "^22.10.7",
"@vitest/coverage-v8": "^3.0.2",
"@vitest/ui": "^3.0.2",
"bumpp": "^9.10.1",
"colorette": "^2.0.20",
"destr": "^2.0.3",
"esbuild": "^0.24.2",
"esbuild-plugin-file-path-extensions": "^2.1.4",
"eslint": "^9.17.0",
"eslint": "^9.18.0",
"jiti": "^2.4.2",
"jsdom": "^26.0.0",
"jsr": "^0.13.2",
"msw": "^2.7.0",
"pathe": "^2.0.1",
"pathe": "^2.0.2",
"tsup": "^8.3.5",
"tsx": "^4.19.2",
"turbo": "^2.3.3",
"typescript": "^5.7.3",
"vite": "^6.0.7",
"vitest": "^2.1.8"
"vite": "^6.0.10",
"vitest": "^3.0.2"
},
"pnpm": {
"patchedDependencies": {
Expand All @@ -87,9 +87,9 @@
},
"resolutions": {
"@eslint-community/eslint-utils": "^4.4.1",
"@typescript-eslint/utils": "^8.19.1",
"@typescript-eslint/utils": "^8.21.0",
"esbuild": "^0.24.2",
"eslint": "^9.17.0",
"eslint": "^9.18.0",
"tsx": "^4.19.2"
}
}
2 changes: 1 addition & 1 deletion packages/create-petal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "5.1.0",
"description": "A CLI utility to create a new Petal app",
"author": "@flowr",
"contributors": ["Pauline <[email protected]>"],
"contributors": ["Pauline <[email protected]>"],
"license": "(LicenseRef-OQL-1.2 OR MIT OR Apache-2.0)",
"funding": "https://ko-fi.com/pauliesnug",
"homepage": "https://petal.dyn.gay",
Expand Down
27 changes: 27 additions & 0 deletions packages/eslint-plugin/docs/consistent-chaining.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# consistent-chaining

Enforce consistent line breaks for chaining member access.

## Rule Details

<!-- eslint-skip -->
```js
// 👎 bad
const foo1 = [].map(x => x + 'bar')
.filter(Boolean);

const foo2 = []
.map(x => x + 'bar').filter(Boolean);
```

<!-- eslint-skip -->
```js
// 👍 good
const foo1 = [].map(x => x + 'bar').filter(Boolean);

const foo2 = []
.map(x => x + 'bar')
.filter(Boolean);
```

It will check the newline style of the **first** property access and apply the same style to the rest of the chaining access.
41 changes: 41 additions & 0 deletions packages/eslint-plugin/docs/consistent-list-newline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# consistent-list-newline

Enforce consistent line breaks inside braces of object/array/named imports/exports and function parameters.

## Rule Details

<!-- eslint-skip -->
```js
// 👎 bad
const foo = {
bar: 'baz', qux: 'quux',
fez: 'fum',
};
```

<!-- eslint-skip -->
```js
// 👍 good
const foo = {
bar: 'baz',
qux: 'quux',
fez: 'fum',
};

// 👍 good
const foo = { bar: 'baz', qux: 'quux', fez: 'fum' };
```

It will check the newline style of the **first** property or item and apply to the rest of the properties or items. So you can also use this rule to quite wrap / unwrap your code.

## Rule Conflicts

This rule might conflicts with the [object-curly-newline](https://eslint.org/docs/rules/object-curly-newline). You can turn if off.

```ts
export default {
rules: {
'object-curly-newline': 'off',
}
};
```
75 changes: 75 additions & 0 deletions packages/eslint-plugin/docs/file-header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# file-header

Simple file header that adds a copyright/license/message to the top of files.

Adapted from [`eslint-plugin-simple-header`](https://codeberg.org/rini/eslint-plugin-simple-header)

## Rule Details

Given the following configuration:

<!-- eslint-skip -->
```js
{
'petal/file-header': [
'error',
{
text: [
'Copyright (c) {year} {author}',
'SPDX-License-Identifier: GPL-3.0-or-later',
],
templates: { author: ['.*', 'author name' ] },
},
],
}
```

The rule will match a header like this:

<!-- eslint-skip -->
```text
/*
* Copyright (c) 1970 Linus Torvalds
* SPDX-License-Identifier GPL-3.0-or-later
*/
```

When running auto-fix, it will replace with the following header (where 2025 is the current year, if you are from the future):

<!-- eslint-skip -->
```text
/*
* Copyright (c) 2025 author name
* SPDX-License-Identifier GPL-3.0-or-later
*/
```

## Options

### `text`

This may be an array of lines, or an entire string. This can include comment syntax and won't be autoformatted (i.e. prefixed with `*`s).

### `files`

This is an array of paths, as an alternative to `text`. This can include comment syntax and won't be autoformatted (i.e. prefixed with `*`s).

### `templates`

Inside the header's text `{template}` snyntax can be used, which correlates to the `template` key. The first value is a regex used to match the header, and the second is a default value. By default, `{year}` matches `\d{4}` and defaults to the current year.

### `newlines`

Specifies exactly how many lines should be after the header, defaulting to `1`. If the file is empty otherwise, no newlines are added.

### `syntax`

Specifies the comment syntax, defaulting to `['/*', '*/']`. It can be different for different `files`, and may also be a string, for single-line comment blocks (e.g., `'//'`).

### `decor`

Specifies how the comment is formatted with a tuple of start, indent, and end. When `syntax` is a block comment, this defaults to `['\n', ' * ', '\n ']`, and defaults to `' '` otherwise.

### `linebreak`

Specifies the line ending to expect on files: `unix` for LF, `windows` for CRLF. By default, it uses `unix` or auto-detects based on the file.
18 changes: 18 additions & 0 deletions packages/eslint-plugin/docs/if-newline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# if-newline

Enforce line breaks between `if` statements and their consequent / alternate expressions. Only applicable for inline `if` statements.

## Rule Details

<!-- eslint-skip -->
```js
// 👎 bad
if (foo) bar();
```

<!-- eslint-skip -->
```js
// 👍 good
if (foo)
bar();
```
19 changes: 19 additions & 0 deletions packages/eslint-plugin/docs/import-dedupe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# import-dedupe

Auto-fix import deduplication.

## Rule Details

<!-- eslint-skip -->
```js
// 👎 bad
import { Foo, Bar, Foo } from 'foo';
```

Will be fixed to:

<!-- eslint-skip -->
```js
// 👍 good
import { Foo, Bar } from 'foo';
```
45 changes: 45 additions & 0 deletions packages/eslint-plugin/docs/indent-unindent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# indent-unindent

Enforce consistent indentation style for content inside template string with the `unindent` tag.

## Rule Details

<!-- eslint-skip -->
```js
// 👎 bad
import { unindent } from '@flowr/utilities';

const cases = [
unindent`
const foo = {
bar: 'baz', qux: 'quux',
fez: 'fum',
};`,
unindent`
if (true) {
console.log('hello');
}`,
];
```

<!-- eslint-skip -->
```js
// 👍 good
import { unindent } from '@flowr/utilties';

const cases = [
unindent`
const foo = {
bar: 'baz', qux: 'quux',
fez: 'fum',
};
`,
unindent`
if (true) {
console.log('hello');
}
`,
];
```

By default it affects the template tag named `unindent`, `unIndent` or `$`. This rule works specifically for the `unindent` utility function from `@flowr/utilities`, where the leading and trailing empty lines are removed, and the common indentation is removed from each line. This rule fixes the content inside the template string but shall not affect the runtime result.
67 changes: 67 additions & 0 deletions packages/eslint-plugin/docs/no-discard-result.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# no-discard-result

Disallow discarding the result of a function returning a `Result`.

## Rule Details

<!-- eslint-skip -->
```js
// 👎 bad
import { Result } from '@flowr/result';
function foo(): Promise<Result<string, string>> {}
null ?? foo();

// 👎 bad
import { Result } from '@flowr/result';
function foo(): Promise<Result<string, string>> {}
(foo(), await foo());

// 👎 bad
import { Result } from '@flowr/result';
async function foo(): Promise<Result<string, string>> {}
await foo();

// 👎 bad
import { Result } from '@flowr/result';
async function foo(): Promise<Result<string, string>> {}
foo();

// 👎 bad
import { Result } from '@flowr/result';
function foo(): Result<string, string> {}
foo();
```
<!-- eslint-skip -->
```js
// 👍 good
import { Result } from '@flowr/result';
function foo(): Result<string, string> {}
const x = foo();

// 👍 good
import { Result } from '@flowr/result';
function foo(): Result<string, string> {}
void foo();

// 👍 good
import { Result } from '@flowr/result';
function foo(): Result<string, string> {}
function bar(result: Result<string, string>) {}
void bar(foo());

// 👍 good
import { Result } from '@flowr/result';
function foo(): Result<string, string> {}
async function bar(): Promise<Result<string, string>> {}
let y = await bar(), z = (void 0, foo());
y = z = await bar();

// 👍 good
import { Result } from '@flowr/result';
function foo(): Result<string, string> {}
async function bar(): Promise<Result<string, string>> {}
const complex = foo() && (((Math.random() > 0.5 ? foo(): await bar()) || foo()) ?? await bar());
```
By default it affects the type named and with the shape of `Result<T, E, const Success extends boolean = boolean>`. This rule works only for the `Result` utility class from `@flowr/result`.
17 changes: 17 additions & 0 deletions packages/eslint-plugin/docs/no-import-dist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# no-import-dist

Prevent importing modules in `dist` folder.

## Rule Details

<!-- eslint-skip -->
```js
// 👎 bad
import { Foo, Bar, Foo } from '../dist/index.js';
```

<!-- eslint-skip -->
```js
// 👍 good
import { Foo, Bar } from './index.ts';
```
Loading

0 comments on commit a6a52d8

Please sign in to comment.