{"id":17087852,"url":"https://github.com/dan-lee/eslint-plugin-got","last_synced_at":"2026-05-02T15:37:39.414Z","repository":{"id":66291524,"uuid":"323717654","full_name":"dan-lee/eslint-plugin-got","owner":"dan-lee","description":"eslint rules for got et al","archived":false,"fork":false,"pushed_at":"2021-01-19T09:15:51.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-28T21:18:18.539Z","etag":null,"topics":["eslint","got","request"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dan-lee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-22T19:41:08.000Z","updated_at":"2021-01-19T19:25:52.000Z","dependencies_parsed_at":"2023-02-22T04:46:14.389Z","dependency_job_id":null,"html_url":"https://github.com/dan-lee/eslint-plugin-got","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-lee%2Feslint-plugin-got","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-lee%2Feslint-plugin-got/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-lee%2Feslint-plugin-got/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-lee%2Feslint-plugin-got/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dan-lee","download_url":"https://codeload.github.com/dan-lee/eslint-plugin-got/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245119592,"owners_count":20563763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","got","request"],"created_at":"2024-10-14T13:35:09.085Z","updated_at":"2026-05-02T15:37:39.370Z","avatar_url":"https://github.com/dan-lee.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eslint-plugin-got\n\n_(for the sake of a better name)_\n\n## Install\n\n```\nyarn add -D eslint-plugin-got\n\n# or\n\nnpm install -D eslint-plugin-got\n```\n\nAdd to `.eslintrc.js` or equivalents in plugins/rules section:\n\n```js\nmodule.exports = {\n  plugins: ['got'],\n  rules: {\n    'got/no-leading-slash': ['error', { imports: ['^got$', '^ky$'] }],\n  },\n}\n```\n\n## Disallow leading slashes in requests\n\n`got/no-leading-slash`\n\nIf you are using [`got`](https://github.com/sindresorhus/got) or [`ky`](https://github.com/sindresorhus/ky) with the `prefixUrl` option and constantly forget that you mustn't use a leading slash, this rule is for you.\n\nThis works for all request libraries with the same API and input restrictions.\nSo you can use it for `got`, `ky` or any created instances of it. You just need to specify the `imports` option in the configuration.\n\n**This is auto fixable.**\n\n```ts\n// Api.ts\nimport got from 'got'\nexport default got.extend({ prefixUrl: 'https://cats.com' })\n```\n\n```ts\n// .eslintrc.js\nmodule.exports = {\n  // all imports matching the pattern \".+/Api$\" will be considered for linting\n  'got/no-leading-slash': ['error', { imports: ['.+/Api$'] }],\n}\n```\n\n### Pass\n\n```ts\nimport api from './Api'\napi.get('unicorn')\n```\n\n### Fail\n\n```ts\nimport api from './Api'\n// The request input should not start with a leading slash. (at 2:8)\napi.get('/unicorn')\n// -----^\n\napi.get(`/unicorn/${id}`)\n// -----^\n```\n\nThe import call itself and the request method shortcuts will be checked:\n\n```ts\napi('request', ...args)\napi.get('request', ...args)\napi.post('request', ...args)\napi.put('request', ...args)\napi.patch('request', ...args)\napi.head('request', ...args)\napi.delete('request', ...args)\n```\n\n### Options\n\n#### imports\n\nType: `array`  \nDefault: `[]`\n\nTo enable the lint rule you can add regex pattern(s) which should match the import source (file or package):\n\n```json\n{\n  \"got/no-leading-slash\": [\"error\", { \"imports\": [\".+/Api$\"] }]\n}\n```\n\nIf you also want to prevent leading slashes in the calls of the packages `got`, `ky` and `ky-universal` you could use following config:\n\n```json\n{\n  \"got/no-leading-slash\": [\n    \"error\",\n    { \"imports\": [\"^got$\", \"^ky$\", \"^ky-universal$\", \".+/Api$\"] }\n  ]\n}\n```\n\n### Reasoning\n\nThis rule enforces that every request going through `got`, `ky` or an instance of it with the `prefixUrl` enabled must not start with a leading slash:\n\n\u003e **Note:** Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion. For example, when the prefix URL is `https://example.com/foo` and the input is `/bar`, there's ambiguity whether the resulting URL would become `https://example.com/foo/bar` or `https://example.com/bar`. The latter is used by browsers.\n\n(Source: https://github.com/sindresorhus/got#prefixurl)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-lee%2Feslint-plugin-got","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan-lee%2Feslint-plugin-got","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-lee%2Feslint-plugin-got/lists"}