-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pauline <[email protected]>
- Loading branch information
1 parent
5557108
commit a6a52d8
Showing
47 changed files
with
2,118 additions
and
800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,5 +49,4 @@ | |
], | ||
|
||
"npm.packageManager": "pnpm", | ||
"eslint.options": { "flags": ["unstable_ts_config"] } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
} | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
``` |
Oops, something went wrong.