isaacscript-lint 1.0.150 → 1.0.151

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.
package/.cspell.json CHANGED
@@ -1,18 +1,25 @@
1
1
  {
2
- "version": "0.2",
3
- "words": [
4
- "dbaeumer",
5
- "eqeqeq",
6
- "esbenp",
7
- "gofmt",
8
- "gofmt's",
9
- "Gruntfile",
10
- "isaacscript",
11
- "prettier's",
12
- "rossum",
13
- "rustfmt",
14
- "tiamtowtdi",
15
- "unexported",
16
- "zamiell"
17
- ]
2
+ "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
3
+ "version": "0.2",
4
+ "files": [
5
+ "**"
6
+ ],
7
+ "ignorePaths": [
8
+ ".git/**",
9
+ "dist/**",
10
+ "node_modules/**"
11
+ ],
12
+ "words": [
13
+ "dbaeumer",
14
+ "esbenp",
15
+ "gofmt",
16
+ "Gruntfile",
17
+ "isaacscript",
18
+ "prettierignore",
19
+ "prettierrc",
20
+ "rossum",
21
+ "rustfmt",
22
+ "tiamtowtdi",
23
+ "zamiell"
24
+ ]
18
25
  }
package/.gitattributes CHANGED
@@ -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
@@ -0,0 +1,5 @@
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
package/.prettierrc.js ADDED
@@ -0,0 +1,30 @@
1
+ // This is the configuration file for Prettier, the auto-formatter:
2
+ // https://prettier.io/docs/en/configuration.html
3
+ module.exports = {
4
+ // Always print trailing commas:
5
+ // https://prettier.io/docs/en/options.html#trailing-commas
6
+ // The default is "es5" - Trailing commas where valid in ES5 (objects, arrays, etc.). However,
7
+ // always having trailing commas is objectively better. The Airbnb style guide agrees:
8
+ // https://github.com/airbnb/javascript#commas--dangling
9
+ // Prettier itself also acknowledges Nik Graf's blog in their official blog:
10
+ // https://prettier.io/blog/2020/03/21/2.0.0.html
11
+ // https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
12
+ // Prettier will change the default in the future:
13
+ // https://github.com/prettier/prettier/issues/9369
14
+ trailingComma: "all",
15
+
16
+ // We want to always use "lf" to be consistent with all platforms.
17
+ endOfLine: "lf",
18
+
19
+ // Allow proper formatting of JSONC files:
20
+ // https://github.com/prettier/prettier/issues/5708
21
+ overrides: [
22
+ {
23
+ files: ["**/.vscode/*.json", "**/tsconfig.json", "**/tsconfig.*.json"],
24
+ options: {
25
+ parser: "json5",
26
+ quoteProps: "preserve",
27
+ },
28
+ },
29
+ ],
30
+ };
@@ -1,8 +1,9 @@
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": [
5
+ "esbenp.prettier-vscode", // The TypeScript formatter
6
+ "dbaeumer.vscode-eslint", // The TypeScript linter
6
7
  "streetsidesoftware.code-spell-checker", // A spell-checker extension based on cspell
7
- ]
8
+ ],
8
9
  }
@@ -1,16 +1,66 @@
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
 
11
- // Linux line endings are used in this project
11
+ // We want to always use "lf" to be consistent with all platforms.
12
12
  "files.eol": "\n",
13
13
 
14
- // Automatically removing all trailing whitespace when saving a file
14
+ // Automatically removing all trailing whitespace when saving a file.
15
15
  "files.trimTrailingWhitespace": true,
16
+
17
+ // Configure glob patterns for excluding files and folders in full text searches and quick open.
18
+ // (File extensions must be specified or the glob won't work properly.)
19
+ "search.exclude": {
20
+ "dist/**/*.ts": true,
21
+ "dist/**/*.js": true,
22
+ "dist/**/*.json": true,
23
+ },
24
+
25
+ // -----------------
26
+ // Language settings
27
+ // -----------------
28
+
29
+ // By default, VSCode will not automatically fill-in function arguments.
30
+ "javascript.suggest.completeFunctionCalls": true,
31
+ "typescript.suggest.completeFunctionCalls": true,
32
+
33
+ // Automatically run the formatter when certain files are saved.
34
+ "[javascript]": {
35
+ "editor.codeActionsOnSave": ["source.fixAll.eslint"],
36
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
37
+ "editor.formatOnSave": true,
38
+ "editor.tabSize": 2,
39
+ },
40
+ "[typescript]": {
41
+ "editor.codeActionsOnSave": ["source.fixAll.eslint"],
42
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
43
+ "editor.formatOnSave": true,
44
+ "editor.tabSize": 2,
45
+ },
46
+ "[json]": {
47
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
48
+ "editor.formatOnSave": true,
49
+ "editor.tabSize": 2,
50
+ },
51
+ "[jsonc]": {
52
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
53
+ "editor.formatOnSave": true,
54
+ "editor.tabSize": 2,
55
+ },
56
+ "[yaml]": {
57
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
58
+ "editor.formatOnSave": true,
59
+ "editor.tabSize": 2,
60
+ },
61
+ "[markdown]": {
62
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
63
+ "editor.formatOnSave": true,
64
+ "editor.tabSize": 2,
65
+ },
16
66
  }
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # isaacscript-lint
2
2
 
3
+ <!-- markdownlint-disable MD033 -->
4
+
3
5
  [![npm version](https://img.shields.io/npm/v/isaacscript-lint.svg)](https://www.npmjs.com/package/isaacscript-lint)
4
6
 
5
7
  `isaacscript-lint` is a helper package to install all of the dependencies necessary for ESLint to work with a typical TypeScript project or a typical IsaacScript mod.
@@ -30,7 +32,7 @@ One of the key insights of [Guido van Rossum](https://en.wikipedia.org/wiki/Guid
30
32
 
31
33
  [Go](https://golang.org/), the programming language designed at Google in 2009, took this concept a step further. They included a code formatter inside of the language itself, called `gofmt` (which is short for "Go formatter"). When you are coding a Go program, it will automatically format all of the code as soon as you save the file. This can be surprising and disturbing for newcomers: "Why does `gofmt` make my code ugly?!"
32
34
 
33
- However, once people get used to the formatter, they realize that it saves them a *tremendous amount of time*. By ignoring all formatting and typing out code "raw", and then summoning the formatter to instantly fix everything, you can quite literally code twice as fast. Rob Pike, one of the creators of Go, famously said that "gofmt's style is no one's favorite, yet gofmt is everyone's favorite". ([This YouTube clip](https://www.youtube.com/embed/PAAkCSZUG1c?start=523&end=568) of Rob is a much-watch!)
35
+ However, once people get used to the formatter, they realize that it saves them a _tremendous amount of time_. By ignoring all formatting and typing out code "raw", and then summoning the formatter to instantly fix everything, you can quite literally code twice as fast. Rob Pike, one of the creators of Go, famously said that "gofmt's style is no one's favorite, yet gofmt is everyone's favorite". ([This YouTube clip](https://www.youtube.com/embed/PAAkCSZUG1c?start=523&end=568) of Rob is a much-watch!)
34
36
 
35
37
  `gofmt` is nice because it saves people from mundane code formatting. But there is also a benefit that is entirely separate and not readily apparent. When looking at other people's Go code on StackOverflow or GitHub, you realize that it looks exactly like your code. It's easy to read and comprehend. And you can copy-paste code snippets from other programs into your own applications without having to change anything! For programmers, this is not the norm, and it feels great - it's the hidden superpower of Go.
36
38
 
@@ -48,7 +50,7 @@ Historically, the the most popular style guide is the world is the [Airbnb JavaS
48
50
 
49
51
  ESLint is the industry standard tool for linting in JavaScript and TypeScript. Airbnb helpfully provides an ESLint configuration with most of their style recommendations. ESLint can function in a way similar to `gofmt` by configuring your text editor to do `eslint --fix` on save. However, this has a lot of limitations. It can't automatically fix everything and leaves a lot up to the end user to fix.
50
52
 
51
- [Prettier](https://prettier.io/) was released in 2017 and it has quickly become very widespread. (It could *probably* also be considered to be industry standard in 2022.) Prettier works by completely rebuilding your code from scratch using the [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree), which allows it to make much better transformations than pure ESLint can.
53
+ [Prettier](https://prettier.io/) was released in 2017 and it has quickly become very widespread. (It could _probably_ also be considered to be industry standard in 2022.) Prettier works by completely rebuilding your code from scratch using the [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree), which allows it to make much better transformations than pure ESLint can.
52
54
 
53
55
  Because of the advantages of Prettier, we use it on top of the Airbnb config, and prefer Prettier's changes if there are any conflicts. Any ESLint rules that conflict with Prettier are turned off with [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier).
54
56
 
@@ -116,8 +118,8 @@ Create a `tsconfig.eslint.json` file in the root of your repository:
116
118
  // These are ESLint-only inclusions
117
119
  // Usually, this includes any files that are outside of your "src" directory,
118
120
  // such as "webpack.config.js", "jest.config.js", "Gruntfile.js", and so forth
119
- "./.eslintrc.js",
120
- ],
121
+ "./.eslintrc.js"
122
+ ]
121
123
  }
122
124
  ```
123
125
 
@@ -157,20 +159,16 @@ Furthermore, you will probably want Prettier and ESLint to be run automatically
157
159
  // These are Visual Studio Code settings that should apply to this particular repository
158
160
  {
159
161
  "[javascript]": {
160
- "editor.codeActionsOnSave": [
161
- "source.fixAll.eslint",
162
- ],
162
+ "editor.codeActionsOnSave": ["source.fixAll.eslint"],
163
163
  "editor.defaultFormatter": "esbenp.prettier-vscode",
164
- "editor.formatOnSave": true,
164
+ "editor.formatOnSave": true
165
165
  },
166
166
 
167
167
  "[typescript]": {
168
- "editor.codeActionsOnSave": [
169
- "source.fixAll.eslint",
170
- ],
168
+ "editor.codeActionsOnSave": ["source.fixAll.eslint"],
171
169
  "editor.defaultFormatter": "esbenp.prettier-vscode",
172
- "editor.formatOnSave": true,
173
- },
170
+ "editor.formatOnSave": true
171
+ }
174
172
  }
175
173
  ```
176
174
 
@@ -190,8 +188,8 @@ Optionally, you can also provide a hint to anyone cloning your repository that t
190
188
  "recommendations": [
191
189
  "esbenp.prettier-vscode", // The TypeScript formatter
192
190
  "dbaeumer.vscode-eslint", // The TypeScript linter
193
- "streetsidesoftware.code-spell-checker", // A spell-checker extension based on cspell
194
- ],
191
+ "streetsidesoftware.code-spell-checker" // A spell-checker extension based on cspell
192
+ ]
195
193
  }
196
194
  ```
197
195
 
@@ -0,0 +1,67 @@
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
+ TEMPLATE_FILES_FILE_NAME="check-file-updates.txt"
10
+ TEMPLATE_FILES_PATH="$DIR/$TEMPLATE_FILES_FILE_NAME"
11
+
12
+ # Do nothing if the metadata file does not exist.
13
+ if ! test -f "$TEMPLATE_FILES_PATH"; then
14
+ echo "The \"$TEMPLATE_FILES_FILE_NAME\" file does not exist. Skipping checks."
15
+ exit 0
16
+ fi
17
+
18
+ ONE_OR_MORE_FAILURES=0
19
+ for FILE_SPECIFICATION in $(cat "$TEMPLATE_FILES_PATH"); do
20
+ if [[ "$FILE_SPECIFICATION" =~ (.+):(.+) ]]; then
21
+ LOCAL_FILE=${BASH_REMATCH[1]}
22
+ REMOTE_FILE=${BASH_REMATCH[2]}
23
+ STATIC_DIRECTORY="static-alt"
24
+ else
25
+ LOCAL_FILE=$FILE_SPECIFICATION
26
+ REMOTE_FILE=$FILE_SPECIFICATION
27
+ STATIC_DIRECTORY="static"
28
+ fi
29
+
30
+ echo "Checking for an updated version of: $LOCAL_FILE"
31
+ TMP_FILE_PATH="/tmp/base-file"
32
+ URL="https://raw.githubusercontent.com/IsaacScript/isaacscript/main/file-templates/$STATIC_DIRECTORY/$REMOTE_FILE"
33
+ curl "$URL" --output "$TMP_FILE_PATH" --silent --show-error
34
+ if grep "^404: Not Found" "$TMP_FILE_PATH" --silent; then
35
+ echo
36
+ echo "Failed to find the following remote file:"
37
+ echo "$URL"
38
+ exit 1
39
+ fi
40
+
41
+ FILE_PATH="$DIR/$LOCAL_FILE"
42
+ if test -f "$FILE_PATH"; then
43
+ set +e
44
+ if ! cmp "$FILE_PATH" "$TMP_FILE_PATH" --silent; then
45
+ echo
46
+ echo "File \"$LOCAL_FILE\" is out of date. Get the updated version here:"
47
+ echo "$URL"
48
+ echo
49
+ diff "$FILE_PATH" "$TMP_FILE_PATH"
50
+ echo
51
+ ONE_OR_MORE_FAILURES=1
52
+ fi
53
+ set -e
54
+ else
55
+ echo "File \"$FILE_PATH\" does not exist! Change the \"$TEMPLATE_FILES_FILE_NAME\" file."
56
+ ONE_OR_MORE_FAILURES=1
57
+ fi
58
+
59
+ rm -f "$TMP_FILE_PATH"
60
+ done
61
+
62
+ if [ $ONE_OR_MORE_FAILURES -ne "0" ]; then
63
+ echo "One or more files was not valid."
64
+ exit 1
65
+ fi
66
+
67
+ echo "All core files up to date!"
@@ -0,0 +1,7 @@
1
+ .vscode/extensions.json:.vscode/extensions-typescript.json
2
+ .vscode/settings.json:.vscode/settings-typescript.json
3
+ .gitattributes
4
+ .prettierignore:.prettierignore-base
5
+ .prettierrc.js:.prettierrc-base.js
6
+ check-file-updates.sh:check-file-updates.sh
7
+ check-orphaned-words.sh
@@ -0,0 +1,58 @@
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_CONFIG_NAME=".cspell.json"
14
+ CSPELL_CONFIG_PATH="$REPO_ROOT/$CSPELL_CONFIG_NAME"
15
+ if ! test -f "$CSPELL_CONFIG_PATH"; then
16
+ echo "The \"$CSPELL_CONFIG_NAME\" file does not exist. Skipping checks."
17
+ exit 0
18
+ fi
19
+
20
+ # Do nothing if the configuration file does not have any words in it.
21
+ if ! grep -q '"words": ' "$CSPELL_CONFIG_PATH"; then
22
+ echo "The \"$CSPELL_CONFIG_NAME\" file does not have any whitelisted words in it. Skipping checks."
23
+ exit 0
24
+ fi
25
+
26
+ # Make a list of every misspelled word without any custom words.
27
+ # We need to move the configuration path temporarily or else the cspell command won't work properly.
28
+ CSPELL_CONFIG_WORDS=$(cat "$CSPELL_CONFIG_PATH" | python -c "import sys, json; print('\n'.join(json.load(sys.stdin)['words']))")
29
+ CSPELL_CONFIG_WITHOUT_WORDS=$(cat "$CSPELL_CONFIG_PATH" | python -c "import sys, json; config = json.load(sys.stdin); del config['words']; print(json.dumps(config))")
30
+ CSPELL_CONFIG_PATH_TEMP="$REPO_ROOT/.cspell-temp.json"
31
+ mv "$CSPELL_CONFIG_PATH" "$CSPELL_CONFIG_PATH_TEMP"
32
+ echo "$CSPELL_CONFIG_WITHOUT_WORDS" > "$CSPELL_CONFIG_PATH"
33
+ MISSPELLED_WORDS_PATH="/tmp/misspelled-words.txt"
34
+ npx cspell lint --no-progress --no-summary --unique --words-only | sort --ignore-case --unique > "$MISSPELLED_WORDS_PATH"
35
+ mv "$CSPELL_CONFIG_PATH_TEMP" "$CSPELL_CONFIG_PATH"
36
+
37
+ # Check that each ".cspell.json" word is actually being used.
38
+ echo "Checking for orphaned CSpell configuration words in: $CSPELL_CONFIG_PATH"
39
+
40
+ ONE_OR_MORE_FAILURES=0
41
+ set +e
42
+ for LINE in $CSPELL_CONFIG_WORDS; do
43
+ LINE_TRIMMED=$(echo "$LINE" | xargs)
44
+ if ! grep "$LINE_TRIMMED" "$MISSPELLED_WORDS_PATH" --ignore-case --quiet; then
45
+ echo "The following word in the CSpell config is not being used: $LINE_TRIMMED"
46
+ ONE_OR_MORE_FAILURES=1
47
+ fi
48
+ done
49
+ set -e
50
+
51
+ rm -f "$MISSPELLED_WORDS_PATH"
52
+
53
+ if [ $ONE_OR_MORE_FAILURES -ne "0" ]; then
54
+ echo "CSpell configuration words are not valid."
55
+ exit 1
56
+ fi
57
+
58
+ echo "CSpell configuration words are valid."
package/lint.sh ADDED
@@ -0,0 +1,22 @@
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
+ cd "$DIR"
10
+
11
+ # Step 1 - Use Prettier to check formatting.
12
+ npx prettier --check .
13
+
14
+ # Step 2 - Spell check every file using cspell.
15
+ # We use "--no-progress" and "--no-summary" because we want to only output errors.
16
+ npx cspell --no-progress --no-summary
17
+
18
+ # Step 3 - Check for orphaned words.
19
+ bash "$DIR/check-orphaned-words.sh"
20
+
21
+ # Step 4 - Check for base file updates.
22
+ bash "$DIR/check-file-updates.sh"
package/nuke.sh CHANGED
@@ -15,4 +15,4 @@ rm -rf "$NODE_MODULES"
15
15
  echo "Successfully deleted: $NODE_MODULES"
16
16
 
17
17
  npm install
18
- echo "Successfully reinstalled Node depedencies."
18
+ echo "Successfully reinstalled Node dependencies."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-lint",
3
- "version": "1.0.150",
3
+ "version": "1.0.151",
4
4
  "description": "An updatable linting dependency container for IsaacScript and TypeScript projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,12 +16,12 @@
16
16
  "eslint": "^8.15.0",
17
17
  "eslint-config-airbnb-base": "^15.0.0",
18
18
  "eslint-config-airbnb-typescript": "^17.0.0",
19
- "eslint-config-isaacscript": "^1.0.76",
19
+ "eslint-config-isaacscript": "^1.0.77",
20
20
  "eslint-config-prettier": "^8.5.0",
21
21
  "eslint-plugin-eslint-comments": "^3.2.0",
22
22
  "eslint-plugin-import": "^2.26.0",
23
- "eslint-plugin-isaacscript": "^1.0.39",
24
- "eslint-plugin-jsdoc": "^39.2.9",
23
+ "eslint-plugin-isaacscript": "^1.0.40",
24
+ "eslint-plugin-jsdoc": "^39.3.0",
25
25
  "eslint-plugin-no-implicit-map-set-loops": "^1.0.3",
26
26
  "eslint-plugin-only-warn": "^1.0.3",
27
27
  "eslint-plugin-sort-exports": "^0.6.0",