[{"name":"NoTestValuesInProductionCode","comment":"\n\n@docs rule\n@docs Configuration, startsWith, endsWith\n\n","unions":[{"name":"Configuration","comment":" Configure how values should be tagged.\n","args":[],"cases":[]}],"aliases":[],"values":[{"name":"endsWith","comment":" A test-only value's name ends with the given string.\n","type":"String.String -> NoTestValuesInProductionCode.Configuration"},{"name":"rule","comment":" Reports when functions or values meant to be used only in tests are used in production source code.\n\n    config =\n        [ NoTestValuesInProductionCodeTest.rule\n            (NoTestValuesInProductionCodeTest.startsWith \"test_\")\n\n        -- or\n        , NoTestValuesInProductionCodeTest.rule\n            (NoTestValuesInProductionCodeTest.endsWith \"_TESTS_ONLY\")\n        ]\n\nThis rule is meant to allow you to expose values from your module that you need for writing tests, while preserving the\nmaking sure they are not misused in production code. You can read about the [problem and solution more in detail](https://jfmengels.net//test-only-values/).\n\n\n## Fail\n\n    -- NoTestValuesInProductionCodeTest.startsWith \"test_\"\n    grantAdminRights user =\n        { user | role = Role.test_admin }\n\n    -- NoTestValuesInProductionCodeTest.endsWith \"_TESTS_ONLY\"\n    grantAdminRights user =\n        { user | role = Role.admin_TESTS_ONLY }\n\n\n## Success\n\n    -- module RoleTest exposing (roleTest)\n    roleTest =\n        Test.describe \"Role\"\n            [ Test.test \"admins should be able to delete database \" <|\n                \\() -> Expect.true (Role.canDeleteDatabase Role.test_admin)\n            , Test.test \"users should not be able to delete database \" <|\n                \\() -> Expect.false (Role.canDeleteDatabase Role.user)\n            ]\n\nValues marked as test-only can be used in the declaration of other test values.\n\n    -- module User exposing (test_admin_user)\n    test_admin_user =\n        { id = \"001\"\n        , role = Role.test_admin\n        }\n\n\n## When (not) to enable this rule\n\nThis rule is useful only if you have instances where you wish to add guarantees to the usage of your data types, but\nneed to access internals in the context of your tests.\nAlso, for this rule to work well, the naming convention for test-only values needs to be communicated to the rest of the\nteam or project.\n\n\n## Try it out\n\nYou can try this rule out by running the following command:\n\n```bash\nelm-review --template jfmengels/elm-review-test-values/example --rules NoTestValuesInProductionCodeTest\n```\n\nThe example uses the following configuration:\n\n    config =\n        [ NoTestValuesInProductionCodeTest.rule\n            (NoTestValuesInProductionCodeTest.startsWith \"test_\")\n        ]\n\n","type":"NoTestValuesInProductionCode.Configuration -> Review.Rule.Rule"},{"name":"startsWith","comment":" A test-only value's name starts with the given string.\n","type":"String.String -> NoTestValuesInProductionCode.Configuration"}],"binops":[]}]