Skip to content

Commit 7b1c428

Browse files
committed
add linting
1 parent d4bf990 commit 7b1c428

24 files changed

+3676
-631
lines changed

.vscode/settings.json

+50-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,54 @@
22
"typescript.tsdk": "node_modules/typescript/lib",
33
"files.insertFinalNewline": true,
44
"files.trimFinalNewlines": true,
5-
"files.trimTrailingWhitespace": true
5+
"files.trimTrailingWhitespace": true,
6+
// Disable the default formatter, use eslint instead
7+
"prettier.enable": false,
8+
"editor.formatOnSave": false,
9+
10+
// Auto fix
11+
"editor.codeActionsOnSave": {
12+
"source.fixAll.eslint": "explicit",
13+
"source.organizeImports": "never"
14+
},
15+
16+
// Silent the stylistic rules in you IDE, but still auto fix them
17+
"eslint.rules.customizations": [
18+
{ "rule": "style/*", "severity": "off", "fixable": true },
19+
{ "rule": "format/*", "severity": "off", "fixable": true },
20+
{ "rule": "*-indent", "severity": "off", "fixable": true },
21+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
22+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
23+
{ "rule": "*-order", "severity": "off", "fixable": true },
24+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
25+
{ "rule": "*-newline", "severity": "off", "fixable": true },
26+
{ "rule": "*quotes", "severity": "off", "fixable": true },
27+
{ "rule": "*semi", "severity": "off", "fixable": true }
28+
],
29+
30+
// Enable eslint for all supported languages
31+
"eslint.validate": [
32+
"javascript",
33+
"javascriptreact",
34+
"typescript",
35+
"typescriptreact",
36+
"vue",
37+
"html",
38+
"markdown",
39+
"json",
40+
"json5",
41+
"jsonc",
42+
"yaml",
43+
"toml",
44+
"xml",
45+
"gql",
46+
"graphql",
47+
"astro",
48+
"svelte",
49+
"css",
50+
"less",
51+
"scss",
52+
"pcss",
53+
"postcss"
54+
]
655
}

CONTRIBUTING.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# Contributing Guide
2+
23
If you get stuck, message me on discord `@samualn`.
34

45
## Requirements
6+
57
- [Git](https://git-scm.com/)
68
- **Windows:** Make sure you install Git Bash with it
79
- [Clone this repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
810
- [PNPM](https://pnpm.io/)
911
- **Optional:** [`direnv`](https://direnv.net/)
1012

1113
## Linux Users
14+
1215
1. Open this cloned repository in a terminal
1316
2. Run `pnpm install`
1417
3. Modify your `PATH`
@@ -17,21 +20,26 @@ If you get stuck, message me on discord `@samualn`.
1720
4. Run `scripts/package.sh` to compile everything and build the NPM package in `dist`
1821

1922
## Windows Users
23+
2024
1. Open this cloned repository in Git Bash
2125
2. Run `pnpm install`
2226
3. Run `export PATH=$PWD/node_modules/.bin:$PATH`
2327
4. Run `scripts/package.sh` to compile everything and build the NPM package in `dist`
2428

2529
## Tips and Tricks
30+
2631
Run `./rollup.config.js` to only recompile.
2732

2833
### Run the Development Version of HSM
34+
2935
You can run the development version of HSM by running `node dist/bin/hsm.js`. You can pass it arguments just like you normally would e.g. `node dist/bin/hsm.js --version`.
3036

3137
### Install the Development Version of the NPM Package in Another Project
38+
3239
In the other project (e.g. testing with Hackmud Scripting Environment) run `pnpm add ~/path/to/hackmud-script-manager/dist`.
3340

3441
## Tests
42+
3543
Tests can be run by running `vitest run` (assuming you have followed above setup instructions).
3644

3745
There is currently not enforcement on writing unit tests but if you are going to, the test you write MUST be failing.

README.md

+44-38
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Hackmud Script Manager
2+
23
Command made for [Hackmud Scripting Environment](https://github.com/samualtnorman/hackmud-environment), which is a scripting environment for hackmud with minification, autocompletes / intellisense, and TypeScript support.
34

45
Join [our Discord server](https://discord.gg/RSa4Sc6pNA)!
@@ -8,66 +9,71 @@ Join [our Discord server](https://discord.gg/RSa4Sc6pNA)!
89
You can read about how HSM works [in my blog post](https://samual.uk/blog/js-code-transformation-niche-environment/).
910

1011
## Install
12+
1113
1. [Install Node.js](https://nodejs.org/en/download)
1214
2. Run `npm install -g hackmud-script-manager`
1315

1416
## Usage
17+
1518
1. Run `#dir` in game, then `cd` to that folder
1619
2. Name your source script file to `<name>.src.js`
1720
3. Run `hsm minify <name>.src.js` and it will create a minified script file called `<name>.js`
1821

1922
> **NOTE:** If you get an error message that looks like this:
23+
>
2024
> ```
2125
> [...]\AppData\Local\pnpm\hsm.ps1 cannot be loaded because running scripts is disabled on this system. [...]
2226
> ```
27+
>
2328
> You will need to run `Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser` in PowerShell as an administrator. For more information, see [Microsoft's page about Execution Policies](https://learn.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4).
2429
2530
![image](https://github.com/user-attachments/assets/cc97f8a6-82a4-4a66-9785-accc8d774285)
2631
![image](https://github.com/user-attachments/assets/d0ec9450-4e16-4f8d-82b2-734deaf5abe3)
2732
![image](https://github.com/user-attachments/assets/a59a6ec4-d268-40f7-8ce2-5fbdbcd40c19)
2833
2934
## Features
35+
3036
- Minification
31-
- This includes auto quine cheating.
32-
- Supported types are null, numbers, strings, and JSON compatible objects and arrays.
33-
- Non JSON compatible object keys are quine cheated.
34-
- Member expressions are converted to index notation so the index string can be quine cheated.
35-
- And template literals are converted to string concatenation so the strings can be quine cheated.
36-
- Global variable aliasing.
37-
- Convert function declarations to arrow function assigned to variable hoisted to the top of the block (`function foo() { ... }` -> `let foo = () => ...`).
38-
- Convert `_START` and `_TIMEOUT` to `_ST` and `_TO`.
39-
- Remove unused parameters from the main function expression.
37+
- This includes auto quine cheating.
38+
- Supported types are null, numbers, strings, and JSON compatible objects and arrays.
39+
- Non JSON compatible object keys are quine cheated.
40+
- Member expressions are converted to index notation so the index string can be quine cheated.
41+
- And template literals are converted to string concatenation so the strings can be quine cheated.
42+
- Global variable aliasing.
43+
- Convert function declarations to arrow function assigned to variable hoisted to the top of the block (`function foo() { ... }` -> `let foo = () => ...`).
44+
- Convert `_START` and `_TIMEOUT` to `_ST` and `_TO`.
45+
- Remove unused parameters from the main function expression.
4046
- Modern Javascript Syntax and Features
41-
- [Exponentiation Operator](https://babeljs.io/docs/en/babel-plugin-transform-exponentiation-operator), [Object Rest Spread](https://babeljs.io/docs/en/babel-plugin-proposal-object-rest-spread), [Optional Catch Binding](https://babeljs.io/docs/en/babel-plugin-proposal-optional-catch-binding), [JSON strings](https://babeljs.io/docs/en/babel-plugin-proposal-json-strings), [Nullish Coalescing Operator](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator), [Optional Chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining), [Logical Assignment Operators](https://babeljs.io/docs/en/babel-plugin-proposal-logical-assignment-operators), [Numeric Seperators](https://babeljs.io/docs/en/babel-plugin-proposal-numeric-separator), [Class Properties](https://babeljs.io/docs/en/babel-plugin-proposal-class-properties), [Class Static Block](https://babeljs.io/docs/en/babel-plugin-proposal-class-static-block), [Private Property `in` Object](https://babeljs.io/docs/en/babel-plugin-proposal-private-property-in-object).
42-
- Bigint literals are converted to `BigInt()` calls.
43-
- Hackmud already supports all modern regular expression features.
47+
- [Exponentiation Operator](https://babeljs.io/docs/en/babel-plugin-transform-exponentiation-operator), [Object Rest Spread](https://babeljs.io/docs/en/babel-plugin-proposal-object-rest-spread), [Optional Catch Binding](https://babeljs.io/docs/en/babel-plugin-proposal-optional-catch-binding), [JSON strings](https://babeljs.io/docs/en/babel-plugin-proposal-json-strings), [Nullish Coalescing Operator](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator), [Optional Chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining), [Logical Assignment Operators](https://babeljs.io/docs/en/babel-plugin-proposal-logical-assignment-operators), [Numeric Seperators](https://babeljs.io/docs/en/babel-plugin-proposal-numeric-separator), [Class Properties](https://babeljs.io/docs/en/babel-plugin-proposal-class-properties), [Class Static Block](https://babeljs.io/docs/en/babel-plugin-proposal-class-static-block), [Private Property `in` Object](https://babeljs.io/docs/en/babel-plugin-proposal-private-property-in-object).
48+
- Bigint literals are converted to `BigInt()` calls.
49+
- Hackmud already supports all modern regular expression features.
4450
- Future JavaScript Syntax and Features
45-
- Warning: TypeScript doesn't support any of these features and these features may change or not actually make it into JavaScript.
46-
- [Decorators](https://babeljs.io/docs/en/babel-plugin-proposal-decorators), [Do Expressions](https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions), [Function Bind](https://babeljs.io/docs/en/babel-plugin-proposal-function-bind), [Function Sent](https://babeljs.io/docs/en/babel-plugin-proposal-function-sent), [Partial Application](https://babeljs.io/docs/en/babel-plugin-proposal-partial-application), [Pipeline Operator](https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator) (using the hack proposal and `%` as the topic token), [Throw Expression](https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions), [Record and Tuple](https://babeljs.io/docs/en/babel-plugin-proposal-record-and-tuple) (hash `#` syntax type).
51+
- Warning: TypeScript doesn't support any of these features and these features may change or not actually make it into JavaScript.
52+
- [Decorators](https://babeljs.io/docs/en/babel-plugin-proposal-decorators), [Do Expressions](https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions), [Function Bind](https://babeljs.io/docs/en/babel-plugin-proposal-function-bind), [Function Sent](https://babeljs.io/docs/en/babel-plugin-proposal-function-sent), [Partial Application](https://babeljs.io/docs/en/babel-plugin-proposal-partial-application), [Pipeline Operator](https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator) (using the hack proposal and `%` as the topic token), [Throw Expression](https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions), [Record and Tuple](https://babeljs.io/docs/en/babel-plugin-proposal-record-and-tuple) (hash `#` syntax type).
4753
- TypeScript Support
48-
- This command/module does **not** do type checking, it simply removes type annotations so you'll need to rely on your IDE or run `tsc` seperatly with `noEmit`.
54+
- This command/module does **not** do type checking, it simply removes type annotations so you'll need to rely on your IDE or run `tsc` seperatly with `noEmit`.
4955
- And “Cool” Unnecessary Features.
50-
- Variables declared outside the main function expression automatically become `#G` global variables.
51-
- Any code outside the function expression will only run once per top level script execution (`#FMCL`).
52-
- Basic seclevel verification.
53-
- Declaring `// @seclevel HIGHSEC` or any other seclevel before all of your code stops you from accidentally using `#ls.` or `#ns.`.
54-
- Import `node_modules` modules into your script using `import { foo } from "bar"` syntax.
55-
- `_SOURCE` is replaced with a string of the source code of the script it's in.
56-
- `_BUILD_DATE` is replaced with a unix timestamp (`Date.now()`) of the build date of the script.
57-
- `_SCRIPT_USER` is replaced with a string of the user the script was pushed to.
58-
- This saves characters compared to `context.this_script.split(".")[0]`.
59-
- `_SCRIPT_SUBNAME` is like `_SCRIPT_USER` but for the name of the script.
60-
- Saves characters compared to `context.this_script.split(".")[1]`.
61-
- `_FULL_SCRIPT_NAME` is replaced with what would be in `context.this_script`.
62-
- Subscript and `#db` methods names are verified.
63-
- All references to preprocessor syntax functions not being called are turned into arrow function wrappers e.g. `let debug = #D;` -> `let debug = v => #D(v);`.
64-
- `_SECLEVEL` is replaced with a number (`0` to `4`) representing the seclevel of the script.
56+
- Variables declared outside the main function expression automatically become `#G` global variables.
57+
- Any code outside the function expression will only run once per top level script execution (`#FMCL`).
58+
- Basic seclevel verification.
59+
- Declaring `// @seclevel HIGHSEC` or any other seclevel before all of your code stops you from accidentally using `#ls.` or `#ns.`.
60+
- Import `node_modules` modules into your script using `import { foo } from "bar"` syntax.
61+
- `_SOURCE` is replaced with a string of the source code of the script it's in.
62+
- `_BUILD_DATE` is replaced with a unix timestamp (`Date.now()`) of the build date of the script.
63+
- `_SCRIPT_USER` is replaced with a string of the user the script was pushed to.
64+
- This saves characters compared to `context.this_script.split(".")[0]`.
65+
- `_SCRIPT_SUBNAME` is like `_SCRIPT_USER` but for the name of the script.
66+
- Saves characters compared to `context.this_script.split(".")[1]`.
67+
- `_FULL_SCRIPT_NAME` is replaced with what would be in `context.this_script`.
68+
- Subscript and `#db` methods names are verified.
69+
- All references to preprocessor syntax functions not being called are turned into arrow function wrappers e.g. `let debug = #D;` -> `let debug = v => #D(v);`.
70+
- `_SECLEVEL` is replaced with a number (`0` to `4`) representing the seclevel of the script.
6571
- And Neat Weird Fixes
66-
- Like `.__proto__` and `.prototype` being converted to `["__proto__"]` and `["prototype"]`.
67-
- Illegal and unsafe strings.
68-
- Appearences of `_SC` and friends are either renamed or have an escape inserted so that script is legal.
69-
- Preprocessor syntax in strings are escaped so hackmud doesn't recognise them as preprocessor syntax.
70-
- And appearences of `//` in strings and regexes have a backslash inserted between to stop hackmud's overagressive comment remover from removing half the line of code.
71-
- Classes are actually usable now, this module replaces instances of `this` with a variable referencing what would be `this`.
72-
- `Function.prototype` can be referenced (but only the `.prototype` property, nothing else).
73-
- `Object.getPrototypeOf` and `Object.setPrototypeOf` are replaced with equivalent functions.
72+
- Like `.__proto__` and `.prototype` being converted to `["__proto__"]` and `["prototype"]`.
73+
- Illegal and unsafe strings.
74+
- Appearences of `_SC` and friends are either renamed or have an escape inserted so that script is legal.
75+
- Preprocessor syntax in strings are escaped so hackmud doesn't recognise them as preprocessor syntax.
76+
- And appearences of `//` in strings and regexes have a backslash inserted between to stop hackmud's overagressive comment remover from removing half the line of code.
77+
- Classes are actually usable now, this module replaces instances of `this` with a variable referencing what would be `this`.
78+
- `Function.prototype` can be referenced (but only the `.prototype` property, nothing else).
79+
- `Object.getPrototypeOf` and `Object.setPrototypeOf` are replaced with equivalent functions.

0 commit comments

Comments
 (0)