Go to file
Kunal Mehta 829c53ef05 Add strict.lua to replace "Module:No globals"
For the most part, it is a good idea to avoid global variables and use
`local` variables instead. Quoting from the ScopeTutorial[1], "The
general rule is to always use local variables, unless it's necessary for
every part of your program to be able to access the variable (which is
very rare)."

Wikimedia module authors have written "Module:No globals", which errors
on the use of any global variable. On the English Wikipedia, this is
used on 32% of pages (18 million). Wikidata[2] indicates that it's been
copied to 334 other wikis.

Lua itself distributes an extra named "strict.lua"[3], which is what
this is based off of. Similar to bit32.lua, this is a pure-Lua library
that can be imported/enabled with `require( "strict" )` at the top of a
module.

The two changes I made from Lua's strict is to exempt the `arg` key,
which is used internally by Scribunto, and remove `what()`, since we
don't enable access to `debug.getinfo()` for security reasons.

[1] https://lua-users.org/wiki/ScopeTutorial
[2] https://www.wikidata.org/wiki/Q16748603
[3] http://www.lua.org/extras/5.1/strict.lua

Bug: T209310
Change-Id: I46ee6f630ac6b26c68c31becd1f3b9d961bcab29
2022-10-13 04:39:21 +00:00
.phan build: Load pcntl stub to pass phan on windows 2020-06-06 13:58:24 +02:00
i18n Localisation updates from https://translatewiki.net. 2022-10-10 10:21:09 +02:00
includes Add strict.lua to replace "Module:No globals" 2022-10-13 04:39:21 +00:00
modules Restore padding on #mw-scribunto-input to make cursor visible 2022-10-08 21:35:30 +00:00
tests Add strict.lua to replace "Module:No globals" 2022-10-13 04:39:21 +00:00
.eslintrc.json build: Updating mediawiki/mediawiki-phan-config to 0.10.4 2020-11-20 17:01:25 +00:00
.gitignore build: Upgrade eslint-config-wikimedia 0.12.0, drop grunt-jsonlint 2019-05-07 10:40:41 -07:00
.gitreview Whoops, track not trace 2016-10-24 17:03:31 -07:00
.phpcs.xml Namespace tests 2022-09-30 00:59:00 +00:00
.stylelintrc.json Use json extension for .stylelintrc 2017-08-19 10:27:54 +02:00
CODE_OF_CONDUCT.md build: Updating mediawiki/mediawiki-codesniffer to 22.0.0 2018-09-03 21:33:35 +00:00
composer.json build: Update mediawiki/mediawiki-phan-config to 0.12.0 2022-10-08 21:38:28 +00:00
COPYING Add strict.lua to replace "Module:No globals" 2022-10-13 04:39:21 +00:00
extension.json Use OOUI instead of jquery.ui for error popup 2022-10-08 20:33:27 +00:00
Gruntfile.js build: Updating dependencies 2021-01-30 10:41:13 +00:00
package-lock.json build: Updating ansi-regex to 5.0.1 2021-10-05 22:52:36 +00:00
package.json build: Updating dependencies 2021-09-11 22:36:44 +00:00
Scribunto.constants.php Remove PHP entry point 2019-06-21 00:02:08 +00:00
Scribunto.magic.php Add namespace and magic word translations for mnw and my 2019-10-18 20:03:05 +00:00
Scribunto.namespaces.php Namespace translations for Kyrgyz language 2022-06-09 10:06:27 +00:00