GPTScript / AiScript

A Minimal, Full-Stack, Tool-Assisted Language. Native to Browsers and Bun. Strictly & Strongly-Typed.
https://github.com/GPTScript/AiScript
Mozilla Public License 2.0
9 stars 1 forks source link

sort requires by type, alphabetically #16

Open coolaj86 opened 2 years ago

coolaj86 commented 2 years ago

Goal: create an eslint or other plugin that will automatically sort requires alphabetically.

Good Example

Modules group by "native-ness", listed alphabetically by require path.

// exports
let MyPkg = exports;

// ENVs
let debug = process.env.DEBUG;

// built-in & "AJ Std" modules
let Crypto = require("crypto");
let sleep = require("sleep");

// 1st party modules
let Coins = require("./lib/coins.js").Coins;
let Wallet = require("./lib/wallet.js").Wallet;

// 3rd party modules
let request = require("@root/require").require;

Bad Example

// bogo sort

let Wallet = require("./lib/wallet.js").Wallet;
let request = require("@root/require").require;
let debug = process.env.DEBUG;
let Crypto = require("crypto");
let MyPkg = exports;
let sleep = require("sleep");
let Coins = require("./lib/coins.js").Coins;

cc/ @wmerfalen

wmerfalen commented 2 years ago

This appears to be what we're after https://eslint.org/docs/developer-guide/working-with-custom-formatters

wmerfalen commented 2 years ago

@coolaj86 can you modify the description of this issue to reflect what the before and after code should look like? I am having a hard time understanding what the description is supposed to represent

coolaj86 commented 2 years ago

@wmerfalen done.