purescript / registry-dev

Development work related to the PureScript Registry
https://github.com/purescript/registry
97 stars 80 forks source link

Exclude Main and Test.Main as module names #598

Closed thomashoneyman closed 1 year ago

thomashoneyman commented 1 year ago

Fixes #566 by disallowing Main and Test.Main module names in library code due to their high chance of colliding with user module names. These really ought not be published to libraries and we now explicitly disallow it.

This PR uses parsePartialModule from lanugage-cst-parser as suggested by @natefaubion to reliably parse just the module header of a file: https://github.com/natefaubion/purescript-language-cst-parser/blob/7a0a4484f8abd91d688d297461209a75667e0da6/src/PureScript/CST.purs#L83-L84

I've adjusted our containsPursFile check to instead be validatePursModules; instead of walking their src directory to ensure there is at least one PureScript file, we now parse the module header of each module in their src directory and fail if either a) there are no modules or b) a module uses a reserved name.