{"id":13847202,"url":"https://github.com/JamieMason/eslint-plugin-move-files","last_synced_at":"2025-07-12T08:31:24.000Z","repository":{"id":35048128,"uuid":"194290676","full_name":"JamieMason/eslint-plugin-move-files","owner":"JamieMason","description":"Move and rename files while keeping imports up to date","archived":false,"fork":false,"pushed_at":"2022-05-29T07:27:54.000Z","size":153,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T23:29:52.194Z","etag":null,"topics":["eslint","eslint-plugin","eslint-rules","javascript","lint","linter","linting","move-files","nodejs","rename-files","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/eslint-plugin-move-files","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JamieMason.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"open_collective":"fold_left","custom":["https://www.paypal.me/foldleft"]}},"created_at":"2019-06-28T14:52:54.000Z","updated_at":"2023-07-27T12:05:34.000Z","dependencies_parsed_at":"2022-08-20T11:40:49.251Z","dependency_job_id":null,"html_url":"https://github.com/JamieMason/eslint-plugin-move-files","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/JamieMason/eslint-plugin-move-files","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamieMason%2Feslint-plugin-move-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamieMason%2Feslint-plugin-move-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamieMason%2Feslint-plugin-move-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamieMason%2Feslint-plugin-move-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JamieMason","download_url":"https://codeload.github.com/JamieMason/eslint-plugin-move-files/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamieMason%2Feslint-plugin-move-files/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264962200,"owners_count":23689756,"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","eslint-plugin","eslint-rules","javascript","lint","linter","linting","move-files","nodejs","rename-files","typescript"],"created_at":"2024-08-04T18:01:13.028Z","updated_at":"2025-07-12T08:31:23.647Z","avatar_url":"https://github.com/JamieMason.png","language":"TypeScript","funding_links":["https://opencollective.com/fold_left","https://www.paypal.me/foldleft"],"categories":["TypeScript"],"sub_categories":[],"readme":"# eslint-plugin-move-files\n\n\u003e Move and rename files while keeping imports up to date\n\n[![NPM version](http://img.shields.io/npm/v/eslint-plugin-move-files.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-move-files)\n[![NPM downloads](http://img.shields.io/npm/dm/eslint-plugin-move-files.svg?style=flat-square)](https://www.npmjs.com/package/eslint-plugin-move-files)\n[![Build Status](http://img.shields.io/travis/JamieMason/eslint-plugin-move-files/master.svg?style=flat-square)](https://travis-ci.org/JamieMason/eslint-plugin-move-files)\n[![Maintainability](https://api.codeclimate.com/v1/badges/170c5ae0fbf646e5678a/maintainability)](https://codeclimate.com/github/JamieMason/eslint-plugin-move-files/maintainability)\n\n## Table of Contents\n\n- [📣 Summary](#-summary)\n- [🌩 Installation](#-installation)\n- [🤫 Caveats](#-caveats)\n- [⚖️ Configuration](#️-configuration)\n- [🤔 Target Problem](#-target-problem)\n- [🙋🏿‍♀️ Getting Help](#♀️-getting-help)\n- [👀 Other Projects](#-other-projects)\n- [🤓 Author](#-author)\n\n## 📣 Summary\n\n- Move and rename files in bulk.\n- Update all [`import`][import] declarations and [`require`][require] statements\n  in the codebase.\n- Standardise where certain files should be named and located.\n- Automatically move new files to the correct locations.\n\n## 🌩 Installation\n\n```\nnpm install --save-dev eslint eslint-plugin-move-files\n```\n\n## 🤫 Caveats\n\n- This plugin is in alpha, more testing is needed on real projects.\n- It is best to run this rule on its own to avoid false-positives from plugins\n  such as `eslint-plugin-imports` while files are being moved but files\n  dependending on them have not yet been updated. This is necessary because the\n  order which rules and files will run is not predictable or guaranteed.\n\n## ⚖️ Configuration\n\n## npm Scripts\n\nIt is recommended to run this plugin on its own, before running the other ESLint\nRules in your project. In this example you would run `npm run lint` to achieve\nthis:\n\n```json\n{\n  \"scripts\": {\n    \"lint:fs\": \"eslint --fix --config .eslintrc-fs.js --no-inline-config 'src/**/*.js' 'test/**/*.js'\",\n    \"lint:js\": \"eslint --fix --config .eslintrc.js 'src/**/*.js' 'test/**/*.js'\",\n    \"lint\": \"npm run lint:fs \u0026\u0026 npm run lint:js\"\n  }\n}\n```\n\n### ESLint\n\nThese changes relate to the `.eslintrc` file explained in\n[Configuring ESLint](https://eslint.org/docs/user-guide/configuring). You will\nneed to ensure `'move-files'` is included in the `plugins` array and that a\n`'move-files/move-files'` property of the `rules` object is present and matches\nthe structure described below.\n\n```js\n{\n  \"root\": true,\n  \"parserOptions\": {\n    \"ecmaVersion\": 2019,\n    \"sourceType\": \"module\"\n  },\n  \"plugins\": [\"move-files\"],\n  \"rules\": {\n    \"move-files/move-files\": [\n      \"error\",\n      {\n        \"files\": {\n          // rename a file in-place\n          \"./src/rename-me.js\": \"./renamed.js\",\n          // move a file into a sibling of its current directory\n          \"./src/server.test.js\": \"../test/server.js\",\n          // convert a flat directory of files into module folders\n          \"./src/services/*.js\": \"./{name}/index.js\",\n          // use .jsx extension in all React components\n          \"./src/components/**/*.js\": \"./{name}.jsx\",\n          // locate tests alongside source\n          \"./test/*.js\": \"{rootDir}/src/{name}.spec.js\",\n          \"./test/*/*.js\": \"{rootDir}/src/{..}/{name}.spec.js\",\n          \"./test/*/*/*.js\": \"{rootDir}/src/{...}/{..}/{name}.spec.js\",\n          \"./test/*/*/*/*.js\": \"{rootDir}/src/{....}/{...}/{..}/{name}.spec.js\",\n          \"./test/*/*/*/*/*.js\": \"{rootDir}/src/{.....}/{....}/{...}/{..}/{name}.spec.js\",\n          \"./test/*/*/*/*/*/*.js\": \"{rootDir}/src/{......}/{.....}/{....}/{...}/{..}/{name}.spec.js\",\n          \"./test/*/*/*/*/*/*/*.js\": \"{rootDir}/src/{.......}/{......}/{.....}/{....}/{...}/{..}/{name}.spec.js\"\n        }\n      }\n    ]\n  }\n}\n```\n\n### `files` option\n\n`files` is an object whose keys define the **Sources** (which files should move)\nand whose values define the **Destinations** (where the files should move to).\n\n- Sources can match multiple files via the use of \"[Globs][globs]\".\n- Sources are resolved relative to the [`process.cwd()`][cwd] root directory of\n  your project.\n- Destinations are resolved relative to each matched source file.\n- Destinations can optionally use [tokens](#String-Interpolation) such as\n  `{name}` or `{ext}` to interpolate values parsed from the Source path.\n\n### String Interpolation\n\nUsing `src/lib/module.spec.js` as an example, the following data would be\navailable:\n\n```json\n{\n  \"rootDir\": \"/path/to/project\",\n  \"dir\": \"src/lib\",\n  \"base\": \"module.spec.js\",\n  \"name\": \"module\",\n  \"ext\": \"spec.js\",\n  \"dirs\": [\"src\", \"lib\"],\n  \"exts\": [\"spec\", \"js\"],\n  \"ancestors\": [\"lib\", \"src\"]\n}\n```\n\nThis dataset can be read using the following tokens. A destination of\n`'{rootDir}/test/{ancestors.0}/{name}.js'` for example would move this file to\n`/path/to/project/test/lib/module.js`.\n\n| Token                      | Value              |\n| -------------------------- | ------------------ |\n| `{rootDir}`                | `/path/to/project` |\n| `{dir}`                    | `src/lib`          |\n| `{base}` or `{.}`          | `module.spec.js`   |\n| `{name}`                   | `module`           |\n| `{ext}`                    | `spec.js`          |\n| `{dirs.0}`                 | `src`              |\n| `{dirs.1}`                 | `lib`              |\n| `{exts.0}`                 | `spec`             |\n| `{exts.1}`                 | `js`               |\n| `{ancestors.0}` or `{..}`  | `lib`              |\n| `{ancestors.1}` or `{...}` | `src`              |\n\n## 🤔 Target Problem\n\n### Moving files with increased confidence\n\nMoving and renaming files in a large codebase can be time-consuming and\nerror-prone due to:\n\n- The large number of files to search for and edit `import` declarations in.\n- The high probability of conflicts as you `git merge` from `master`.\n- The high probability of conflicts in other branches once yours is merged.\n\n### Maintaining a standard file structure\n\nImagine that you want to migrate your codebase from being organised by role to\nbe organised by feature. Once you've done the work of moving everything into the\nnew structure, you want Contributors to follow the new approach rather than the\nold, and you want it to be easy to fix if they don't.\n\n```\nOrganised by Role\n\n├── fixtures\n│   └── billing.js\n├── resolvers\n│   └── billing.js\n└── schema\n    └── billing.js\n\nOrganised by Feature\n\n└── billing\n    ├── fixtures.js\n    ├── resolvers.js\n    └── schema.js\n```\n\n\u003c!-- LINKS --\u003e\n\n[import]:\n  https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import\n[require]: https://nodejs.org/docs/latest-v10.x/api/modules.html#modules_require\n[cwd]: https://nodejs.org/docs/latest-v10.x/api/process.html#process_process_cwd\n[globs]: https://github.com/isaacs/node-glob#glob-primer\n\n## 🙋🏿‍♀️ Getting Help\n\nGet help with issues by creating a [Bug Report] or discuss ideas by opening a\n[Feature Request].\n\n[bug report]:\n  https://github.com/JamieMason/eslint-plugin-move-files/issues/new?template=bug_report.md\n[feature request]:\n  https://github.com/JamieMason/eslint-plugin-move-files/issues/new?template=feature_request.md\n\n## 👀 Other Projects\n\nIf you find my Open Source projects useful, please share them ❤️\n\n- [**eslint-formatter-git-log**](https://github.com/JamieMason/eslint-formatter-git-log)\u003cbr\u003eESLint\n  Formatter featuring Git Author, Date, and Hash\n- [**eslint-plugin-prefer-arrow-functions**](https://github.com/JamieMason/eslint-plugin-prefer-arrow-functions)\u003cbr\u003eConvert\n  functions to arrow functions\n- [**ImageOptim-CLI**](https://github.com/JamieMason/ImageOptim-CLI)\u003cbr\u003eAutomates\n  ImageOptim, ImageAlpha, and JPEGmini for Mac to make batch optimisation of\n  images part of your automated build process.\n- [**Jasmine-Matchers**](https://github.com/JamieMason/Jasmine-Matchers)\u003cbr\u003eWrite\n  Beautiful Specs with Custom Matchers\n- [**karma-benchmark**](https://github.com/JamieMason/karma-benchmark)\u003cbr\u003eRun\n  Benchmark.js over multiple Browsers, with CI compatible output\n- [**self-help**](https://github.com/JamieMason/self-help#readme)\u003cbr\u003eInteractive\n  Q\u0026A Guides for Web and the Command Line\n- [**syncpack**](https://github.com/JamieMason/syncpack#readme)\u003cbr\u003eManage\n  multiple package.json files, such as in Lerna Monorepos and Yarn Workspaces\n\n## 🤓 Author\n\n\u003cimg src=\"https://www.gravatar.com/avatar/acdf106ce071806278438d8c354adec8?s=100\" align=\"left\"\u003e\n\nI'm [Jamie Mason] from [Leeds] in England, I began Web Design and Development in\n1999 and have been Contracting and offering Consultancy as Fold Left Ltd\nsince 2012. Who I've worked with includes [Sky Sports], [Sky Bet], [Sky Poker],\nThe [Premier League], [William Hill], [Shell], [Betfair], and Football Clubs\nincluding [Leeds United], [Spurs], [West Ham], [Arsenal], and more.\n\n\u003cdiv align=\"center\"\u003e\n\n[![Follow JamieMason on GitHub][github badge]][github]      [![Follow fold_left on Twitter][twitter badge]][twitter]\n\n\u003c/div\u003e\n\n\u003c!-- images --\u003e\n\n[github badge]:\n  https://img.shields.io/github/followers/JamieMason.svg?style=social\u0026label=Follow\n[twitter badge]:\n  https://img.shields.io/twitter/follow/fold_left.svg?style=social\u0026label=Follow\n\n\u003c!-- links --\u003e\n\n[arsenal]: https://www.arsenal.com\n[betfair]: https://www.betfair.com\n[github]: https://github.com/JamieMason\n[jamie mason]: https://www.linkedin.com/in/jamiemasonleeds\n[leeds united]: https://www.leedsunited.com/\n[leeds]: https://www.instagram.com/visitleeds\n[premier league]: https://www.premierleague.com\n[shell]: https://www.shell.com\n[sky bet]: https://www.skybet.com\n[sky poker]: https://www.skypoker.com\n[sky sports]: https://www.skysports.com\n[spurs]: https://www.tottenhamhotspur.com\n[twitter]: https://twitter.com/fold_left\n[west ham]: https://www.whufc.com\n[william hill]: https://www.williamhill.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJamieMason%2Feslint-plugin-move-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJamieMason%2Feslint-plugin-move-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJamieMason%2Feslint-plugin-move-files/lists"}