diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd746a1a..dd6971b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,21 +24,41 @@ jobs: - uses: leafo/gh-actions-luarocks@v4 + - name: get foreman and run foreman install + uses: rojo-rbx/setup-foreman@v1 + with: + version: "^1.0.1" + token: ${{ secrets.GITHUB_TOKEN }} + + # useful for debugging differences between CI and local environment + - name: check versions + shell: bash + run: | + foreman list + + - name: use rojo to build project + shell: bash + run: rojo build default.project.json --output model.rbxmx + + - name: Linting and Style Checking + shell: bash + run: | + selene src benchmarks examples + stylua -c src benchmarks examples + - name: Install dependencies run: | luarocks install luafilesystem luarocks install luacov luarocks install luacov-reporter-lcov - luarocks install luacheck - name: Test run: | lua -lluacov bin/spec.lua - luacheck src benchmarks examples luacov -r lcov - name: Report to Coveralls uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: luacov.report.out \ No newline at end of file + path-to-lcov: luacov.report.out diff --git a/.gitignore b/.gitignore index ce0b8c02..c4f8932f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ /*.rbxlx /*.rbxmx /*.rbxm -/*.rbxl \ No newline at end of file +/*.rbxl +# let selene re-generate roblox.toml so it updates automatically with selene +roblox.toml diff --git a/.luacheckrc b/.luacheckrc deleted file mode 100644 index 2bb24248..00000000 --- a/.luacheckrc +++ /dev/null @@ -1,43 +0,0 @@ -stds.roblox = { - globals = { - "game" - }, - read_globals = { - -- Roblox globals - "script", - - -- Extra functions - "tick", "warn", "spawn", - "wait", "settings", "typeof", - - -- Types - "Vector2", "Vector3", - "Color3", - "UDim", "UDim2", - "Rect", - "CFrame", - "Enum", - "Instance", - "TweenInfo", - } -} - -stds.testez = { - read_globals = { - "describe", - "it", "itFOCUS", "itSKIP", - "FOCUS", "SKIP", - "expect", - "beforeEach", "afterEach", "beforeAll", "afterAll", - } -} - -ignore = { - "212", -- unused arguments -} - -std = "lua51+roblox" - -files["**/*.spec.lua"] = { - std = "+testez", -} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd088337..26366f82 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,9 +22,20 @@ To get started working on Roact, you'll need: * Lua 5.1 * Lemur's dependencies: * [LuaFileSystem](https://keplerproject.github.io/luafilesystem/) (`luarocks install luafilesystem`) -* [Luacheck](https://github.com/mpeterv/luacheck) (`luarocks install luacheck`) * [LuaCov](https://keplerproject.github.io/luacov) (`luarocks install luacov`) +Foreman is an un-package manager that retrieves code directly from GitHub repositories. We'll use this to get a lua code analysis tool and other utilities. The Foreman packages are listed in `foreman.toml`. + +You can install `foreman` from its [releases page](https://github.com/rojo-rbx/foreman/releases). If you have the Rust tool `cargo` installed, you can also do `cargo install foreman`. Either way, be sure the foreman binary location is in your `PATH` environment variable. + +``` +foreman github-auth <[your GitHub API token](https://github.com/settings/tokens)> +foreman install +export PATH=$PATH:~/.foreman/bin/ # you might want to add this to your .bash_profile (or similarly appropriate shell configuration) file as well +``` + +After running `foreman install`, you should be able to run `stylua src` and `selene src` commands -- just like this repository's continuous integration steps do! This helps ensure that our code and your contributions are consistently formatted and are free of trivial bugs. + Make sure you have all of the Git submodules for Roact downloaded, which include a couple extra dependencies used for testing. Finally, you can run all of Roact's tests with: @@ -44,10 +55,10 @@ luacov Before starting a pull request, open an issue about the feature or bug. This helps us prevent duplicated and wasted effort. These issues are a great place to ask for help if you run into problems! Before you submit a new pull request, check: -* Code Style: Match the [official Roblox Lua style guide](https://roblox.github.io/lua-style-guide) and the local code style -* Changelog: Add an entry to [CHANGELOG.md](CHANGELOG.md) -* Luacheck: Run [Luacheck](https://github.com/mpeterv/luacheck) on your code, no warnings allowed! +* Code Style: Run [StyLua](https://github.com/JohnnyMorganz/StyLua) to ensure your code changes follow the [official Roblox Lua style guide](https://roblox.github.io/lua-style-guide) and the local code style +* selene: Run [Selene](https://github.com/kampfkarren/selene) on your code, no warnings allowed! * Tests: They all need to pass! +* Changelog: Add an entry to [CHANGELOG.md](CHANGELOG.md) ### Code Style Roblox has an [official Lua style guide](https://roblox.github.io/lua-style-guide) which should be the general guidelines for all new code. When modifying code, follow the existing style! @@ -58,7 +69,7 @@ In short: * Double quotes * One statement per line -Eventually we'll have a tool to check these things automatically. +Use `StyLua` (instructions below) to automatically format the code to follow the coding style ### Changelog Adding an entry to [CHANGELOG.md](CHANGELOG.md) alongside your commit makes it easier for everyone to keep track of what's been changed. @@ -67,10 +78,10 @@ Add a line under the "Current master" heading. When we make a new release, all o Add a link to your pull request in the entry. We don't need to link to the related GitHub issue, since pull requests will also link to them. -### Luacheck -We use [Luacheck](https://github.com/mpeterv/luacheck) for static analysis of Lua on all of our projects. +### Selene and StyLua +We use [Selene](https://github.com/kampfkarren/selene) and [StyLua](https://github.com/JohnnyMorganz/StyLua) for static analysis of Lua on all of our projects. -From the command line, just run `luacheck src` to check the Roact source. +From the command line, just run `selene src` and `stylua -c src` to check the Roact source. You'll need to install `foreman` and run `foreman install` first, which will make both the `selene` and `stylua` tools available. You should get it working on your system, and then get a plugin for the editor you use. There are plugins available for most popular editors! @@ -97,4 +108,4 @@ When releasing a new version of Roact, do these things: 7. Write a release on GitHub: - Use the same format as the previous release - Copy the release notes from `CHANGELOG.md` - - Attach the `Roact.rbxm` built with Rojo \ No newline at end of file + - Attach the `Roact.rbxm` built with Rojo diff --git a/benchmarks/hello.bench.lua b/benchmarks/hello.bench.lua index 7b8766d9..36195b1c 100644 --- a/benchmarks/hello.bench.lua +++ b/benchmarks/hello.bench.lua @@ -11,4 +11,4 @@ return { local handle = Roact.mount(hello) Roact.unmount(handle) end, -} \ No newline at end of file +} diff --git a/benchmarks/init.server.lua b/benchmarks/init.server.lua index 5cdde7d3..7111737c 100644 --- a/benchmarks/init.server.lua +++ b/benchmarks/init.server.lua @@ -11,8 +11,7 @@ local function findBenchmarkModules(root, moduleList) end end -local function noop() -end +local function noop() end local emptyTimes = {} local function getEmptyTime(iterations) @@ -42,11 +41,7 @@ table.sort(benchmarkModules, function(a, b) return a.Name < b.Name end) -local startMessage = ( - "Starting %d benchmarks..." -):format( - #benchmarkModules -) +local startMessage = ("Starting %d benchmarks..."):format(#benchmarkModules) print(startMessage) print() @@ -70,9 +65,7 @@ for _, module in ipairs(benchmarkModules) do local totalTime = (endTime - startTime) - getEmptyTime(benchmark.iterations) - local message = ( - "Benchmark %s:\n\t(%d iterations) took %f s (%f ns/iteration)" - ):format( + local message = ("Benchmark %s:\n\t(%d iterations) took %f s (%f ns/iteration)"):format( module.Name, benchmark.iterations, totalTime, @@ -83,4 +76,4 @@ for _, module in ipairs(benchmarkModules) do print() end -print("Benchmarks complete!") \ No newline at end of file +print("Benchmarks complete!") diff --git a/benchmarks/update.bench.lua b/benchmarks/update.bench.lua index b450be4a..240133be 100644 --- a/benchmarks/update.bench.lua +++ b/benchmarks/update.bench.lua @@ -14,8 +14,11 @@ return { Roact.unmount(tree) end, step = function(i) - Roact.update(tree, Roact.createElement("StringValue", { - Value = tostring(i), - })) + Roact.update( + tree, + Roact.createElement("StringValue", { + Value = tostring(i), + }) + ) end, -} \ No newline at end of file +} diff --git a/bin/run-tests.server.lua b/bin/run-tests.server.lua index d4df9f36..a15c9b2f 100644 --- a/bin/run-tests.server.lua +++ b/bin/run-tests.server.lua @@ -1,5 +1,3 @@ --- luacheck: globals __LEMUR__ - local ReplicatedStorage = game:GetService("ReplicatedStorage") local isRobloxCli, ProcessService = pcall(game.GetService, game, "ProcessService") @@ -19,8 +17,8 @@ local results = TestEZ.TestBootstrap:run( local statusCode = (results.failureCount == 0 and #results.errors == 0) and 0 or 1 -if __LEMUR__ then +if _G.__LEMUR__ then os.exit(statusCode) elseif isRobloxCli then ProcessService:ExitAsync(statusCode) -end \ No newline at end of file +end diff --git a/examples/binding/init.lua b/examples/binding/init.lua index 36835bff..bd677903 100644 --- a/examples/binding/init.lua +++ b/examples/binding/init.lua @@ -48,4 +48,4 @@ return function() end return stop -end \ No newline at end of file +end diff --git a/examples/clock/init.lua b/examples/clock/init.lua index f9eda0ef..cfec2c47 100644 --- a/examples/clock/init.lua +++ b/examples/clock/init.lua @@ -18,17 +18,23 @@ return function() local running = true local currentTime = 0 - local handle = Roact.mount(Roact.createElement(ClockApp, { - time = currentTime, - }), PlayerGui) + local handle = Roact.mount( + Roact.createElement(ClockApp, { + time = currentTime, + }), + PlayerGui + ) spawn(function() while running do currentTime = currentTime + 1 - handle = Roact.reconcile(handle, Roact.createElement(ClockApp, { - time = currentTime, - })) + handle = Roact.reconcile( + handle, + Roact.createElement(ClockApp, { + time = currentTime, + }) + ) wait(1) end @@ -40,4 +46,4 @@ return function() end return stop -end \ No newline at end of file +end diff --git a/examples/event/init.lua b/examples/event/init.lua index 598eb452..e4209dda 100644 --- a/examples/event/init.lua +++ b/examples/event/init.lua @@ -12,7 +12,7 @@ return function() -- Attach event listeners using `Roact.Event[eventName]` -- Event listeners get `rbx` as their first parameter -- followed by their normal event arguments. - [Roact.Event.Activated] = function(rbx) + [Roact.Event.Activated] = function(_rbx) print("The button was clicked!") end, }), diff --git a/examples/hello-roact/init.lua b/examples/hello-roact/init.lua index f67cbf14..09ad91b3 100644 --- a/examples/hello-roact/init.lua +++ b/examples/hello-roact/init.lua @@ -19,4 +19,4 @@ return function() end return stop -end \ No newline at end of file +end diff --git a/examples/init.client.lua b/examples/init.client.lua index a320546c..b181f26a 100644 --- a/examples/init.client.lua +++ b/examples/init.client.lua @@ -131,4 +131,4 @@ function Examples.makeExampleList() end Examples.exampleList = Examples.makeExampleList() -Examples.exampleList.Parent = PlayerGui \ No newline at end of file +Examples.exampleList.Parent = PlayerGui diff --git a/examples/stress-test/init.lua b/examples/stress-test/init.lua index 00f60e83..853bdede 100644 --- a/examples/stress-test/init.lua +++ b/examples/stress-test/init.lua @@ -81,4 +81,4 @@ return function() end return stop -end \ No newline at end of file +end diff --git a/foreman.toml b/foreman.toml new file mode 100644 index 00000000..dedd8e87 --- /dev/null +++ b/foreman.toml @@ -0,0 +1,4 @@ +[tools] +rojo = { source = "rojo-rbx/rojo", version = "6.2.0" } +selene = { source = "Kampfkarren/selene", version = "0.14" } +stylua = { source = "JohnnyMorganz/StyLua", version = "0.11" } diff --git a/selene.toml b/selene.toml new file mode 100644 index 00000000..49fb47e5 --- /dev/null +++ b/selene.toml @@ -0,0 +1 @@ +std = "roblox+testez" diff --git a/src/Binding.lua b/src/Binding.lua index b50acf61..96987abf 100644 --- a/src/Binding.lua +++ b/src/Binding.lua @@ -76,7 +76,7 @@ function BindingInternalApi.map(upstreamBinding, predicate) end) end - function impl.update(newValue) + function impl.update(_newValue) error("Bindings created by Binding:map(fn) cannot be updated directly", 2) end @@ -96,9 +96,7 @@ function BindingInternalApi.join(upstreamBindings) for key, value in pairs(upstreamBindings) do if Type.of(value) ~= Type.Binding then - local message = ( - "Expected arg #1 to contain only bindings, but key %q had a non-binding value" - ):format( + local message = ("Expected arg #1 to contain only bindings, but key %q had a non-binding value"):format( tostring(key) ) error(message, 2) @@ -122,7 +120,7 @@ function BindingInternalApi.join(upstreamBindings) local disconnects = {} for key, upstream in pairs(upstreamBindings) do - disconnects[key] = BindingInternalApi.subscribe(upstream, function(newValue) + disconnects[key] = BindingInternalApi.subscribe(upstream, function(_newValue) callback(getValue()) end) end @@ -140,7 +138,7 @@ function BindingInternalApi.join(upstreamBindings) end end - function impl.update(newValue) + function impl.update(_newValue) error("Bindings created by joinBindings(...) cannot be updated directly", 2) end @@ -154,4 +152,4 @@ function BindingInternalApi.join(upstreamBindings) }, BindingPublicMeta) end -return BindingInternalApi \ No newline at end of file +return BindingInternalApi diff --git a/src/Binding.spec.lua b/src/Binding.spec.lua index f4fd03e9..baf9d37f 100644 --- a/src/Binding.spec.lua +++ b/src/Binding.spec.lua @@ -199,7 +199,7 @@ return function() local binding1, update1 = Binding.create(1) local binding2, update2 = Binding.create(2) - local joined = Binding.join({binding1, binding2}) + local joined = Binding.join({ binding1, binding2 }) local spy = createSpy() local disconnect = Binding.subscribe(joined, spy.value) @@ -266,4 +266,4 @@ return function() end) end) end) -end \ No newline at end of file +end diff --git a/src/Component.lua b/src/Component.lua index 04bdeaa7..b35754b2 100644 --- a/src/Component.lua +++ b/src/Component.lua @@ -104,10 +104,11 @@ function Component:setState(mapState) to call `setState` as it will interfere with in-flight updates. It's also disallowed during unmounting ]] - if lifecyclePhase == ComponentLifecyclePhase.ShouldUpdate or - lifecyclePhase == ComponentLifecyclePhase.WillUpdate or - lifecyclePhase == ComponentLifecyclePhase.Render or - lifecyclePhase == ComponentLifecyclePhase.WillUnmount + if + lifecyclePhase == ComponentLifecyclePhase.ShouldUpdate + or lifecyclePhase == ComponentLifecyclePhase.WillUpdate + or lifecyclePhase == ComponentLifecyclePhase.Render + or lifecyclePhase == ComponentLifecyclePhase.WillUnmount then local messageTemplate = invalidSetStateMessages[internalData.lifecyclePhase] @@ -143,10 +144,10 @@ function Component:setState(mapState) -- If `setState` is called in `init`, we can skip triggering an update! local derivedState = self:__getDerivedState(self.props, newState) self.state = assign(newState, derivedState) - - elseif lifecyclePhase == ComponentLifecyclePhase.DidMount or - lifecyclePhase == ComponentLifecyclePhase.DidUpdate or - lifecyclePhase == ComponentLifecyclePhase.ReconcileChildren + elseif + lifecyclePhase == ComponentLifecyclePhase.DidMount + or lifecyclePhase == ComponentLifecyclePhase.DidUpdate + or lifecyclePhase == ComponentLifecyclePhase.ReconcileChildren then --[[ During certain phases of the component lifecycle, it's acceptable to @@ -155,7 +156,6 @@ function Component:setState(mapState) ]] local derivedState = self:__getDerivedState(self.props, newState) internalData.pendingState = assign(newState, derivedState) - elseif lifecyclePhase == ComponentLifecyclePhase.Idle then -- Outside of our lifecycle, the state update is safe to make immediately self:__update(nil, newState) @@ -188,9 +188,7 @@ end function Component:render() local internalData = self[InternalData] - local message = componentMissingRenderMessage:format( - tostring(internalData.componentClass) - ) + local message = componentMissingRenderMessage:format(tostring(internalData.componentClass)) error(message, 0) end @@ -254,21 +252,26 @@ function Component:__validateProps(props) end if typeof(validator) ~= "function" then - error(("validateProps must be a function, but it is a %s.\nCheck the definition of the component %q."):format( - typeof(validator), - self.__componentName - )) + error( + ("validateProps must be a function, but it is a %s.\nCheck the definition of the component %q."):format( + typeof(validator), + self.__componentName + ) + ) end local success, failureReason = validator(props) if not success then failureReason = failureReason or "" - error(("Property validation failed in %s: %s\n\n%s"):format( - self.__componentName, - tostring(failureReason), - self:getElementTraceback() or ""), - 0) + error( + ("Property validation failed in %s: %s\n\n%s"):format( + self.__componentName, + tostring(failureReason), + self:getElementTraceback() or "" + ), + 0 + ) end end diff --git a/src/Component.spec/context.spec.lua b/src/Component.spec/context.spec.lua index 1346a335..6ab5b6cc 100644 --- a/src/Component.spec/context.spec.lua +++ b/src/Component.spec/context.spec.lua @@ -16,8 +16,7 @@ return function() self:__addContext("foo", "bar") end - function Provider:render() - end + function Provider:render() end local element = createElement(Provider) local hostParent = nil @@ -42,8 +41,7 @@ return function() } end - function Consumer:render() - end + function Consumer:render() end local Parent = Component:extend("Parent") @@ -77,8 +75,7 @@ return function() } end - function Consumer:render() - end + function Consumer:render() end local function Parent() return createElement(Consumer) @@ -135,8 +132,7 @@ return function() self:__addContext("child", "I'm here too!") end - function ChildProvider:render() - end + function ChildProvider:render() end local ParentProvider = Component:extend("ParentProvider") @@ -162,7 +158,7 @@ return function() local expectedChildContext = { parent = "I'm here!", - child = "I'm here too!" + child = "I'm here too!", } assertDeepEqual(parentNode.context, expectedParentContext) @@ -180,8 +176,7 @@ return function() } end - function Consumer:render() - end + function Consumer:render() end local Provider = Component:extend("Provider") @@ -238,8 +233,7 @@ return function() capturedContextA = captureAllContext(self) end - function ConsumerA:render() - end + function ConsumerA:render() end local ConsumerB = Component:extend("ConsumerB") @@ -250,8 +244,7 @@ return function() capturedContextB = captureAllContext(self) end - function ConsumerB:render() - end + function ConsumerB:render() end local Provider = Component:extend("Provider") @@ -294,4 +287,4 @@ return function() assertDeepEqual(capturedContextB, expectedContextB) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/defaultProps.spec.lua b/src/Component.spec/defaultProps.spec.lua index 40edca03..3de800ff 100644 --- a/src/Component.spec/defaultProps.spec.lua +++ b/src/Component.spec/defaultProps.spec.lua @@ -24,8 +24,7 @@ return function() capturedProps = self.props end - function Foo:render() - end + function Foo:render() end local initialProps = { b = 4, @@ -123,4 +122,4 @@ return function() assertDeepEqual(capturedProps, expectedProps) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/didMount.spec.lua b/src/Component.spec/didMount.spec.lua index b7286298..e065349e 100644 --- a/src/Component.spec/didMount.spec.lua +++ b/src/Component.spec/didMount.spec.lua @@ -32,4 +32,4 @@ return function() expect(Type.of(values.self)).to.equal(Type.StatefulComponentInstance) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/didUpdate.spec.lua b/src/Component.spec/didUpdate.spec.lua index 269c6f4a..431b829d 100644 --- a/src/Component.spec/didUpdate.spec.lua +++ b/src/Component.spec/didUpdate.spec.lua @@ -66,8 +66,7 @@ return function() self:setState(initialState) end - function MyComponent:render() - end + function MyComponent:render() end local element = createElement(MyComponent) local hostParent = nil @@ -89,4 +88,4 @@ return function() assertDeepEqual(values.oldProps, {}) assertDeepEqual(values.oldState, initialState) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/extend.spec.lua b/src/Component.spec/extend.spec.lua index 04a433a3..d5e7f18c 100644 --- a/src/Component.spec/extend.spec.lua +++ b/src/Component.spec/extend.spec.lua @@ -26,4 +26,4 @@ return function() expect(name).to.be.a("string") expect(name:find("FooBar")).to.be.ok() end) -end \ No newline at end of file +end diff --git a/src/Component.spec/getDerivedStateFromProps.spec.lua b/src/Component.spec/getDerivedStateFromProps.spec.lua index 1f04cc8d..cd3f49bd 100644 --- a/src/Component.spec/getDerivedStateFromProps.spec.lua +++ b/src/Component.spec/getDerivedStateFromProps.spec.lua @@ -49,13 +49,20 @@ return function() local hostParent = nil local hostKey = "WithDerivedState" - local node = noopReconciler.mountVirtualNode(createElement(WithDerivedState, { - someProp = 1, - }), hostParent, hostKey) - - noopReconciler.updateVirtualNode(node, createElement(WithDerivedState, { - someProp = 2, - })) + local node = noopReconciler.mountVirtualNode( + createElement(WithDerivedState, { + someProp = 1, + }), + hostParent, + hostKey + ) + + noopReconciler.updateVirtualNode( + node, + createElement(WithDerivedState, { + someProp = 2, + }) + ) expect(getDerivedSpy.callCount).to.equal(2) @@ -276,4 +283,4 @@ return function() derived = true, }) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/getElementTraceback.spec.lua b/src/Component.spec/getElementTraceback.spec.lua index 1d3e0ac9..eaea310b 100644 --- a/src/Component.spec/getElementTraceback.spec.lua +++ b/src/Component.spec/getElementTraceback.spec.lua @@ -64,4 +64,4 @@ return function() expect(stackTrace).to.equal(nil) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/init.spec.lua b/src/Component.spec/init.spec.lua index af50997a..e9117616 100644 --- a/src/Component.spec/init.spec.lua +++ b/src/Component.spec/init.spec.lua @@ -38,4 +38,4 @@ return function() expect(typeof(values.props)).to.equal("table") assertDeepEqual(values.props, props) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/legacyContext.spec.lua b/src/Component.spec/legacyContext.spec.lua index e1014f21..8e254079 100644 --- a/src/Component.spec/legacyContext.spec.lua +++ b/src/Component.spec/legacyContext.spec.lua @@ -15,8 +15,7 @@ return function() self._context.foo = "bar" end - function Provider:render() - end + function Provider:render() end local element = createElement(Provider) local hostParent = nil @@ -38,8 +37,7 @@ return function() capturedContext = self._context end - function Consumer:render() - end + function Consumer:render() end local Parent = Component:extend("Parent") @@ -70,8 +68,7 @@ return function() capturedContext = self._context end - function Consumer:render() - end + function Consumer:render() end local function Parent() return createElement(Consumer) @@ -100,8 +97,7 @@ return function() capturedContext = self._context end - function Consumer:render() - end + function Consumer:render() end local Provider = Component:extend("Provider") @@ -150,8 +146,7 @@ return function() capturedContextA = self._context end - function ConsumerA:render() - end + function ConsumerA:render() end local ConsumerB = Component:extend("ConsumerB") @@ -162,8 +157,7 @@ return function() capturedContextB = self._context end - function ConsumerB:render() - end + function ConsumerB:render() end local Provider = Component:extend("Provider") @@ -206,4 +200,4 @@ return function() assertDeepEqual(capturedContextB, expectedContextB) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/render.spec.lua b/src/Component.spec/render.spec.lua index 8dac00a6..c8387cb7 100644 --- a/src/Component.spec/render.spec.lua +++ b/src/Component.spec/render.spec.lua @@ -147,4 +147,4 @@ return function() itSKIP("Test defaultProps on initial render", function() end) itSKIP("Test defaultProps on prop update", function() end) itSKIP("Test defaultProps on state update", function() end) -end \ No newline at end of file +end diff --git a/src/Component.spec/setState.spec.lua b/src/Component.spec/setState.spec.lua index 88ae9f5d..7e62e507 100644 --- a/src/Component.spec/setState.spec.lua +++ b/src/Component.spec/setState.spec.lua @@ -19,7 +19,7 @@ return function() function InitComponent:init() self:setState({ - a = 1 + a = 1, }) end @@ -47,7 +47,7 @@ return function() function TestComponent:render() self:setState({ - a = 1 + a = 1, }) end @@ -69,7 +69,7 @@ return function() function TestComponent:shouldUpdate() self:setState({ - a = 1 + a = 1, }) end @@ -94,7 +94,7 @@ return function() function TestComponent:willUpdate() self:setState({ - a = 1 + a = 1, }) end @@ -118,7 +118,7 @@ return function() function TestComponent:willUnmount() self:setState({ - a = 1 + a = 1, }) end @@ -146,7 +146,7 @@ return function() end self:setState({ - value = 0 + value = 0, }) end @@ -160,7 +160,7 @@ return function() expect(getStateCallback().value).to.equal(0) setStateCallback({ - value = None + value = None, }) expect(getStateCallback().value).to.equal(nil) @@ -186,7 +186,7 @@ return function() end self:setState({ - value = 0 + value = 0, }) end @@ -204,7 +204,7 @@ return function() expect(props).to.equal(getPropsCallback()) return { - value = state.value + 1 + value = state.value + 1, } end) @@ -224,7 +224,7 @@ return function() end self:setState({ - value = 0 + value = 0, }) end @@ -237,7 +237,7 @@ return function() local instance = noopReconciler.mountVirtualNode(element, nil, "Test") expect(renderCount).to.equal(1) - setStateCallback(function(state, props) + setStateCallback(function(_state, _props) return nil end) @@ -272,7 +272,7 @@ return function() return createElement(Child, { callback = function() self:setState({ - foo = "bar" + foo = "bar", }) end, }) @@ -314,7 +314,7 @@ return function() -- This guards against a stack overflow that would be OUR fault if not self.state.foo then self:setState({ - foo = "bar" + foo = "bar", }) end end, @@ -511,7 +511,7 @@ return function() setComponentState(function(state) return { - counter = state.counter + 1 + counter = state.counter + 1, } end) @@ -565,7 +565,7 @@ return function() function MyComponent:init() self:setState({ - status = "initial mount" + status = "initial mount", }) self.isMounted = false @@ -577,13 +577,13 @@ return function() function MyComponent:didMount() self:setState({ - status = "mounted" + status = "mounted", }) self.isMounted = true end - function MyComponent:didUpdate(oldProps, oldState) + function MyComponent:didUpdate(_oldProps, oldState) expect(oldState.status).to.equal("initial mount") expect(self.state.status).to.equal("mounted") diff --git a/src/Component.spec/shouldUpdate.spec.lua b/src/Component.spec/shouldUpdate.spec.lua index 9d53b989..73cf6c9a 100644 --- a/src/Component.spec/shouldUpdate.spec.lua +++ b/src/Component.spec/shouldUpdate.spec.lua @@ -172,4 +172,4 @@ return function() expect(renderSpy.callCount).to.equal(1) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/validateProps.spec.lua b/src/Component.spec/validateProps.spec.lua index c7278e0f..5759de7c 100644 --- a/src/Component.spec/validateProps.spec.lua +++ b/src/Component.spec/validateProps.spec.lua @@ -105,11 +105,11 @@ return function() noopReconciler.mountVirtualNode(element, hostParent, key) expect(validatePropsSpy.callCount).to.equal(1) validatePropsSpy:assertCalledWithDeepEqual({ - a = 1 + a = 1, }) setStateCallback({ - b = 1 + b = 1, }) expect(validatePropsSpy.callCount).to.equal(1) @@ -266,4 +266,4 @@ return function() expect(validatePropsSpy.callCount).to.equal(0) end) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/willUnmount.spec.lua b/src/Component.spec/willUnmount.spec.lua index 590b61d1..e1448aa4 100644 --- a/src/Component.spec/willUnmount.spec.lua +++ b/src/Component.spec/willUnmount.spec.lua @@ -33,4 +33,4 @@ return function() expect(Type.of(values.self)).to.equal(Type.StatefulComponentInstance) end) -end \ No newline at end of file +end diff --git a/src/Component.spec/willUpdate.spec.lua b/src/Component.spec/willUpdate.spec.lua index b83937fe..f50cd92d 100644 --- a/src/Component.spec/willUpdate.spec.lua +++ b/src/Component.spec/willUpdate.spec.lua @@ -60,7 +60,7 @@ return function() end self:setState({ - foo = 1 + foo = 1, }) end @@ -77,7 +77,7 @@ return function() expect(willUpdateSpy.callCount).to.equal(0) setComponentState({ - foo = 2 + foo = 2, }) expect(willUpdateSpy.callCount).to.equal(1) @@ -87,7 +87,7 @@ return function() expect(Type.of(values.self)).to.equal(Type.StatefulComponentInstance) assertDeepEqual(values.newProps, {}) assertDeepEqual(values.newState, { - foo = 2 + foo = 2, }) end) -end \ No newline at end of file +end diff --git a/src/ComponentLifecyclePhase.lua b/src/ComponentLifecyclePhase.lua index dd239635..4a1c95e8 100644 --- a/src/ComponentLifecyclePhase.lua +++ b/src/ComponentLifecyclePhase.lua @@ -16,4 +16,4 @@ local ComponentLifecyclePhase = strict({ Idle = Symbol.named("idle"), }, "ComponentLifecyclePhase") -return ComponentLifecyclePhase \ No newline at end of file +return ComponentLifecyclePhase diff --git a/src/Config.lua b/src/Config.lua index 54043503..0c73a25e 100644 --- a/src/Config.lua +++ b/src/Config.lua @@ -41,15 +41,13 @@ function Config.new() self._currentConfig = setmetatable({}, { __index = function(_, key) - local message = ( - "Invalid global configuration key %q. Valid configuration keys are: %s" - ):format( + local message = ("Invalid global configuration key %q. Valid configuration keys are: %s"):format( tostring(key), table.concat(defaultConfigKeys, ", ") ) error(message, 3) - end + end, }) -- We manually bind these methods here so that the Config's methods can be @@ -77,9 +75,7 @@ function Config:set(configValues) -- We only want to apply this configuration if it's valid! for key, value in pairs(configValues) do if defaultConfig[key] == nil then - local message = ( - "Invalid global configuration key %q (type %s). Valid configuration keys are: %s" - ):format( + local message = ("Invalid global configuration key %q (type %s). Valid configuration keys are: %s"):format( tostring(key), typeof(key), table.concat(defaultConfigKeys, ", ") @@ -92,11 +88,7 @@ function Config:set(configValues) if typeof(value) ~= "boolean" then local message = ( "Invalid value %q (type %s) for global configuration key %q. Valid values are: true, false" - ):format( - tostring(value), - typeof(value), - tostring(key) - ) + ):format(tostring(value), typeof(value), tostring(key)) error(message, 3) end @@ -124,4 +116,4 @@ function Config:scoped(configValues, callback) assert(success, result) end -return Config \ No newline at end of file +return Config diff --git a/src/Config.spec.lua b/src/Config.spec.lua index 08a884fc..6e5e6bfb 100644 --- a/src/Config.spec.lua +++ b/src/Config.spec.lua @@ -49,4 +49,4 @@ return function() expect(err:find(goodKey)).to.be.ok() expect(err:find(badValue)).to.be.ok() end) -end \ No newline at end of file +end diff --git a/src/ElementKind.lua b/src/ElementKind.lua index 22e1e539..649b2fde 100644 --- a/src/ElementKind.lua +++ b/src/ElementKind.lua @@ -48,4 +48,4 @@ getmetatable(ElementKind).__index = ElementKindInternal strict(ElementKindInternal, "ElementKind") -return ElementKind \ No newline at end of file +return ElementKind diff --git a/src/ElementKind.spec.lua b/src/ElementKind.spec.lua index 80f8c4e1..197e97f7 100644 --- a/src/ElementKind.spec.lua +++ b/src/ElementKind.spec.lua @@ -30,8 +30,7 @@ return function() end) it("should handle function components", function() - local function foo() - end + local function foo() end expect(ElementKind.fromComponent(foo)).to.equal(ElementKind.Function) end) @@ -51,4 +50,4 @@ return function() expect(ElementKind.fromComponent(newproxy(true))).to.equal(nil) end) end) -end \ No newline at end of file +end diff --git a/src/ElementUtils.lua b/src/ElementUtils.lua index 971b6b19..01f2b2e3 100644 --- a/src/ElementUtils.lua +++ b/src/ElementUtils.lua @@ -96,4 +96,4 @@ function ElementUtils.getElementByKey(elements, hostKey) error("Invalid elements") end -return ElementUtils \ No newline at end of file +return ElementUtils diff --git a/src/ElementUtils.spec.lua b/src/ElementUtils.spec.lua index 3457abb6..1b0ce6dd 100644 --- a/src/ElementUtils.spec.lua +++ b/src/ElementUtils.spec.lua @@ -92,4 +92,4 @@ return function() expect(ElementUtils.getElementByKey(children, "a")).to.equal(nil) end) end) -end \ No newline at end of file +end diff --git a/src/GlobalConfig.lua b/src/GlobalConfig.lua index 32198357..76f2d900 100644 --- a/src/GlobalConfig.lua +++ b/src/GlobalConfig.lua @@ -4,4 +4,4 @@ local Config = require(script.Parent.Config) -return Config.new() \ No newline at end of file +return Config.new() diff --git a/src/GlobalConfig.spec.lua b/src/GlobalConfig.spec.lua index 760a2a36..1fa95977 100644 --- a/src/GlobalConfig.spec.lua +++ b/src/GlobalConfig.spec.lua @@ -6,4 +6,4 @@ return function() expect(GlobalConfig.set).to.be.ok() expect(GlobalConfig.get).to.be.ok() end) -end \ No newline at end of file +end diff --git a/src/Logging.lua b/src/Logging.lua index 17a9d6de..13f7190e 100644 --- a/src/Logging.lua +++ b/src/Logging.lua @@ -48,7 +48,7 @@ local logInfoMetatable = {} more easily. ]] function logInfoMetatable:__tostring() - local outputBuffer = {"LogInfo {"} + local outputBuffer = { "LogInfo {" } local errorCount = #self.errors local warningCount = #self.warnings @@ -156,4 +156,4 @@ function Logging.warnOnce(messageTemplate, ...) Logging.warn(messageTemplate, ...) end -return Logging \ No newline at end of file +return Logging diff --git a/src/None.lua b/src/None.lua index 9f25d3ae..320bd3c0 100644 --- a/src/None.lua +++ b/src/None.lua @@ -4,4 +4,4 @@ local Symbol = require(script.Parent.Symbol) -- stored in tables. local None = Symbol.named("None") -return None \ No newline at end of file +return None diff --git a/src/NoopRenderer.lua b/src/NoopRenderer.lua index 8d19157e..d74f84f1 100644 --- a/src/NoopRenderer.lua +++ b/src/NoopRenderer.lua @@ -11,14 +11,12 @@ function NoopRenderer.isHostObject(target) return target == nil end -function NoopRenderer.mountHostNode(reconciler, node) -end +function NoopRenderer.mountHostNode(_reconciler, _node) end -function NoopRenderer.unmountHostNode(reconciler, node) -end +function NoopRenderer.unmountHostNode(_reconciler, _node) end -function NoopRenderer.updateHostNode(reconciler, node, newElement) +function NoopRenderer.updateHostNode(_reconciler, node, _newElement) return node end -return NoopRenderer \ No newline at end of file +return NoopRenderer diff --git a/src/Portal.lua b/src/Portal.lua index 4db0a37a..0bb9c329 100644 --- a/src/Portal.lua +++ b/src/Portal.lua @@ -2,4 +2,4 @@ local Symbol = require(script.Parent.Symbol) local Portal = Symbol.named("Portal") -return Portal \ No newline at end of file +return Portal diff --git a/src/PropMarkers/Change.lua b/src/PropMarkers/Change.lua index 2a20adbf..c31e9dee 100644 --- a/src/PropMarkers/Change.lua +++ b/src/PropMarkers/Change.lua @@ -22,7 +22,7 @@ local changeMetatable = { } setmetatable(Change, { - __index = function(self, propertyName) + __index = function(_self, propertyName) local changeListener = { [Type] = Type.HostChangeEvent, name = propertyName, diff --git a/src/PropMarkers/Change.spec.lua b/src/PropMarkers/Change.spec.lua index 903099d8..f073cf1f 100644 --- a/src/PropMarkers/Change.spec.lua +++ b/src/PropMarkers/Change.spec.lua @@ -16,4 +16,4 @@ return function() expect(a).to.equal(b) expect(a).never.to.equal(c) end) -end \ No newline at end of file +end diff --git a/src/PropMarkers/Children.lua b/src/PropMarkers/Children.lua index 8c320ddf..9dd105cc 100644 --- a/src/PropMarkers/Children.lua +++ b/src/PropMarkers/Children.lua @@ -2,4 +2,4 @@ local Symbol = require(script.Parent.Parent.Symbol) local Children = Symbol.named("Children") -return Children \ No newline at end of file +return Children diff --git a/src/PropMarkers/Event.lua b/src/PropMarkers/Event.lua index f9aba02b..64193b02 100644 --- a/src/PropMarkers/Event.lua +++ b/src/PropMarkers/Event.lua @@ -24,7 +24,7 @@ local eventMetatable = { } setmetatable(Event, { - __index = function(self, eventName) + __index = function(_self, eventName) local event = { [Type] = Type.HostEvent, name = eventName, diff --git a/src/PropMarkers/Event.spec.lua b/src/PropMarkers/Event.spec.lua index fc34e917..eee1dfa7 100644 --- a/src/PropMarkers/Event.spec.lua +++ b/src/PropMarkers/Event.spec.lua @@ -16,4 +16,4 @@ return function() expect(a).to.equal(b) expect(a).never.to.equal(c) end) -end \ No newline at end of file +end diff --git a/src/PropMarkers/Ref.lua b/src/PropMarkers/Ref.lua index a86e4c2e..6ee5d4f4 100644 --- a/src/PropMarkers/Ref.lua +++ b/src/PropMarkers/Ref.lua @@ -2,4 +2,4 @@ local Symbol = require(script.Parent.Parent.Symbol) local Ref = Symbol.named("Ref") -return Ref \ No newline at end of file +return Ref diff --git a/src/PureComponent.lua b/src/PureComponent.lua index 02832987..ff3e09e5 100644 --- a/src/PureComponent.lua +++ b/src/PureComponent.lua @@ -38,4 +38,4 @@ function PureComponent:shouldUpdate(newProps, newState) return false end -return PureComponent \ No newline at end of file +return PureComponent diff --git a/src/PureComponent.spec.lua b/src/PureComponent.spec.lua index b1644373..1f60d109 100644 --- a/src/PureComponent.spec.lua +++ b/src/PureComponent.spec.lua @@ -72,4 +72,4 @@ return function() noopReconciler.unmountVirtualTree(tree) end) -end \ No newline at end of file +end diff --git a/src/RobloxRenderer.lua b/src/RobloxRenderer.lua index 4f528ad5..c3fff28a 100644 --- a/src/RobloxRenderer.lua +++ b/src/RobloxRenderer.lua @@ -44,9 +44,7 @@ local function applyRef(ref, newHostObject) Binding.update(ref, newHostObject) else -- TODO (#197): Better error message - error(("Invalid ref: Expected type Binding but got %s"):format( - typeof(ref) - )) + error(("Invalid ref: Expected type Binding but got %s"):format(typeof(ref))) end end diff --git a/src/RobloxRenderer.spec.lua b/src/RobloxRenderer.spec.lua index 99e3a1af..5473f1de 100644 --- a/src/RobloxRenderer.spec.lua +++ b/src/RobloxRenderer.spec.lua @@ -194,10 +194,10 @@ return function() local defaultStringValue = Instance.new("StringValue").Value local element = createElement("StringValue", { - Value = firstValue + Value = firstValue, }, { ChildA = createElement("IntValue", { - Value = 1 + Value = 1, }), ChildB = createElement("BoolValue", { Value = true, @@ -207,7 +207,7 @@ return function() }), ChildD = createElement("StringValue", { Value = "test", - }) + }), }) local node = reconciler.createVirtualNode(element, parent, key) @@ -221,7 +221,7 @@ return function() }, { -- ChildA changes element type. ChildA = createElement("StringValue", { - Value = "test" + Value = "test", }), -- ChildB changes child properties. ChildB = createElement("BoolValue", { @@ -722,7 +722,7 @@ return function() local hostParent = Instance.new("Folder") local hostKey = "Test" - local function parent(props) + local function parent(_props) return createElement("IntValue", {}, { fragmentA = createFragment({ key = createElement("StringValue", { @@ -776,8 +776,8 @@ return function() }), TheOtherValue = createElement("IntValue", { Value = 2, - }) - }) + }), + }), }) local node = reconciler.mountVirtualNode(fragment, hostParent, "Test") @@ -815,15 +815,14 @@ return function() local capturedContext function Consumer:init() capturedContext = { - hello = self:__getContext("hello") + hello = self:__getContext("hello"), } end - function Consumer:render() - end + function Consumer:render() end local element = createElement("Folder", nil, { - Consumer = createElement(Consumer) + Consumer = createElement(Consumer), }) local hostParent = nil local hostKey = "Context Test" @@ -869,14 +868,14 @@ return function() target = target, }, { Consumer = createElement(Consumer), - }) + }), }) local hostParent = nil local hostKey = "Some Key" reconciler.mountVirtualNode(element, hostParent, hostKey) assertDeepEqual(capturedContext, { - foo = "bar" + foo = "bar", }) end) end) @@ -890,11 +889,10 @@ return function() capturedContext = self._context end - function Consumer:render() - end + function Consumer:render() end local element = createElement("Folder", nil, { - Consumer = createElement(Consumer) + Consumer = createElement(Consumer), }) local hostParent = nil local hostKey = "Context Test" @@ -938,19 +936,18 @@ return function() target = target, }, { Consumer = createElement(Consumer), - }) + }), }) local hostParent = nil local hostKey = "Some Key" reconciler.mountVirtualNode(element, hostParent, hostKey) assertDeepEqual(capturedContext, { - foo = "bar" + foo = "bar", }) end) end) - describe("Integration Tests", function() local temporaryParent = nil beforeEach(function() @@ -973,7 +970,7 @@ return function() function ChildComponent:init() self:setState({ - firstTime = true + firstTime = true, }) end @@ -990,7 +987,7 @@ return function() function ChildComponent:didMount() childCoroutine = coroutine.create(function() self:setState({ - firstTime = false + firstTime = false, }) end) end @@ -999,7 +996,7 @@ return function() function ParentComponent:init() self:setState({ - count = 1 + count = 1, }) self.childAdded = function() @@ -1014,8 +1011,8 @@ return function() [Event.ChildAdded] = self.childAdded, }, { ChildComponent = createElement(ChildComponent, { - count = self.state.count - }) + count = self.state.count, + }), }) end @@ -1059,7 +1056,7 @@ return function() function ChildComponent:init() self:setState({ - firstTime = true + firstTime = true, }) end @@ -1071,14 +1068,14 @@ return function() end return createElement(LowestComponent, { - onDidMountCallback = self.props.onDidMountCallback + onDidMountCallback = self.props.onDidMountCallback, }) end function ChildComponent:didMount() childCoroutine = coroutine.create(function() self:setState({ - firstTime = false + firstTime = false, }) end) end @@ -1089,7 +1086,7 @@ return function() function ParentComponent:init() self:setState({ - count = 1 + count = 1, }) self.onDidMountCallback = function() @@ -1103,13 +1100,11 @@ return function() end function ParentComponent:render() - return createElement("Frame", { - - }, { + return createElement("Frame", {}, { ChildComponent = createElement(ChildComponent, { count = self.state.count, onDidMountCallback = self.onDidMountCallback, - }) + }), }) end @@ -1189,7 +1184,7 @@ return function() addInit(tostring(self)) self:setState({ - firstTime = true + firstTime = true, }) end @@ -1201,14 +1196,14 @@ return function() end return createElement(LowestComponent, { - onDidMountCallback = self.props.onDidMountCallback + onDidMountCallback = self.props.onDidMountCallback, }) end function ChildComponent:didMount() childCoroutine = coroutine.create(function() self:setState({ - firstTime = false + firstTime = false, }) end) end @@ -1223,7 +1218,7 @@ return function() function ParentComponent:init() self:setState({ - count = 1 + count = 1, }) self.onDidMountCallback = function() @@ -1237,13 +1232,11 @@ return function() end function ParentComponent:render() - return createElement("Frame", { - - }, { + return createElement("Frame", {}, { ChildComponent = createElement(ChildComponent, { count = self.state.count, onDidMountCallback = self.onDidMountCallback, - }) + }), }) end @@ -1286,7 +1279,7 @@ return function() return createElement("Frame") end - function LowestComponent:didUpdate(prevProps, prevState) + function LowestComponent:didUpdate(prevProps, _prevState) if prevProps.firstTime and not self.props.firstTime then self.props.onChangedCallback() end @@ -1296,7 +1289,7 @@ return function() function ChildComponent:init() self:setState({ - firstTime = true + firstTime = true, }) end @@ -1305,14 +1298,14 @@ return function() function ChildComponent:render() return createElement(LowestComponent, { firstTime = self.state.firstTime, - onChangedCallback = self.props.onChangedCallback + onChangedCallback = self.props.onChangedCallback, }) end function ChildComponent:didMount() childCoroutine = coroutine.create(function() self:setState({ - firstTime = false + firstTime = false, }) end) end @@ -1323,7 +1316,7 @@ return function() function ParentComponent:init() self:setState({ - count = 1 + count = 1, }) self.onChangedCallback = function() @@ -1337,13 +1330,11 @@ return function() end function ParentComponent:render() - return createElement("Frame", { - - }, { + return createElement("Frame", {}, { ChildComponent = createElement(ChildComponent, { count = self.state.count, onChangedCallback = self.onChangedCallback, - }) + }), }) end diff --git a/src/SingleEventManager.lua b/src/SingleEventManager.lua index bb579c78..3c5b96e9 100644 --- a/src/SingleEventManager.lua +++ b/src/SingleEventManager.lua @@ -58,10 +58,7 @@ function SingleEventManager:connectPropertyChange(key, listener) end) if not success then - error(("Cannot get changed signal on property %q: %s"):format( - tostring(key), - event - ), 0) + error(("Cannot get changed signal on property %q: %s"):format(tostring(key), event), 0) end self:_connect(CHANGE_PREFIX .. key, event, listener) @@ -126,7 +123,8 @@ function SingleEventManager:resume() local success, result = coroutine.resume( listenerCo, self._instance, - unpack(eventInvocation, 3, 2 + argumentCount)) + unpack(eventInvocation, 3, 2 + argumentCount) + ) -- If the listener threw an error, we log it as a warning, since -- there's no way to write error text in Roblox Lua without killing @@ -144,4 +142,4 @@ function SingleEventManager:resume() self._suspendedEventQueue = {} end -return SingleEventManager \ No newline at end of file +return SingleEventManager diff --git a/src/SingleEventManager.spec.lua b/src/SingleEventManager.spec.lua index 9d87e271..d978282e 100644 --- a/src/SingleEventManager.spec.lua +++ b/src/SingleEventManager.spec.lua @@ -98,7 +98,7 @@ return function() manager:resume() expect(eventSpy.callCount).to.equal(4) - assertDeepEqual(recordedValues, {1, 2, 3, 4}) + assertDeepEqual(recordedValues, { 1, 2, 3, 4 }) end) it("should not invoke events fired during suspension but disconnected before resumption", function() @@ -236,4 +236,4 @@ return function() end).to.throw() end) end) -end \ No newline at end of file +end diff --git a/src/Symbol.lua b/src/Symbol.lua index 305d66a9..3e9b951e 100644 --- a/src/Symbol.lua +++ b/src/Symbol.lua @@ -1,3 +1,4 @@ +--!nonstrict --[[ A 'Symbol' is an opaque marker type. @@ -27,4 +28,4 @@ function Symbol.named(name) return self end -return Symbol \ No newline at end of file +return Symbol diff --git a/src/Symbol.spec.lua b/src/Symbol.spec.lua index e05061da..c9be1503 100644 --- a/src/Symbol.spec.lua +++ b/src/Symbol.spec.lua @@ -21,4 +21,4 @@ return function() expect(symbolA).never.to.equal(symbolB) end) end) -end \ No newline at end of file +end diff --git a/src/Type.lua b/src/Type.lua index 156ee0ea..8c5ce212 100644 --- a/src/Type.lua +++ b/src/Type.lua @@ -45,4 +45,4 @@ end strict(TypeInternal, "Type") -return Type \ No newline at end of file +return Type diff --git a/src/Type.spec.lua b/src/Type.spec.lua index f2477093..0883fa58 100644 --- a/src/Type.spec.lua +++ b/src/Type.spec.lua @@ -15,10 +15,10 @@ return function() it("should return the assigned type", function() local test = { - [Type] = Type.Element + [Type] = Type.Element, } expect(Type.of(test)).to.equal(Type.Element) end) end) -end \ No newline at end of file +end diff --git a/src/assertDeepEqual.lua b/src/assertDeepEqual.lua index 3f422d85..c43dd26a 100644 --- a/src/assertDeepEqual.lua +++ b/src/assertDeepEqual.lua @@ -8,10 +8,7 @@ local function deepEqual(a, b) if typeof(a) ~= typeof(b) then - local message = ("{1} is of type %s, but {2} is of type %s"):format( - typeof(a), - typeof(b) - ) + local message = ("{1} is of type %s, but {2} is of type %s"):format(typeof(a), typeof(b)) return false, message end @@ -60,9 +57,7 @@ local function assertDeepEqual(a, b) local success, innerMessageTemplate = deepEqual(a, b) if not success then - local innerMessage = innerMessageTemplate - :gsub("{1}", "first") - :gsub("{2}", "second") + local innerMessage = innerMessageTemplate:gsub("{1}", "first"):gsub("{2}", "second") local message = ("Values were not deep-equal.\n%s"):format(innerMessage) @@ -70,4 +65,4 @@ local function assertDeepEqual(a, b) end end -return assertDeepEqual \ No newline at end of file +return assertDeepEqual diff --git a/src/assertDeepEqual.spec.lua b/src/assertDeepEqual.spec.lua index bece8d73..67f5f16f 100644 --- a/src/assertDeepEqual.spec.lua +++ b/src/assertDeepEqual.spec.lua @@ -28,10 +28,10 @@ return function() assertDeepEqual(someFunction, theSameFunction) local A = { - foo = someFunction + foo = someFunction, } local B = { - foo = theSameFunction + foo = theSameFunction, } assertDeepEqual(A, B) @@ -50,14 +50,14 @@ return function() nested = { foo = 1, bar = 2, - } + }, } local B = { foo = "bar", nested = { foo = 1, bar = 2, - } + }, } assertDeepEqual(A, B) @@ -67,7 +67,7 @@ return function() nested = { foo = 1, bar = 3, - } + }, } local success, message = pcall(assertDeepEqual, A, C) @@ -93,7 +93,11 @@ return function() foo = "bar", } - expect(function() assertDeepEqual(equalArgsA, nonEqualArgs) end).to.throw() - expect(function() assertDeepEqual(nonEqualArgs, equalArgsA) end).to.throw() + expect(function() + assertDeepEqual(equalArgsA, nonEqualArgs) + end).to.throw() + expect(function() + assertDeepEqual(nonEqualArgs, equalArgsA) + end).to.throw() end) -end \ No newline at end of file +end diff --git a/src/assign.lua b/src/assign.lua index 704c1659..3a18dbcd 100644 --- a/src/assign.lua +++ b/src/assign.lua @@ -24,4 +24,4 @@ local function assign(target, ...) return target end -return assign \ No newline at end of file +return assign diff --git a/src/assign.spec.lua b/src/assign.spec.lua index 24784a16..6ebe5b75 100644 --- a/src/assign.spec.lua +++ b/src/assign.spec.lua @@ -65,4 +65,4 @@ return function() expect(target.foo).to.equal(source2.foo) end) -end \ No newline at end of file +end diff --git a/src/createContext.lua b/src/createContext.lua index e4dcae15..f8b71b15 100644 --- a/src/createContext.lua +++ b/src/createContext.lua @@ -66,7 +66,7 @@ local function createConsumer(context) end end - function Consumer:init(props) + function Consumer:init(_props) -- This value may be nil, which indicates that our consumer is not a -- descendant of a provider for this context item. self.contextEntry = self:__getContext(context.key) diff --git a/src/createContext.spec.lua b/src/createContext.spec.lua index 4b436b86..ed68961e 100644 --- a/src/createContext.spec.lua +++ b/src/createContext.spec.lua @@ -115,11 +115,14 @@ return function() expect(valueSpy.callCount).to.equal(1) valueSpy:assertCalledWith("NewTest") - noopReconciler.updateVirtualTree(tree, createElement(context.Provider, { - value = "ThirdTest", - }, { - Listener = createElement(Listener), - })) + noopReconciler.updateVirtualTree( + tree, + createElement(context.Provider, { + value = "ThirdTest", + }, { + Listener = createElement(Listener), + }) + ) expect(valueSpy.callCount).to.equal(2) valueSpy:assertCalledWith("ThirdTest") @@ -165,13 +168,16 @@ return function() expect(valueSpy.callCount).to.equal(1) valueSpy:assertCalledWith("NewTest") - noopReconciler.updateVirtualTree(tree, createElement(context.Provider, { - value = "ThirdTest", - }, { - Blocker = createElement(UpdateBlocker, nil, { - Listener = createElement(Listener), - }), - })) + noopReconciler.updateVirtualTree( + tree, + createElement(context.Provider, { + value = "ThirdTest", + }, { + Blocker = createElement(UpdateBlocker, nil, { + Listener = createElement(Listener), + }), + }) + ) expect(valueSpy.callCount).to.equal(2) valueSpy:assertCalledWith("ThirdTest") @@ -312,8 +318,7 @@ return function() local context = createContext({}) local LowestComponent = Component:extend("LowestComponent") - function LowestComponent:init() - end + function LowestComponent:init() end function LowestComponent:render() return createElement("Frame") @@ -324,8 +329,7 @@ return function() end local FirstComponent = Component:extend("FirstComponent") - function FirstComponent:init() - end + function FirstComponent:init() end function FirstComponent:render() return createElement(context.Consumer, { @@ -349,7 +353,7 @@ return function() end return createElement(LowestComponent, { - onDidMountCallback = self.props.onDidMountCallback + onDidMountCallback = self.props.onDidMountCallback, }) end @@ -383,7 +387,7 @@ return function() count = self.state.count, onDidMountCallback = self.onDidMountCallback, }), - }) + }), }) end @@ -398,4 +402,4 @@ return function() childCallback() end).never.to.throw() end) -end \ No newline at end of file +end diff --git a/src/createElement.lua b/src/createElement.lua index b902219f..b3cece14 100644 --- a/src/createElement.lua +++ b/src/createElement.lua @@ -71,4 +71,4 @@ local function createElement(component, props, children) return element end -return createElement \ No newline at end of file +return createElement diff --git a/src/createElement.spec.lua b/src/createElement.spec.lua index 6e05709a..f6ed6a9d 100644 --- a/src/createElement.spec.lua +++ b/src/createElement.spec.lua @@ -18,8 +18,7 @@ return function() end) it("should create new functional elements", function() - local element = createElement(function() - end) + local element = createElement(function() end) expect(element).to.be.ok() expect(Type.of(element)).to.equal(Type.Element) @@ -107,4 +106,4 @@ return function() expect(element.source).to.be.a("string") end) end) -end \ No newline at end of file +end diff --git a/src/createFragment.lua b/src/createFragment.lua index 91554f39..8af1b28c 100644 --- a/src/createFragment.lua +++ b/src/createFragment.lua @@ -9,4 +9,4 @@ local function createFragment(elements) } end -return createFragment \ No newline at end of file +return createFragment diff --git a/src/createFragment.spec.lua b/src/createFragment.spec.lua index 45de6c71..3f16669b 100644 --- a/src/createFragment.spec.lua +++ b/src/createFragment.spec.lua @@ -14,8 +14,8 @@ return function() it("should accept children", function() local subFragment = createFragment({}) - local fragment = createFragment({key = subFragment}) + local fragment = createFragment({ key = subFragment }) expect(fragment.elements.key).to.equal(subFragment) end) -end \ No newline at end of file +end diff --git a/src/createReconciler.lua b/src/createReconciler.lua index 2ff86467..0d7046fa 100644 --- a/src/createReconciler.lua +++ b/src/createReconciler.lua @@ -1,3 +1,4 @@ +--!nonstrict local Type = require(script.Parent.Type) local ElementKind = require(script.Parent.ElementKind) local ElementUtils = require(script.Parent.ElementUtils) @@ -152,16 +153,16 @@ local function createReconciler(renderer) end local function updateVirtualNodeWithRenderResult(virtualNode, hostParent, renderResult) - if Type.of(renderResult) == Type.Element - or renderResult == nil - or typeof(renderResult) == "boolean" - then + if Type.of(renderResult) == Type.Element or renderResult == nil or typeof(renderResult) == "boolean" then updateChildren(virtualNode, hostParent, renderResult) else - error(("%s\n%s"):format( - "Component returned invalid children:", - virtualNode.currentElement.source or "" - ), 0) + error( + ("%s\n%s"):format( + "Component returned invalid children:", + virtualNode.currentElement.source or "" + ), + 0 + ) end end @@ -177,6 +178,7 @@ local function createReconciler(renderer) local kind = ElementKind.of(virtualNode.currentElement) + -- selene: allow(if_same_then_else) if kind == ElementKind.Host then renderer.unmountHostNode(reconciler, virtualNode) elseif kind == ElementKind.Function then @@ -302,7 +304,10 @@ local function createReconciler(renderer) ]] local function createVirtualNode(element, hostParent, hostKey, context, legacyContext) if config.internalTypeChecks then - internalAssert(renderer.isHostObject(hostParent) or hostParent == nil, "Expected arg #2 to be a host object") + internalAssert( + renderer.isHostObject(hostParent) or hostParent == nil, + "Expected arg #2 to be a host object" + ) internalAssert(typeof(context) == "table" or context == nil, "Expected arg #4 to be of type table or nil") internalAssert( typeof(legacyContext) == "table" or legacyContext == nil, @@ -377,7 +382,10 @@ local function createReconciler(renderer) ]] function mountVirtualNode(element, hostParent, hostKey, context, legacyContext) if config.internalTypeChecks then - internalAssert(renderer.isHostObject(hostParent) or hostParent == nil, "Expected arg #2 to be a host object") + internalAssert( + renderer.isHostObject(hostParent) or hostParent == nil, + "Expected arg #2 to be a host object" + ) internalAssert( typeof(legacyContext) == "table" or legacyContext == nil, "Expected arg #5 to be of type table or nil" diff --git a/src/createReconciler.spec.lua b/src/createReconciler.spec.lua index 193dd256..e82a68aa 100644 --- a/src/createReconciler.spec.lua +++ b/src/createReconciler.spec.lua @@ -171,7 +171,7 @@ return function() describe("Function components", function() it("should mount and unmount function components", function() - local componentSpy = createSpy(function(props) + local componentSpy = createSpy(function(_props) return nil end) @@ -197,7 +197,7 @@ return function() end) it("should mount single children of function components", function() - local childComponentSpy = createSpy(function(props) + local childComponentSpy = createSpy(function(_props) return nil end) @@ -235,11 +235,11 @@ return function() end) it("should mount fragments returned by function components", function() - local childAComponentSpy = createSpy(function(props) + local childAComponentSpy = createSpy(function(_props) return nil end) - local childBComponentSpy = createSpy(function(props) + local childBComponentSpy = createSpy(function(_props) return nil end) @@ -306,14 +306,14 @@ return function() end) it("should mount all fragment's children", function() - local childComponentSpy = createSpy(function(props) + local childComponentSpy = createSpy(function(_props) return nil end) local elements = {} local totalElements = 5 - for i=1, totalElements do - elements["key"..tostring(i)] = createElement(childComponentSpy.value, {}) + for i = 1, totalElements do + elements["key" .. tostring(i)] = createElement(childComponentSpy.value, {}) end local fragments = createFragment(elements) @@ -323,4 +323,4 @@ return function() expect(childComponentSpy.callCount).to.equal(totalElements) end) end) -end \ No newline at end of file +end diff --git a/src/createReconcilerCompat.lua b/src/createReconcilerCompat.lua index e79cf5ac..d60c9879 100644 --- a/src/createReconcilerCompat.lua +++ b/src/createReconcilerCompat.lua @@ -44,4 +44,4 @@ local function createReconcilerCompat(reconciler) return compat end -return createReconcilerCompat \ No newline at end of file +return createReconcilerCompat diff --git a/src/createReconcilerCompat.spec.lua b/src/createReconcilerCompat.spec.lua index ea4d0789..ea0ceb6f 100644 --- a/src/createReconcilerCompat.spec.lua +++ b/src/createReconcilerCompat.spec.lua @@ -79,4 +79,4 @@ return function() expect(#logInfo.warnings).to.equal(1) expect(logInfo.warnings[1]:find("reconcile")).to.be.ok() end) -end \ No newline at end of file +end diff --git a/src/createRef.lua b/src/createRef.lua index c13e1b55..ad0ef4d1 100644 --- a/src/createRef.lua +++ b/src/createRef.lua @@ -13,21 +13,21 @@ local function createRef() A ref is just redirected to a binding via its metatable ]] setmetatable(ref, { - __index = function(self, key) + __index = function(_self, key) if key == "current" then return binding:getValue() else return binding[key] end end, - __newindex = function(self, key, value) + __newindex = function(_self, key, value) if key == "current" then error("Cannot assign to the 'current' property of refs", 2) end binding[key] = value end, - __tostring = function(self) + __tostring = function(_self) return ("RoactRef(%s)"):format(tostring(binding:getValue())) end, }) @@ -35,4 +35,4 @@ local function createRef() return ref end -return createRef \ No newline at end of file +return createRef diff --git a/src/createRef.spec.lua b/src/createRef.spec.lua index 553e79d5..1b3886b2 100644 --- a/src/createRef.spec.lua +++ b/src/createRef.spec.lua @@ -52,4 +52,4 @@ return function() expect(ref:getValue()).to.equal(10) expect(ref:getValue()).to.equal(ref.current) end) -end \ No newline at end of file +end diff --git a/src/createSignal.lua b/src/createSignal.lua index f3e0add2..8fec5c71 100644 --- a/src/createSignal.lua +++ b/src/createSignal.lua @@ -17,7 +17,7 @@ local function createSignal() local suspendedConnections = {} local firing = false - local function subscribe(self, callback) + local function subscribe(_self, callback) assert(typeof(callback) == "function", "Can only subscribe to signals with a function.") local connection = { @@ -44,7 +44,7 @@ local function createSignal() return disconnect end - local function fire(self, ...) + local function fire(_self, ...) firing = true for callback, connection in pairs(connections) do if not connection.disconnected and not suspendedConnections[callback] then diff --git a/src/createSignal.spec.lua b/src/createSignal.spec.lua index 822df8d4..1d59ba0b 100644 --- a/src/createSignal.spec.lua +++ b/src/createSignal.spec.lua @@ -92,7 +92,7 @@ return function() local disconnectA local spyA = createSpy() - local listener = function(a, b) + local listener = function(_a, _b) disconnectA = signal:subscribe(spyA.value) end @@ -151,4 +151,4 @@ return function() signal:fire(a) expect(spyA.callCount).to.equal(2) end) -end \ No newline at end of file +end diff --git a/src/createSpy.lua b/src/createSpy.lua index baeba1cf..bce0b137 100644 --- a/src/createSpy.lua +++ b/src/createSpy.lua @@ -1,3 +1,4 @@ +--!strict --[[ A utility used to create a function spy that can be used to robustly test that functions are invoked the correct number of times and with the correct @@ -9,30 +10,26 @@ local assertDeepEqual = require(script.Parent.assertDeepEqual) local function createSpy(inner) - local self = { - callCount = 0, - values = {}, - valuesLength = 0, - } - + local self = {} + self.callCount = 0 + self.values = {} + self.valuesLength = 0 self.value = function(...) self.callCount = self.callCount + 1 - self.values = {...} + self.values = { ... } self.valuesLength = select("#", ...) if inner ~= nil then return inner(...) end + return nil end self.assertCalledWith = function(_, ...) local len = select("#", ...) if self.valuesLength ~= len then - error(("Expected %d arguments, but was called with %d arguments"):format( - self.valuesLength, - len - ), 2) + error(("Expected %d arguments, but was called with %d arguments"):format(self.valuesLength, len), 2) end for i = 1, len do @@ -46,10 +43,7 @@ local function createSpy(inner) local len = select("#", ...) if self.valuesLength ~= len then - error(("Expected %d arguments, but was called with %d arguments"):format( - self.valuesLength, - len - ), 2) + error(("Expected %d arguments, but was called with %d arguments"):format(self.valuesLength, len), 2) end for i = 1, len do @@ -82,4 +76,4 @@ local function createSpy(inner) return self end -return createSpy \ No newline at end of file +return createSpy diff --git a/src/createSpy.spec.lua b/src/createSpy.spec.lua index 86936939..59f6b2ca 100644 --- a/src/createSpy.spec.lua +++ b/src/createSpy.spec.lua @@ -87,4 +87,4 @@ return function() expect(captured.b).to.equal(2) end) end) -end \ No newline at end of file +end diff --git a/src/forwardRef.lua b/src/forwardRef.lua index 77fff90d..c7446c7d 100644 --- a/src/forwardRef.lua +++ b/src/forwardRef.lua @@ -25,4 +25,4 @@ local function forwardRef(render) end end -return forwardRef \ No newline at end of file +return forwardRef diff --git a/src/forwardRef.spec.lua b/src/forwardRef.spec.lua index 6d65101c..c22fdb07 100644 --- a/src/forwardRef.spec.lua +++ b/src/forwardRef.spec.lua @@ -29,19 +29,19 @@ return function() end return createElement("Frame", nil, { First = createElement("Frame", { - [Ref] = firstRef + [Ref] = firstRef, }, { Child = createElement("TextLabel", { - Text = "First" - }) + Text = "First", + }), }), Second = createElement("ScrollingFrame", { - [Ref] = secondRef + [Ref] = secondRef, }, { Child = createElement("TextLabel", { - Text = "Second" - }) - }) + Text = "Second", + }), + }), }) end @@ -69,7 +69,7 @@ return function() end) it("should support rendering nil", function() - local RefForwardingComponent = forwardRef(function(props, ref) + local RefForwardingComponent = forwardRef(function(_props, _ref) return nil end) @@ -82,7 +82,7 @@ return function() end) it("should support rendering nil for multiple children", function() - local RefForwardingComponent = forwardRef(function(props, ref) + local RefForwardingComponent = forwardRef(function(_props, _ref) return nil end) @@ -114,9 +114,12 @@ return function() end local RefForwardingComponent = forwardRef(function(props, ref) - return createElement(FunctionComponent, assign({}, props, { - forwardedRef = ref - })) + return createElement( + FunctionComponent, + assign({}, props, { + forwardedRef = ref, + }) + ) end) RefForwardingComponent.defaultProps = { optional = createElement("TextLabel"), @@ -188,7 +191,7 @@ return function() local function Child(props) value = props.value return createElement("Frame", { - [Ref] = props[Ref] + [Ref] = props[Ref], }) end @@ -212,7 +215,7 @@ return function() it("should forward a ref for multiple children", function() local function Child(props) return createElement("Frame", { - [Ref] = props[Ref] + [Ref] = props[Ref], }) end @@ -241,7 +244,7 @@ return function() local function Child(props) value = props.value return createElement("Frame", { - [Ref] = props[Ref] + [Ref] = props[Ref], }) end diff --git a/src/getDefaultInstanceProperty.lua b/src/getDefaultInstanceProperty.lua index 9a6a0950..b6c5014f 100644 --- a/src/getDefaultInstanceProperty.lua +++ b/src/getDefaultInstanceProperty.lua @@ -51,4 +51,4 @@ local function getDefaultInstanceProperty(className, propertyName) return ok, defaultValue end -return getDefaultInstanceProperty \ No newline at end of file +return getDefaultInstanceProperty diff --git a/src/getDefaultInstanceProperty.spec.lua b/src/getDefaultInstanceProperty.spec.lua index a1268203..4db61fc8 100644 --- a/src/getDefaultInstanceProperty.spec.lua +++ b/src/getDefaultInstanceProperty.spec.lua @@ -30,4 +30,4 @@ return function() expect(defaultValue).to.equal(false) end) -end \ No newline at end of file +end diff --git a/src/init.lua b/src/init.lua index 1696d235..f58d32a5 100644 --- a/src/init.lua +++ b/src/init.lua @@ -1,3 +1,4 @@ +--~strict --[[ Packages up the internals of Roact and exposes a public API for it. ]] @@ -12,7 +13,7 @@ local Binding = require(script.Binding) local robloxReconciler = createReconciler(RobloxRenderer) local reconcilerCompat = createReconcilerCompat(robloxReconciler) -local Roact = strict { +local Roact = strict({ Component = require(script.Component), createElement = require(script.createElement), createFragment = require(script.createFragment), @@ -42,8 +43,7 @@ local Roact = strict { setGlobalConfig = GlobalConfig.set, -- APIs that may change in the future without warning - UNSTABLE = { - }, -} + UNSTABLE = {}, +}) -return Roact \ No newline at end of file +return Roact diff --git a/src/init.spec.lua b/src/init.spec.lua index 23fef065..4d003350 100644 --- a/src/init.spec.lua +++ b/src/init.spec.lua @@ -44,9 +44,11 @@ return function() if not success then local existence = typeof(valueType) == "boolean" and "present" or "of type " .. valueType - local message = ( - "Expected public API member %q to be %s, but instead it was of type %s" - ):format(tostring(key), existence, typeof(Roact[key])) + local message = ("Expected public API member %q to be %s, but instead it was of type %s"):format( + tostring(key), + existence, + typeof(Roact[key]) + ) error(message) end @@ -54,12 +56,10 @@ return function() for key in pairs(Roact) do if publicApi[key] == nil then - local message = ( - "Found unknown public API key %q!" - ):format(tostring(key)) + local message = ("Found unknown public API key %q!"):format(tostring(key)) error(message) end end end) -end \ No newline at end of file +end diff --git a/src/internalAssert.lua b/src/internalAssert.lua index 87c5dfcb..11ab8c23 100644 --- a/src/internalAssert.lua +++ b/src/internalAssert.lua @@ -4,4 +4,4 @@ local function internalAssert(condition, message) end end -return internalAssert \ No newline at end of file +return internalAssert diff --git a/src/invalidSetStateMessages.lua b/src/invalidSetStateMessages.lua index 34571cee..60294bc0 100644 --- a/src/invalidSetStateMessages.lua +++ b/src/invalidSetStateMessages.lua @@ -41,4 +41,4 @@ This is a bug in Roact. It was triggered by the component %q. ]] -return invalidSetStateMessages \ No newline at end of file +return invalidSetStateMessages diff --git a/src/oneChild.lua b/src/oneChild.lua index 285d519d..0f68df17 100644 --- a/src/oneChild.lua +++ b/src/oneChild.lua @@ -25,4 +25,4 @@ local function oneChild(children) return child end -return oneChild \ No newline at end of file +return oneChild diff --git a/src/oneChild.spec.lua b/src/oneChild.spec.lua index 6540ce2d..588a466c 100644 --- a/src/oneChild.spec.lua +++ b/src/oneChild.spec.lua @@ -32,4 +32,4 @@ return function() it("should handle being passed nil", function() expect(oneChild(nil)).to.equal(nil) end) -end \ No newline at end of file +end diff --git a/src/strict.lua b/src/strict.lua index c1d21a5b..0f32dedf 100644 --- a/src/strict.lua +++ b/src/strict.lua @@ -1,27 +1,20 @@ +--!nonstrict local function strict(t, name) name = name or tostring(t) return setmetatable(t, { - __index = function(self, key) - local message = ("%q (%s) is not a valid member of %s"):format( - tostring(key), - typeof(key), - name - ) + __index = function(_self, key) + local message = ("%q (%s) is not a valid member of %s"):format(tostring(key), typeof(key), name) error(message, 2) end, - __newindex = function(self, key, value) - local message = ("%q (%s) is not a valid member of %s"):format( - tostring(key), - typeof(key), - name - ) + __newindex = function(_self, key, _value) + local message = ("%q (%s) is not a valid member of %s"):format(tostring(key), typeof(key), name) error(message, 2) end, }) end -return strict \ No newline at end of file +return strict diff --git a/src/strict.spec.lua b/src/strict.spec.lua index fc44bff7..f4d75f36 100644 --- a/src/strict.spec.lua +++ b/src/strict.spec.lua @@ -22,4 +22,4 @@ return function() t.c = 3 end).to.throw() end) -end \ No newline at end of file +end diff --git a/testez.toml b/testez.toml new file mode 100644 index 00000000..b8c0ceeb --- /dev/null +++ b/testez.toml @@ -0,0 +1,79 @@ +[[afterAll.args]] +type = "function" + +[[afterEach.args]] +type = "function" + +[[beforeAll.args]] +type = "function" + +[[beforeEach.args]] +type = "function" + +[[describe.args]] +type = "string" + +[[describe.args]] +type = "function" + +[[describeFOCUS.args]] +type = "string" + +[[describeFOCUS.args]] +type = "function" + +[[describeSKIP.args]] +type = "string" + +[[describeSKIP.args]] +type = "function" + +[[expect.args]] +type = "any" + +[[FIXME.args]] +type = "string" +required = false + +[FOCUS] +args = [] + +[[it.args]] +type = "string" + +[[it.args]] +type = "function" + +[[itFIXME.args]] +type = "string" + +[[itFIXME.args]] +type = "function" + +[[itFOCUS.args]] +type = "string" + +[[itFOCUS.args]] +type = "function" + +[[fit.args]] +type = "string" + +[[fit.args]] +type = "function" + +[[itSKIP.args]] +type = "string" + +[[itSKIP.args]] +type = "function" + +[[xit.args]] +type = "string" + +[[xit.args]] +type = "function" + +[SKIP] +args = [] +