generated from userscripters/template
-
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.
- Loading branch information
1 parent
7ae724f
commit ffcf691
Showing
25 changed files
with
110 additions
and
101 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
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
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
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import type { HeaderEntries } from "./index.js"; | ||
export type CustomHeaders = { | ||
contributors: string; | ||
} & { | ||
[name: string]: string; | ||
}; | ||
} & Record<string, string>; | ||
export declare const generateCustomHeaders: (custom: string[]) => HeaderEntries<CustomHeaders>; |
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
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
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export type LintOptions = { | ||
export interface LintOptions { | ||
fix?: boolean; | ||
isHomepageAllowed?: boolean; | ||
spaces?: number; | ||
}; | ||
export type LintResult = { | ||
} | ||
export interface LintResult { | ||
error: string; | ||
headers: string; | ||
}; | ||
} | ||
export declare const lintHeaders: (metadataBlock: string, options?: LintOptions) => Promise<LintResult>; |
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 |
---|---|---|
@@ -1,24 +1,25 @@ | ||
import { ESLint } from "eslint"; | ||
import { configs } from "eslint-plugin-userscripts"; | ||
import userscripts from "eslint-plugin-userscripts"; | ||
export const lintHeaders = async (metadataBlock, options = {}) => { | ||
const { fix = false, isHomepageAllowed = false, spaces = 4 } = options; | ||
const eslint = new ESLint({ | ||
baseConfig: { | ||
plugins: ["userscripts"], | ||
plugins: { userscripts }, | ||
rules: { | ||
...configs.recommended.rules, | ||
...userscripts.configs.recommended.rules, | ||
"userscripts/align-attributes": ["error", spaces], | ||
"userscripts/use-homepage-and-url": isHomepageAllowed ? "error" : "off", | ||
"userscripts/filename-user": "off", | ||
}, | ||
}, | ||
useEslintrc: false, | ||
overrideConfigFile: true, | ||
fix, | ||
}); | ||
const results = await eslint.lintText(metadataBlock); | ||
const [{ output }] = results; | ||
const formatter = await eslint.loadFormatter("stylish"); | ||
return { | ||
error: await formatter.format(results), | ||
headers: fix && output ? output : metadataBlock | ||
headers: fix && output ? output : metadataBlock, | ||
}; | ||
}; |
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
Oops, something went wrong.