ESLint plugin
This project is maintained by iliubinskii
ESLint plugin / sort-statements
Sorts statements.
StatementType =
| "Declare"
| "DeclareGlobal"
| "ExportAllDeclaration"
| "ExportDeclaration"
| "ExportDefaultDeclaration"
| "ExportFunctionDeclaration"
| "ExportTypeDeclaration"
| "ExportUnknown"
| "FunctionDeclaration"
| "ImportDeclaration"
| "JestTest"
| "TypeDeclaration"
| "Unknown";
module.exports = {
plugins: ["misc"],
rules: {
"misc/sort-statements": [
"error",
{
blockOrder: StatementType[],
moduleOrder: StatementType[],
order: StatementType[],
programOrder: StatementType[]
}
]
}
};
Option | Description | Default |
---|---|---|
blockOrder |
Order inside block statement | [] |
moduleOrder |
Order inside module declaration | [] |
order |
Default order | [] |
programOrder |
Root statements order | [] |
function f() {}
type T1 = number;
const x1 = true;
const x2 = true;
export function g() {}
export type T2 = number;
export const x3 = true;
export const x4 = true;
export * from "source";
declare global {}
import "source";
import "source";
declare global {}
export * from "source";
export const x1 = true;
export const x2 = true;
export type T1 = number;
export function f() {}
const x3 = true;
const x4 = true;
type T2 = number;
function g() {}