Skip to content

Commit

Permalink
✨ feature(eslint-plugin): add new file-header rule
Browse files Browse the repository at this point in the history
Signed-off-by: Pauline <[email protected]>
  • Loading branch information
pauliesnug committed Aug 28, 2024
1 parent 8d62f1b commit 72b194e
Show file tree
Hide file tree
Showing 8 changed files with 272 additions and 172 deletions.
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import noTsExportEqual from './rules/no-ts-export-equal';
import consistentListNewline from './rules/consistent-list-newline';
import indentUnindent from './rules/indent-unindent';
import onlyExportComponents from './rules/only-export-components';
import fileHeader from './rules/file-header';
import type { RuleModule } from './utils';

const plugin = {
Expand All @@ -20,6 +21,7 @@ const plugin = {
/// @keep-sorted
rules: {
'consistent-list-newline': consistentListNewline,
'file-header': fileHeader,
'if-newline': ifNewline,
'import-dedupe': importDedupe,
'indent-unindent': indentUnindent,
Expand Down
28 changes: 28 additions & 0 deletions packages/eslint-plugin/src/rules/file-header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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

```ts
type PetalFileHeader = [] | [(({
syntax?: string;
decor?: string;
[k: string]: unknown | undefined;
} | {

syntax?: [string, string];

decor?: [string, string, string];
[k: string]: unknown | undefined;
}) & ({

files: [string, ...string[]];
[k: string]: unknown | undefined;
} | {
text: (string | string[]);
[k: string]: unknown | undefined;
}))];
```
7 changes: 7 additions & 0 deletions packages/eslint-plugin/src/rules/file-header.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { run } from './_test';
import rule, { RULE_NAME } from './file-header';

run({
name: RULE_NAME,
rule,
});
Loading

0 comments on commit 72b194e

Please sign in to comment.