diff --git a/.vscode/settings.json b/.vscode/settings.json index c80ab65..3d00bdc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,6 @@ "editor.tabSize": 4, "editor.insertSpaces": true, "editor.detectIndentation": false, - "editor.formatOnSave": true, "cSpell.words": [ "brighterscript", "findnode", diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5080e5c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,13 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + + +## [0.1.0](https://github.com/rokucommunity/bsc-plugin-auto-findnode/compare/315acc957e1f9e26fa8398d1f6f1926c592355a8...v0.1.0) - 2024-08-19 +- Initial release, which includes: + - auto-inject m variables for each element with an ID from xml + - warn about all `m.top.findNode` calls in the `init()` function diff --git a/README.md b/README.md index 3ea5f55..840698c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # bsc-plugin-auto-findnode + A BrighterScript plugin that auto-injects `m.top.findNode()` calls in your component `init()` functions [![build status](https://img.shields.io/github/actions/workflow/status/rokucommunity/bsc-plugin-auto-findnode/build.yml?branch=master&logo=github)](https://github.com/rokucommunity/bsc-plugin-auto-findnode/actions?query=branch%3Amaster+workflow%3Abuild) @@ -20,14 +21,64 @@ npm install bsc-plugin-auto-findnode ```jsonc { - "plugins": [ - "bsc-plugin-auto-findnode" - ] + "plugins": ["bsc-plugin-auto-findnode"] } ``` 3. Run brighterscript like normal, and the plugin will work! + ```bash npx bsc ``` +## How it works + +1. find every xml file in the project +2. find every element with an ID in that xml file +3. find the `init()` function for each scope (or create one in a new file) +4. inject `m. = m.top.findNode("")` into the init function + +For example: + +**Before:** + +_pkg:/components/ZombieKeyboard.xml_ + +```xml + + + +