isaacscript 1.2.45 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/.cspell-base.json +38 -0
  2. package/.cspell-check-unused.json +7 -0
  3. package/.cspell.json +51 -35
  4. package/.eslintrc.js +14 -10
  5. package/.gitattributes +3 -3
  6. package/.github/workflows/ci.yml +3 -4
  7. package/.prettierignore +5 -0
  8. package/.prettierrc.js +19 -5
  9. package/.vscode/extensions.json +2 -3
  10. package/.vscode/settings.json +26 -15
  11. package/README.md +3 -3
  12. package/build.sh +2 -2
  13. package/check-file-updates.sh +56 -0
  14. package/check-gitignore.sh +26 -0
  15. package/check-orphaned-words.sh +53 -0
  16. package/dist/package.json +6 -6
  17. package/dist/src/checkForWindowsTerminalBugs.js +8 -7
  18. package/dist/src/checkForWindowsTerminalBugs.js.map +1 -1
  19. package/dist/src/commands/init/createMod.js +13 -8
  20. package/dist/src/commands/init/createMod.js.map +1 -1
  21. package/dist/src/commands/init/getModsDir.js +4 -5
  22. package/dist/src/commands/init/getModsDir.js.map +1 -1
  23. package/dist/src/commands/init/getProjectPath.js +5 -5
  24. package/dist/src/commands/init/getProjectPath.js.map +1 -1
  25. package/dist/src/commands/init/git.js +2 -2
  26. package/dist/src/commands/init/git.js.map +1 -1
  27. package/dist/src/commands/init/promptSaveSlot.js +3 -4
  28. package/dist/src/commands/init/promptSaveSlot.js.map +1 -1
  29. package/dist/src/commands/init/promptVSCode.js +1 -2
  30. package/dist/src/commands/init/promptVSCode.js.map +1 -1
  31. package/dist/src/commands/monitor/copyWatcherMod.js +9 -11
  32. package/dist/src/commands/monitor/copyWatcherMod.js.map +1 -1
  33. package/dist/src/commands/monitor/monitor.js +3 -4
  34. package/dist/src/commands/monitor/monitor.js.map +1 -1
  35. package/dist/src/commands/monitor/notifyGame.js +3 -3
  36. package/dist/src/commands/monitor/notifyGame.js.map +1 -1
  37. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +8 -8
  38. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
  39. package/dist/src/exec.js +2 -3
  40. package/dist/src/exec.js.map +1 -1
  41. package/dist/src/file.js +16 -1
  42. package/dist/src/file.js.map +1 -1
  43. package/dist/src/prompt.js +5 -7
  44. package/dist/src/prompt.js.map +1 -1
  45. package/dist/src/utils.js +1 -1
  46. package/dist/src/validateNodeVersion.js +4 -3
  47. package/dist/src/validateNodeVersion.js.map +1 -1
  48. package/eslint-debug.sh +8 -0
  49. package/file-templates/dynamic/README.md +2 -2
  50. package/file-templates/dynamic/main.ts +7 -5
  51. package/file-templates/dynamic/metadata.vdf +1 -1
  52. package/file-templates/dynamic/metadata.xml +3 -3
  53. package/file-templates/dynamic/package.json +1 -1
  54. package/file-templates/static/.cspell-check-unused.json +9 -0
  55. package/file-templates/static/.cspell.json.template +9 -0
  56. package/file-templates/static/.eslintrc.js +11 -10
  57. package/file-templates/static/.gitattributes +3 -3
  58. package/file-templates/static/.github/workflows/ci.yml +4 -5
  59. package/file-templates/static/.prettierignore +10 -1
  60. package/file-templates/static/.prettierrc.js +19 -5
  61. package/file-templates/static/.vscode/extensions.json +2 -3
  62. package/file-templates/static/.vscode/settings.json +26 -14
  63. package/file-templates/static/build.sh +2 -2
  64. package/file-templates/static/check-orphaned-words.sh +53 -0
  65. package/file-templates/static/lint.sh +17 -16
  66. package/file-templates/static/nuke.sh +1 -1
  67. package/file-templates/static/publish.sh +1 -1
  68. package/file-templates/static/run.sh +1 -1
  69. package/file-templates/static/src/bundleEntry.ts +4 -4
  70. package/file-templates/static/tsconfig.eslint.json +3 -3
  71. package/file-templates/static/tsconfig.json +8 -10
  72. package/file-templates/static/update.sh +1 -1
  73. package/file-templates/static-alt/.cspell-base.json +38 -0
  74. package/file-templates/static-alt/.cspell-check-unused-base.json +7 -0
  75. package/file-templates/static-alt/.prettierignore-base +5 -0
  76. package/file-templates/static-alt/.prettierrc-base.js +29 -0
  77. package/file-templates/static-alt/.vscode/extensions-typescript.json +9 -0
  78. package/file-templates/static-alt/.vscode/settings-typescript.json +63 -0
  79. package/isaacscript-watcher/README.md +3 -2
  80. package/isaacscript-watcher/main.lua +31 -41
  81. package/lint.sh +19 -16
  82. package/nuke.sh +1 -1
  83. package/package.json +6 -6
  84. package/publish.sh +1 -1
  85. package/src/checkForWindowsTerminalBugs.ts +8 -7
  86. package/src/commands/init/createMod.ts +14 -8
  87. package/src/commands/init/getModsDir.ts +4 -5
  88. package/src/commands/init/getProjectPath.ts +5 -5
  89. package/src/commands/init/git.ts +2 -2
  90. package/src/commands/init/promptSaveSlot.ts +3 -4
  91. package/src/commands/init/promptVSCode.ts +1 -2
  92. package/src/commands/monitor/copyWatcherMod.ts +9 -11
  93. package/src/commands/monitor/monitor.ts +3 -4
  94. package/src/commands/monitor/notifyGame.ts +3 -3
  95. package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +8 -8
  96. package/src/exec.ts +2 -3
  97. package/src/file.ts +25 -0
  98. package/src/prompt.ts +5 -7
  99. package/src/utils.ts +1 -1
  100. package/src/validateNodeVersion.ts +5 -4
  101. package/tsconfig.eslint.json +3 -3
  102. package/tsconfig.json +9 -11
  103. package/update.sh +1 -1
  104. package/file-templates/static/.cspell.json +0 -11
package/dist/src/utils.js CHANGED
@@ -35,7 +35,7 @@ function isKebabCase(s) {
35
35
  }
36
36
  exports.isKebabCase = isKebabCase;
37
37
  /**
38
- * parseIntSafe is a more reliable version of parseInt. By default, "parseInt('1a')" will return
38
+ * `parseIntSafe` is a more reliable version of `parseInt`. By default, "parseInt('1a')" will return
39
39
  * "1", which is unexpected. This returns either an integer or NaN.
40
40
  */
41
41
  function parseIntSafe(input) {
@@ -8,9 +8,10 @@ const chalk_1 = __importDefault(require("chalk"));
8
8
  const constants_1 = require("./constants");
9
9
  const utils_1 = require("./utils");
10
10
  const REQUIRED_NODE_JS_MAJOR_VERSION = 16;
11
- // This program requires Node to be at least v16.0.0,
12
- // since that is the version that added the "fs.rmSync()" function
13
- // (I tested on Node v15.0.0 and it failed)
11
+ /**
12
+ * This program requires Node to be at least v16.0.0, since that is the version that added the
13
+ * "fs.rmSync" function. (Node v15.0.0 is confirmed to not work.)
14
+ */
14
15
  function validateNodeVersion() {
15
16
  const { version } = process;
16
17
  const [majorVersion] = (0, utils_1.parseSemVer)(version);
@@ -1 +1 @@
1
- {"version":3,"file":"validateNodeVersion.js","sourceRoot":"","sources":["../../src/validateNodeVersion.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2CAA2C;AAC3C,mCAAsC;AAEtC,MAAM,8BAA8B,GAAG,EAAE,CAAC;AAE1C,qDAAqD;AACrD,kEAAkE;AAClE,2CAA2C;AAC3C,SAAgB,mBAAmB;IACjC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,CAAC,YAAY,CAAC,GAAG,IAAA,mBAAW,EAAC,OAAO,CAAC,CAAC;IAE5C,IAAI,YAAY,IAAI,8BAA8B,EAAE;QAClD,OAAO;KACR;IAED,OAAO,CAAC,KAAK,CAAC,4BAA4B,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,KAAK,CACX,GAAG,wBAAY,kCAAkC,eAAK,CAAC,GAAG,CACxD,GAAG,8BAA8B,MAAM,CACxC,cAAc,CAChB,CAAC;IACF,OAAO,CAAC,KAAK,CACX,uDAAuD,wBAAY,GAAG,CACvE,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAlBD,kDAkBC"}
1
+ {"version":3,"file":"validateNodeVersion.js","sourceRoot":"","sources":["../../src/validateNodeVersion.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2CAA2C;AAC3C,mCAAsC;AAEtC,MAAM,8BAA8B,GAAG,EAAE,CAAC;AAE1C;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE5B,MAAM,CAAC,YAAY,CAAC,GAAG,IAAA,mBAAW,EAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,YAAY,IAAI,8BAA8B,EAAE;QAClD,OAAO;KACR;IAED,OAAO,CAAC,KAAK,CAAC,4BAA4B,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,KAAK,CACX,GAAG,wBAAY,kCAAkC,eAAK,CAAC,GAAG,CACxD,GAAG,8BAA8B,MAAM,CACxC,cAAc,CAChB,CAAC;IACF,OAAO,CAAC,KAAK,CACX,uDAAuD,wBAAY,GAAG,CACvE,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAlBD,kDAkBC"}
package/eslint-debug.sh CHANGED
@@ -1,3 +1,11 @@
1
1
  #!/bin/bash
2
2
 
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ cd "$DIR"
10
+
3
11
  npx eslint --print-config ./src/main.ts > debug.txt
@@ -1,3 +1,3 @@
1
- # MOD_NAME_TO_REPLACE
1
+ # MOD-NAME-TO-REPLACE
2
2
 
3
- MOD_NAME_TO_REPLACE is a mod for *[The Binding of Isaac: Repentance](https://store.steampowered.com/app/1426300/The_Binding_of_Isaac_Repentance/)*, written in [TypeScript](https://www.typescriptlang.org/) using the [IsaacScript](https://isaacscript.github.io/) framework.
3
+ MOD-NAME-TO-REPLACE is a mod for _[The Binding of Isaac: Repentance](https://store.steampowered.com/app/1426300/The_Binding_of_Isaac_Repentance/)_, written in [TypeScript](https://www.typescriptlang.org/) using the [IsaacScript](https://isaacscript.github.io/) framework.
@@ -1,14 +1,16 @@
1
- const MOD_NAME = "MOD_NAME_TO_REPLACE";
1
+ import { ModCallback } from "isaac-typescript-definitions";
2
+
3
+ const MOD_NAME = "MOD-NAME-TO-REPLACE";
2
4
 
3
5
  export function main(): void {
4
6
  // Instantiate a new mod object, which grants the ability to add callback functions that
5
- // correspond to in-game events
7
+ // correspond to in-game events.
6
8
  const mod = RegisterMod(MOD_NAME, 1);
7
9
 
8
- // Set a callback function that corresponds to when a new run is started
9
- mod.AddCallback(ModCallbacks.MC_POST_GAME_STARTED, postGameStarted);
10
+ // Set a callback function that corresponds to when a new run is started.
11
+ mod.AddCallback(ModCallback.POST_GAME_STARTED, postGameStarted);
10
12
 
11
- // Print an initialization message to the "log.txt" file
13
+ // Print an initialization message to the "log.txt" file.
12
14
  Isaac.DebugString(`${MOD_NAME} initialized.`);
13
15
  }
14
16
 
@@ -2,5 +2,5 @@
2
2
  {
3
3
  "appid" "250900"
4
4
  "publishedfileid" ""
5
- "contentfolder" "MOD_TARGET_DIR"
5
+ "contentfolder" "MOD-TARGET-DIR"
6
6
  }
@@ -1,9 +1,9 @@
1
1
  <?xml version="1.0" encoding="UTF-8" ?>
2
2
  <metadata>
3
- <name>MOD_NAME_TO_REPLACE</name>
4
- <directory>MOD_NAME_TO_REPLACE</directory>
3
+ <name>MOD-NAME-TO-REPLACE</name>
4
+ <directory>MOD-NAME-TO-REPLACE</directory>
5
5
  <description>
6
- MOD_NAME_TO_REPLACE is a currently a work in progress.
6
+ MOD-NAME-TO-REPLACE is a currently a work in progress.
7
7
  </description>
8
8
  <version>1.0</version>
9
9
  <visibility />
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "MOD_NAME_TO_REPLACE",
2
+ "name": "MOD-NAME-TO-REPLACE",
3
3
  "version": "0.0.1",
4
4
  "description": "A mod for The Binding of Isaac: Repentance",
5
5
  "keywords": [
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
3
+ "version": "0.2",
4
+ "import": [
5
+ "./node_modules/isaac-typescript-definitions/.cspell-isaacscript.json"
6
+ ],
7
+ "files": ["**"],
8
+ "ignorePaths": [".cspell-temp.json", ".git/**", "dist/**", "node_modules/**"]
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
3
+ "version": "0.2",
4
+ "import": [
5
+ "./node_modules/isaac-typescript-definitions/.cspell-isaacscript.json"
6
+ ],
7
+ "files": ["**"],
8
+ "ignorePaths": [".git/**", "dist/**", "node_modules/**", "main.lua"]
9
+ }
@@ -1,23 +1,24 @@
1
- // This is the configuration file for ESLint, the TypeScript linter
1
+ // This is the configuration file for ESLint, the TypeScript linter:
2
2
  // https://eslint.org/docs/user-guide/configuring
3
3
  module.exports = {
4
4
  extends: [
5
- // The linter base is the IsaacScript mod config
6
- // https://github.com/IsaacScript/eslint-config-isaacscript/blob/main/mod.js
5
+ /**
6
+ * The linter base is the IsaacScript mod config:
7
+ * https://github.com/IsaacScript/eslint-config-isaacscript/blob/main/mod.js
8
+ */
7
9
  "eslint-config-isaacscript/mod",
8
10
  ],
9
11
 
10
12
  parserOptions: {
11
- // ESLint needs to know about the project's TypeScript settings in order for TypeScript-specific
12
- // things to lint correctly
13
- // We do not point this at "./tsconfig.json" because certain files (such at this file) should be
14
- // linted but not included in the actual project output
13
+ /**
14
+ * ESLint needs to know about the project's TypeScript settings in order for TypeScript-specific
15
+ * things to lint correctly. We do not point this at "./tsconfig.json" because certain files
16
+ * (such at this file) should be linted but not included in the actual project output.
17
+ */
15
18
  project: "./tsconfig.eslint.json",
16
19
  },
17
20
 
18
- // We modify the linting rules from the base for some specific things
19
- // (listed in alphabetical order)
20
21
  rules: {
21
- // Insert changed or disabled rules here, if necessary
22
+ // Insert changed or disabled rules here, if necessary.
22
23
  },
23
24
  };
@@ -1,9 +1,9 @@
1
- # Prevent Windows systems from cloning this repository with "\r\n" line endings
1
+ # Prevent Windows systems from cloning this repository with "\r\n" line endings.
2
2
  core.autocrlf=false
3
3
 
4
- # Prevent people from making merge commits
4
+ # Prevent people from making merge commits:
5
5
  # https://www.endoflineblog.com/gitflow-considered-harmful
6
6
  pull.rebase=true
7
7
 
8
- # Convert all files to use "\n" line endings
8
+ # Convert all files to use "\n" line endings.
9
9
  * text=auto eol=lf
@@ -12,9 +12,8 @@ jobs:
12
12
  - name: Setup Node.js
13
13
  uses: actions/setup-node@v2
14
14
  with:
15
- # The default version is 14
16
- # The ESLint config requires Node 16 to work properly
17
- node-version: '16'
15
+ # The default version is 14. The ESLint config requires Node 16 to work properly.
16
+ node-version: "16"
18
17
 
19
18
  - name: Retrieve the cached "node_modules" directory (if present)
20
19
  uses: actions/cache@v2
@@ -37,12 +36,12 @@ jobs:
37
36
  run: bash lint.sh
38
37
 
39
38
  # To enable CI failure notifications over Discord, add a "DISCORD_WEBHOOK" secret to the
40
- # repository equal to the URL for the webhook, and then uncomment the lines below
39
+ # repository equal to the URL for the webhook, and then uncomment the lines below.
41
40
 
42
41
  #discord:
43
42
  # name: Discord Failure Notification
44
43
  # needs: [build_and_lint]
45
- # if: always() # This is needed to always run this job, even if the other jobs fail
44
+ # if: always() # This is needed to always run this job, even if the other jobs fail.
46
45
  # runs-on: ubuntu-latest
47
46
  # steps:
48
47
  # - uses: technote-space/workflow-conclusion-action@v2
@@ -1,5 +1,14 @@
1
- # Ignore all of the XML files created by Basement Renovator
1
+ # Ignore compiled output.
2
+ dist
3
+
4
+ # The VSCode CSpell plugin causes the file to become unformatted whenever a new word is added.
5
+ .cspell.json
6
+
7
+ # Ignore all of the XML files created by Basement Renovator.
2
8
  mod/content/rooms/**/*.xml
3
9
  mod/content/luarooms/**/*.xml
4
10
  mod/resources/rooms/**/*.xml
5
11
  mod/resources/luarooms/**/*.xml
12
+
13
+ # Ignore all of the XML files created by the animation editor.
14
+ mod/resources/**/*.anm2
@@ -1,10 +1,9 @@
1
- // This is the configuration file for Prettier, the auto-formatter
1
+ // This is the configuration file for Prettier, the auto-formatter:
2
2
  // https://prettier.io/docs/en/configuration.html
3
3
  module.exports = {
4
4
  // https://prettier.io/docs/en/options.html#trailing-commas
5
5
  // The default is "es5" - Trailing commas where valid in ES5 (objects, arrays, etc.)
6
- // However, always having trailing commas is objectively better
7
- // The Airbnb style guide agrees:
6
+ // However, always having trailing commas is objectively better. The Airbnb style guide agrees:
8
7
  // https://github.com/airbnb/javascript#commas--dangling
9
8
  // Prettier itself also acknowledges Nik Graf's blog in their official blog:
10
9
  // https://prettier.io/blog/2020/03/21/2.0.0.html
@@ -13,8 +12,23 @@ module.exports = {
13
12
  // https://github.com/prettier/prettier/issues/9369
14
13
  trailingComma: "all",
15
14
 
15
+ // We want to always use "lf" to be consistent with all platforms.
16
+ endOfLine: "lf",
17
+
18
+ // Allow proper formatting of JSONC files:
19
+ // https://github.com/prettier/prettier/issues/5708
20
+ overrides: [
21
+ {
22
+ files: ["**/.vscode/*.json", "**/tsconfig.json", "**/tsconfig.*.json"],
23
+ options: {
24
+ parser: "json5",
25
+ quoteProps: "preserve",
26
+ },
27
+ },
28
+ ],
29
+
16
30
  // https://github.com/prettier/plugin-xml#configuration
17
- // The default is "struct"
18
- // However, whitespace cannot be reformatted unless this is set to "ignore"
31
+ // The default is "struct".
32
+ // Whitespace cannot be reformatted unless this is set to "ignore".
19
33
  xmlWhitespaceSensitivity: "ignore",
20
34
  };
@@ -1,11 +1,10 @@
1
1
  // These are Visual Studio Code extensions that are intended to be used with this particular
2
- // repository
3
- // https://go.microsoft.com/fwlink/?LinkId=827846
2
+ // repository: https://go.microsoft.com/fwlink/?LinkId=827846
4
3
  {
5
4
  "recommendations": [
6
5
  "esbenp.prettier-vscode", // The TypeScript formatter
7
6
  "dbaeumer.vscode-eslint", // The TypeScript linter
8
7
  "streetsidesoftware.code-spell-checker", // A spell-checker extension based on cspell
9
8
  "typescript-to-lua.vscode-typescript-to-lua", // The TypeScriptToLua extension
10
- ]
9
+ ],
11
10
  }
@@ -1,10 +1,10 @@
1
- // These are Visual Studio Code settings that should apply to this particular repository
1
+ // These are Visual Studio Code settings that should apply to this particular repository.
2
2
  {
3
3
  // ----------------
4
4
  // Vanilla settings
5
5
  // ----------------
6
6
 
7
- // This matches the Airbnb JavaScript style guide
7
+ // This matches the Airbnb JavaScript style guide.
8
8
  "editor.rulers": [100],
9
9
  "editor.tabSize": 2,
10
10
 
@@ -13,40 +13,52 @@
13
13
  "*.dat": "json", // Nearly all mods save JSON to the "save#.dat" file
14
14
  },
15
15
 
16
- // Linux line endings are used in this project
16
+ // Linux line endings are used in this project.
17
17
  "files.eol": "\n",
18
18
 
19
- // Automatically removing all trailing whitespace when saving a file
19
+ // Automatically removing all trailing whitespace when saving a file.
20
20
  "files.trimTrailingWhitespace": true,
21
21
 
22
- // Configure glob patterns for excluding files and folders in full text searches and quick open
22
+ // Configure glob patterns for excluding files and folders in full text searches and quick open.
23
23
  "search.exclude": {
24
24
  "**/mod/main.lua": true,
25
25
  "**/*.png": true,
26
26
  "**/*.wav": true,
27
+ "dist/**": true,
27
28
  },
28
29
 
29
30
  // -----------------
30
31
  // Language settings
31
32
  // -----------------
32
33
 
33
- // By default, VSCode will not automatically fill-in function arguments
34
+ // By default, VSCode will not automatically fill-in function arguments.
34
35
  "javascript.suggest.completeFunctionCalls": true,
35
36
  "typescript.suggest.completeFunctionCalls": true,
36
37
 
37
- // Automatically run the formatter when certain files are saved
38
+ // Automatically run the formatter when certain files are saved.
38
39
  "[javascript]": {
39
- "editor.codeActionsOnSave": [
40
- "source.fixAll.eslint",
41
- ],
40
+ "editor.codeActionsOnSave": ["source.fixAll.eslint"],
42
41
  "editor.defaultFormatter": "esbenp.prettier-vscode",
43
42
  "editor.formatOnSave": true,
44
43
  "editor.tabSize": 2,
45
44
  },
46
45
  "[typescript]": {
47
- "editor.codeActionsOnSave": [
48
- "source.fixAll.eslint",
49
- ],
46
+ "editor.codeActionsOnSave": ["source.fixAll.eslint"],
47
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
48
+ "editor.formatOnSave": true,
49
+ "editor.tabSize": 2,
50
+ },
51
+ "[json]": {
52
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
53
+ "editor.formatOnSave": true,
54
+ "editor.tabSize": 2,
55
+ },
56
+ "[jsonc]": {
57
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
58
+ "editor.formatOnSave": true,
59
+ "editor.tabSize": 2,
60
+ },
61
+ "[yaml]": {
50
62
  "editor.defaultFormatter": "esbenp.prettier-vscode",
51
63
  "editor.formatOnSave": true,
52
64
  "editor.tabSize": 2,
@@ -54,7 +66,7 @@
54
66
  "[markdown]": {
55
67
  "editor.defaultFormatter": "esbenp.prettier-vscode",
56
68
  "editor.formatOnSave": true,
57
- "editor.tabSize": 2
69
+ "editor.tabSize": 2,
58
70
  },
59
71
  "[xml]": {
60
72
  "editor.defaultFormatter": "esbenp.prettier-vscode",
@@ -2,13 +2,13 @@
2
2
 
3
3
  set -e # Exit on any errors
4
4
 
5
- # Get the directory of this script
5
+ # Get the directory of this script:
6
6
  # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
7
  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
8
 
9
9
  SECONDS=0
10
10
 
11
- # Convert the TypeScript to a single Lua file (based on the settings in "tsconfig.json")
11
+ # Convert the TypeScript to a single Lua file (based on the settings in "tsconfig.json").
12
12
  cd "$DIR"
13
13
  npx tstl
14
14
 
@@ -0,0 +1,53 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ REPO_ROOT="$DIR"
10
+ cd "$REPO_ROOT"
11
+
12
+ # Do nothing if the configuration file does not exist.
13
+ CSPELL_CONFIGURATION_PATH="$REPO_ROOT/.cspell.json"
14
+ if ! test -f "$CSPELL_CONFIGURATION_PATH"; then
15
+ exit 0
16
+ fi
17
+
18
+ # Do nothing if the configuration file does not have any words in it.
19
+ if ! grep -q '"words": ' "$CSPELL_CONFIGURATION_PATH"; then
20
+ exit 0
21
+ fi
22
+
23
+ # Make a list of every misspelled word without any custom dictionaries.
24
+ # We need to move the configuration path temporarily or else the cspell command won't work properly.
25
+ CSPELL_CONFIGURATION_PATH_TEMP="$REPO_ROOT/.cspell-temp.json"
26
+ mv "$CSPELL_CONFIGURATION_PATH" "$CSPELL_CONFIGURATION_PATH_TEMP"
27
+ MISSPELLED_WORDS_PATH="/tmp/misspelled-words.txt"
28
+ CSPELL_CONFIGURATION_TEST_PATH="$REPO_ROOT/.cspell-check-unused.json"
29
+ npx cspell lint --config "$CSPELL_CONFIGURATION_TEST_PATH" --dot --no-progress --no-summary --unique --words-only | sort --ignore-case --unique > "$MISSPELLED_WORDS_PATH"
30
+ mv "$CSPELL_CONFIGURATION_PATH_TEMP" "$CSPELL_CONFIGURATION_PATH"
31
+
32
+ # Check that each ".cspell.json" word is actually being used.
33
+ echo "Checking for orphaned CSpell configuration words in: $CSPELL_CONFIGURATION_PATH"
34
+ CSPELL_CONFIGURATION_WORDS=$(cat "$CSPELL_CONFIGURATION_PATH" | python -c "import sys, json; print('\n'.join(json.load(sys.stdin)['words']))")
35
+ ONE_OR_MORE_FAILURES=0
36
+ set +e
37
+ for LINE in $CSPELL_CONFIGURATION_WORDS; do
38
+ LINE_TRIMMED=$(echo "$LINE" | xargs)
39
+ if ! grep "$LINE_TRIMMED" "$MISSPELLED_WORDS_PATH" --ignore-case --quiet; then
40
+ echo "The following word in the CSpell config is not being used: $LINE_TRIMMED"
41
+ ONE_OR_MORE_FAILURES=1
42
+ fi
43
+ done
44
+ set -e
45
+
46
+ rm -f "$MISSPELLED_WORDS_PATH"
47
+
48
+ if [ $ONE_OR_MORE_FAILURES -ne "0" ]; then
49
+ echo "CSpell configuration words are not valid."
50
+ exit 1
51
+ fi
52
+
53
+ echo "CSpell configuration words are valid."
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -e # Exit on any errors
4
4
 
5
- # Get the directory of this script
5
+ # Get the directory of this script:
6
6
  # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
7
  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
8
 
@@ -10,29 +10,30 @@ SECONDS=0
10
10
 
11
11
  cd "$DIR"
12
12
 
13
- # Step 1 - Use Prettier to check formatting
14
- npx prettier --check "src/**/*.ts"
15
- npx prettier --check "mod/**/*.xml"
13
+ # Step 1 - Use Prettier to check formatting.
14
+ npx prettier --check .
16
15
 
17
- # Step 2 - Use ESLint to lint the TypeScript
18
- # Since all ESLint errors are set to warnings,
19
- # we set max warnings to 0 so that warnings will fail in CI
16
+ # Step 2 - Use ESLint to lint the TypeScript.
17
+ # Since all ESLint errors are set to warnings, we set max warnings to 0 so that warnings will fail
18
+ # in CI.
20
19
  npx eslint --max-warnings 0 src
21
20
 
22
- # Step 3 - Spell check every file using cspell
23
- # We use no-progress and no-summary because we want to only output errors
24
- npx cspell --no-progress --no-summary "src/**/*.ts"
25
- npx cspell --no-progress --no-summary "mod/metadata.xml"
21
+ # Step 3 - Spell check every file using cspell.
22
+ # We use "--no-progress" and "--no-summary" because we want to only output errors.
23
+ npx cspell --no-progress --no-summary
26
24
 
27
- # Step 4 - Use xmllint to lint XML files
28
- # (and skip this step if xmllint is not currently installed for whatever reason)
25
+ # Step 4 - Use xmllint to lint XML files.
26
+ # (Skip this step if xmllint is not currently installed for whatever reason.)
29
27
  if command -v xmllint &> /dev/null; then
30
28
  find "$DIR/mod" -name "*.xml" -print0 | xargs -0 xmllint --noout
31
29
  fi
32
30
 
33
- # Step 5 - Check for unused imports
34
- # The "--error" flag makes it return an error code of 1 if unused exports are found
35
- # (this starts out disabled by default, but you can uncomment the following line to find dead code)
31
+ # Step 5 - Check for unused imports.
32
+ # The "--error" flag makes it return an error code of 1 if unused exports are found.
33
+ # (This starts out disabled by default, but you can uncomment the following line to find dead code.)
36
34
  # npx ts-prune --error
37
35
 
36
+ # Step 6 - Check for orphaned words.
37
+ bash "$DIR/check-orphaned-words.sh"
38
+
38
39
  echo "Successfully linted in $SECONDS seconds."
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -e # Exit on any errors
4
4
 
5
- # Get the directory of this script
5
+ # Get the directory of this script:
6
6
  # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
7
  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -e # Exit on any errors
4
4
 
5
- # Get the directory of this script
5
+ # Get the directory of this script:
6
6
  # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
7
  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -e # Exit on any errors
4
4
 
5
- # Get the directory of this script
5
+ # Get the directory of this script:
6
6
  # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
7
  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
8
 
@@ -1,7 +1,7 @@
1
- // This is the entry point for the TypeScriptToLua bundler, which is set in the "tsconfig.json" file
2
- // All this file does is immediately execute the "main()" function in the "main.ts" file
3
- // (We don't want to point the TypeScriptToLua bundler at the "main.ts" file directly, because any
4
- // variables or functions that are declared in a bundle entry point will become global)
1
+ // This is the entry point for the TypeScriptToLua bundler, which is set in the "tsconfig.json"
2
+ // file. All this file does is immediately execute the "main()" function in the "main.ts" file. (We
3
+ // don't want to point the TypeScriptToLua bundler at the "main.ts" file directly, because any
4
+ // variables or functions that are declared in a bundle entry point will become global.)
5
5
 
6
6
  import { main } from "./main";
7
7
 
@@ -1,11 +1,11 @@
1
- // A special TypeScript configuration file, used by ESLint only
1
+ // A special TypeScript configuration file, used by ESLint only.
2
2
  {
3
3
  "extends": "./tsconfig.json",
4
4
  "include": [
5
- // This must match the "include" setting in the "tsconfig.json" file
5
+ // This must match the "include" setting in the "tsconfig.json" file.
6
6
  "./src/**/*.ts",
7
7
 
8
- // These are ESLint-only inclusions
8
+ // These are ESLint-only inclusions.
9
9
  "./.eslintrc.js",
10
10
  ],
11
11
  }
@@ -1,19 +1,17 @@
1
- // The configuration file for TypeScript
1
+ // The configuration file for TypeScript.
2
2
  {
3
- // We extend the standard IsaacScript config
3
+ // We extend the standard IsaacScript config:
4
4
  // https://github.com/IsaacScript/isaacscript-tsconfig/blob/main/tsconfig.mod.json
5
5
  "extends": "isaacscript-tsconfig/tsconfig.mod.json",
6
6
 
7
7
  // https://www.typescriptlang.org/docs/handbook/compiler-options.html
8
8
  "compilerOptions": {
9
- // Specifies the root folder within your source files
9
+ // Specifies the root folder within your source files.
10
10
  "rootDir": "./src",
11
11
  },
12
12
 
13
- // A list of the TypeScript files to compile
14
- "include": [
15
- "./src/**/*.ts",
16
- ],
13
+ // A list of the TypeScript files to compile.
14
+ "include": ["./src/**/*.ts"],
17
15
 
18
16
  // TypeScriptToLua settings
19
17
  "tstl": {
@@ -21,14 +19,14 @@
21
19
  "luaBundle": "./mod/main.lua", // Will bundle all output Lua files into a single file
22
20
  "luaBundleEntry": "./src/bundleEntry.ts", // This invokes the "main.ts" file
23
21
  "luaPlugins": [
24
- // A plugin to add an explanatory comment at the top of the compiled "main.lua" file
22
+ // A plugin to add an explanatory comment at the top of the compiled "main.lua" file.
25
23
  { "name": "./plugins/addIsaacScriptCommentHeader.ts" },
26
24
 
27
- // A plugin to make enums safe from global variables
25
+ // A plugin to make enums safe from global variables.
28
26
  { "name": "./plugins/noExtendedEnums.ts" },
29
27
 
30
28
  // Uncomment this and recompile the mod to enable crash debugging, which will tell you the
31
- // exact line of the mod that is causing the crash
29
+ // exact line of the mod that is causing the crash.
32
30
  // { "name": "./plugins/addCrashDebugStatements.ts" },
33
31
  ],
34
32
  },
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -e # Exit on any errors
4
4
 
5
- # Get the directory of this script
5
+ # Get the directory of this script:
6
6
  # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
7
  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
8
 
@@ -0,0 +1,38 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
3
+ "version": "0.2",
4
+ "loadDefaultConfiguration": true,
5
+ "import": [
6
+ "@cspell/dict-companies/cspell-ext.json",
7
+ "@cspell/dict-en_us/cspell-ext.json",
8
+ "@cspell/dict-public-licenses/cspell-ext.json",
9
+ "@cspell/dict-software-terms/cspell-ext.json",
10
+ "@cspell/dict-typescript/cspell-ext.json"
11
+ ],
12
+ "dictionaries": [
13
+ "companies",
14
+ "en_US",
15
+ "networking-terms",
16
+ "public-licenses",
17
+ "software-terms",
18
+ "typescript"
19
+ ],
20
+ "ignoreRegExpList": [
21
+ "Base64MultiLine",
22
+ "Base64SingleLine",
23
+ "CommitHash",
24
+ "CommitHashLink",
25
+ "CSSHexValue",
26
+ "CStyleHexValue",
27
+ "Email",
28
+ "HashStrings",
29
+ "RsaCert",
30
+ "SHA",
31
+ "SpellCheckerDisable",
32
+ "SpellCheckerIgnoreInDocSetting",
33
+ "SshRsa",
34
+ "UnicodeRef",
35
+ "Urls",
36
+ "UUID"
37
+ ]
38
+ }