@rushstack/eslint-plugin-packlets 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -192,7 +192,7 @@ module.exports = {
192
192
  ## Links
193
193
 
194
194
  - [CHANGELOG.md](
195
- https://github.com/microsoft/rushstack/blob/master/stack/eslint-plugin-packlets/CHANGELOG.md) - Find
195
+ https://github.com/microsoft/rushstack/blob/main/stack/eslint-plugin-packlets/CHANGELOG.md) - Find
196
196
  out what's new in the latest version
197
197
  - [@rushstack/eslint-config](https://www.npmjs.com/package/@rushstack/eslint-config) documentation
198
198
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/eslint-plugin-packlets",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "A lightweight alternative to NPM packages for organizing source files within a single project",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,7 +18,7 @@
18
18
  "main": "lib/index.js",
19
19
  "typings": "lib/index.d.ts",
20
20
  "dependencies": {
21
- "@rushstack/tree-pattern": "0.2.2",
21
+ "@rushstack/tree-pattern": "0.2.3",
22
22
  "@typescript-eslint/experimental-utils": "~5.6.0"
23
23
  },
24
24
  "peerDependencies": {
@@ -41,5 +41,5 @@
41
41
  "_phase:build": "heft build --clean",
42
42
  "_phase:test": "heft test --no-build"
43
43
  },
44
- "readme": "# @rushstack/eslint-plugin-packlets\n\nPacklets provide a lightweight alternative to NPM packages for organizing source files within a single project. The formalism is validated using ESLint rules.\n\n## Motivation\n\nWhen building a large application, it's a good idea to organize source files into modules, so that their dependencies can be managed. For example, suppose an application's source files can be grouped as follows:\n\n- `src/logging/*.ts` - the logging system\n- `src/data-model/*.ts` - the data model\n- `src/reports/*.ts` - the report engine\n- `src/*.ts` - other arbitrary files such as startup code and the main application\n\nUsing file folders is helpful, but it's not very strict. Files under `src/logging` can easily import files from `/src/reports`, creating a confusing circular import. They can also import arbitrary application files. Also, there is no clear distinction between which files are the \"public API\" for `src/logging` versus its private implementation details.\n\nAll these problems can be solved by reorganizing the project into NPM packages (or [Rush projects](https://rushjs.io/)). Something like this:\n\n- `@my-app/logging` - the logging system\n- `@my-app/data-model` - the data model\n- `@my-app/reports` - the report engine\n- `@my-app/application` - other arbitrary files such as startup code and the main application\n\nHowever, separating code in this way has some downsides. The projects need to build separately, which has some tooling costs (for example, \"watch mode\" now needs to consider multiple projects). In a large monorepo, the library may attract other consumers, before the API has been fully worked out.\n\nPacklets provide a lightweight alternative that offers many of the same benefits of packages, but without the `package.json` file. It's a great way to prototype your project organization before later graduating your packlets into proper NPM packages.\n\n## 5 rules for packlets\n\nWith packlets, our folders would be reorganized as follows:\n\n- `src/packlets/logging/*.ts` - the logging system\n- `src/packlets/data-model/*.ts` - the data model\n- `src/packlets/reports/*.ts` - the report engine\n- `src/*.ts` - other arbitrary files such as startup code and the main application\n\nThe [packlets-tutorial](https://github.com/microsoft/rushstack-samples/tree/main/other/packlets-tutorial) sample project illustrates this layout in full detail.\n\nThe basic design can be summarized in 5 rules:\n\n1. A \"packlet\" is defined to be a folder path `./src/packlets/<packlet-name>/index.ts`. The **index.ts** file will have the exported APIs. The `<packlet-name>` name must consist of lower case words separated by hyphens, similar to an NPM package name.\n\n Example file paths:\n ```\n src/packlets/controls\n src/packlets/logger\n src/packlets/my-long-name\n ```\n\n > **NOTE:** The `packlets` cannot be nested deeper in the tree. Like with NPM packages, `src/packlets` is a flat namespace.\n\n2. Files outside the packlet folder can only import the packlet root **index.ts**:\n\n **src/app/App.ts**\n ```ts\n // Okay\n import { MainReport } from '../packlets/reports';\n\n // Error: The import statement does not use the packlet's entry point (@rushstack/packlets/mechanics)\n import { MainReport } from '../packlets/reports/index';\n\n // Error: The import statement does not use the packlet's entry point (@rushstack/packlets/mechanics)\n import { MainReport } from '../packlets/reports/MainReport';\n ```\n\n3. Files inside a packlet folder should import their siblings directly, not via their own **index.ts** (which might create a circular reference):\n\n **src/packlets/logging/Logger.ts**\n ```ts\n // Okay\n import { MessageType } from \"./MessageType\";\n\n // Error: Files under a packlet folder must not import from their own index.ts file (@rushstack/packlets/mechanics)\n import { MessageType } from \".\";\n\n // Error: Files under a packlet folder must not import from their own index.ts file (@rushstack/packlets/mechanics)\n import { MessageType} from \"./index\";\n ```\n\n\n4. Packlets may reference other packlets, but not in a way that would introduce a circular dependency:\n\n **src/packlets/data-model/DataModel.ts**\n ```ts\n // Okay\n import { Logger } from '../../packlets/logging';\n ```\n\n **src/packlets/logging/Logger.ts**\n ```ts\n // Error: Packlet imports create a circular reference: (@rushstack/packlets/circular-deps)\n // \"logging\" is referenced by src/packlets/data-model/DataModel.ts\n // \"data-model\" is referenced by src/packlets/logging/Logger.ts\n import { DataModel } from '../../packlets/data-model';\n ```\n\n5. Other source files are allowed outside the **src/packlets** folder. They may import a packlet, but packlets must only import from other packlets or NPM packages.\n\n **src/app/App.ts**\n\n ```ts\n // Okay\n import { MainReport } from '../packlets/reports';\n ```\n\n **src/packlets/data-model/ExampleModel.ts**\n ```ts\n // Error: A local project file cannot be imported. A packlet's dependencies must be\n // NPM packages and/or other packlets. (@rushstack/packlets/mechanics)\n import { App } from '../../app/App';\n ```\n\n\n## Getting Started\n\nTo enable packlet validation for a simple `typescript-eslint` setup, reference the `@rushstack/eslint-plugin-packlets` project like this:\n\n**\\<my-project\\>/.eslintrc.js**\n```js\nmodule.exports = {\n root: true,\n parser: '@typescript-eslint/parser',\n plugins: ['@typescript-eslint'],\n extends: [\n 'eslint:recommended',\n 'plugin:@typescript-eslint/recommended',\n 'plugin:@rushstack/eslint-plugin-packlets/recommended' // <--- ADD THIS\n ],\n parserOptions: {\n project: './tsconfig.json',\n sourceType: 'module',\n tsconfigRootDir: __dirname\n }\n};\n```\n\nOr, if you are using the [@rushstack/eslint-config](https://www.npmjs.com/package/@rushstack/eslint-config) ruleset, add the `\"packlets\"` mixin like this:\n\n**\\<my-project\\>/.eslintrc.js**\n```ts\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\nrequire('@rushstack/eslint-config/patch/modern-module-resolution');\n\nmodule.exports = {\n extends: [\n \"@rushstack/eslint-config/profile/node\",\n \"@rushstack/eslint-config/mixins/packlets\" // <--- ADD THIS\n ],\n parserOptions: { tsconfigRootDir: __dirname }\n};\n```\n\nThe `@rushstack/eslint-plugin-packlets` plugin implements three separate rules:\n\n- `@rushstack/packlets/mechanics` - validates most of the import path rules outlined above.\n- `@rushstack/packlets/circular-deps` - detects circular dependencies between packlets. This rule requires an ESLint configuration that enables full type information from the TypeScript compiler.\n- `@rushstack/packlets/readme` - requires each packlet to have a README.md file. This rule is disabled by default.\n\n## Requiring a README.md file\n\nIf you'd like to require a README.md file in each packlet folder, enable the optional `@rushstack/packlets/readme` rule.\n\nThe `minimumReadmeWords` option allows you to specify a minimum number of words of documentation in the README.md file. The default value is `10` words.\n\nExample configuration with the `@rushstack/packlets/readme` rule enabled:\n\n**\\<my-project\\>/.eslintrc.js**\n```ts\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\nrequire('@rushstack/eslint-config/patch/modern-module-resolution');\n\nmodule.exports = {\n extends: [\n \"@rushstack/eslint-config/profile/node\",\n \"@rushstack/eslint-config/mixins/packlets\"\n ],\n parserOptions: { tsconfigRootDir: __dirname },\n overrides: [\n {\n files: ['*.ts', '*.tsx'],\n\n rules: {\n '@rushstack/packlets/readme': [ // <--- ADD THIS\n 'warn',\n { minimumReadmeWords: 10 }\n ]\n }\n }\n ]\n};\n```\n\n## Links\n\n- [CHANGELOG.md](\n https://github.com/microsoft/rushstack/blob/master/stack/eslint-plugin-packlets/CHANGELOG.md) - Find\n out what's new in the latest version\n- [@rushstack/eslint-config](https://www.npmjs.com/package/@rushstack/eslint-config) documentation\n\n`@rushstack/eslint-plugin-packlets` is part of the [Rush Stack](https://rushstack.io/) family of projects.\nThe idea for packlets was originally proposed by [@bartvandenende-wm](https://github.com/bartvandenende-wm)\nand [@victor-wm](https://github.com/victor-wm).\n"
44
+ "readme": "# @rushstack/eslint-plugin-packlets\n\nPacklets provide a lightweight alternative to NPM packages for organizing source files within a single project. The formalism is validated using ESLint rules.\n\n## Motivation\n\nWhen building a large application, it's a good idea to organize source files into modules, so that their dependencies can be managed. For example, suppose an application's source files can be grouped as follows:\n\n- `src/logging/*.ts` - the logging system\n- `src/data-model/*.ts` - the data model\n- `src/reports/*.ts` - the report engine\n- `src/*.ts` - other arbitrary files such as startup code and the main application\n\nUsing file folders is helpful, but it's not very strict. Files under `src/logging` can easily import files from `/src/reports`, creating a confusing circular import. They can also import arbitrary application files. Also, there is no clear distinction between which files are the \"public API\" for `src/logging` versus its private implementation details.\n\nAll these problems can be solved by reorganizing the project into NPM packages (or [Rush projects](https://rushjs.io/)). Something like this:\n\n- `@my-app/logging` - the logging system\n- `@my-app/data-model` - the data model\n- `@my-app/reports` - the report engine\n- `@my-app/application` - other arbitrary files such as startup code and the main application\n\nHowever, separating code in this way has some downsides. The projects need to build separately, which has some tooling costs (for example, \"watch mode\" now needs to consider multiple projects). In a large monorepo, the library may attract other consumers, before the API has been fully worked out.\n\nPacklets provide a lightweight alternative that offers many of the same benefits of packages, but without the `package.json` file. It's a great way to prototype your project organization before later graduating your packlets into proper NPM packages.\n\n## 5 rules for packlets\n\nWith packlets, our folders would be reorganized as follows:\n\n- `src/packlets/logging/*.ts` - the logging system\n- `src/packlets/data-model/*.ts` - the data model\n- `src/packlets/reports/*.ts` - the report engine\n- `src/*.ts` - other arbitrary files such as startup code and the main application\n\nThe [packlets-tutorial](https://github.com/microsoft/rushstack-samples/tree/main/other/packlets-tutorial) sample project illustrates this layout in full detail.\n\nThe basic design can be summarized in 5 rules:\n\n1. A \"packlet\" is defined to be a folder path `./src/packlets/<packlet-name>/index.ts`. The **index.ts** file will have the exported APIs. The `<packlet-name>` name must consist of lower case words separated by hyphens, similar to an NPM package name.\n\n Example file paths:\n ```\n src/packlets/controls\n src/packlets/logger\n src/packlets/my-long-name\n ```\n\n > **NOTE:** The `packlets` cannot be nested deeper in the tree. Like with NPM packages, `src/packlets` is a flat namespace.\n\n2. Files outside the packlet folder can only import the packlet root **index.ts**:\n\n **src/app/App.ts**\n ```ts\n // Okay\n import { MainReport } from '../packlets/reports';\n\n // Error: The import statement does not use the packlet's entry point (@rushstack/packlets/mechanics)\n import { MainReport } from '../packlets/reports/index';\n\n // Error: The import statement does not use the packlet's entry point (@rushstack/packlets/mechanics)\n import { MainReport } from '../packlets/reports/MainReport';\n ```\n\n3. Files inside a packlet folder should import their siblings directly, not via their own **index.ts** (which might create a circular reference):\n\n **src/packlets/logging/Logger.ts**\n ```ts\n // Okay\n import { MessageType } from \"./MessageType\";\n\n // Error: Files under a packlet folder must not import from their own index.ts file (@rushstack/packlets/mechanics)\n import { MessageType } from \".\";\n\n // Error: Files under a packlet folder must not import from their own index.ts file (@rushstack/packlets/mechanics)\n import { MessageType} from \"./index\";\n ```\n\n\n4. Packlets may reference other packlets, but not in a way that would introduce a circular dependency:\n\n **src/packlets/data-model/DataModel.ts**\n ```ts\n // Okay\n import { Logger } from '../../packlets/logging';\n ```\n\n **src/packlets/logging/Logger.ts**\n ```ts\n // Error: Packlet imports create a circular reference: (@rushstack/packlets/circular-deps)\n // \"logging\" is referenced by src/packlets/data-model/DataModel.ts\n // \"data-model\" is referenced by src/packlets/logging/Logger.ts\n import { DataModel } from '../../packlets/data-model';\n ```\n\n5. Other source files are allowed outside the **src/packlets** folder. They may import a packlet, but packlets must only import from other packlets or NPM packages.\n\n **src/app/App.ts**\n\n ```ts\n // Okay\n import { MainReport } from '../packlets/reports';\n ```\n\n **src/packlets/data-model/ExampleModel.ts**\n ```ts\n // Error: A local project file cannot be imported. A packlet's dependencies must be\n // NPM packages and/or other packlets. (@rushstack/packlets/mechanics)\n import { App } from '../../app/App';\n ```\n\n\n## Getting Started\n\nTo enable packlet validation for a simple `typescript-eslint` setup, reference the `@rushstack/eslint-plugin-packlets` project like this:\n\n**\\<my-project\\>/.eslintrc.js**\n```js\nmodule.exports = {\n root: true,\n parser: '@typescript-eslint/parser',\n plugins: ['@typescript-eslint'],\n extends: [\n 'eslint:recommended',\n 'plugin:@typescript-eslint/recommended',\n 'plugin:@rushstack/eslint-plugin-packlets/recommended' // <--- ADD THIS\n ],\n parserOptions: {\n project: './tsconfig.json',\n sourceType: 'module',\n tsconfigRootDir: __dirname\n }\n};\n```\n\nOr, if you are using the [@rushstack/eslint-config](https://www.npmjs.com/package/@rushstack/eslint-config) ruleset, add the `\"packlets\"` mixin like this:\n\n**\\<my-project\\>/.eslintrc.js**\n```ts\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\nrequire('@rushstack/eslint-config/patch/modern-module-resolution');\n\nmodule.exports = {\n extends: [\n \"@rushstack/eslint-config/profile/node\",\n \"@rushstack/eslint-config/mixins/packlets\" // <--- ADD THIS\n ],\n parserOptions: { tsconfigRootDir: __dirname }\n};\n```\n\nThe `@rushstack/eslint-plugin-packlets` plugin implements three separate rules:\n\n- `@rushstack/packlets/mechanics` - validates most of the import path rules outlined above.\n- `@rushstack/packlets/circular-deps` - detects circular dependencies between packlets. This rule requires an ESLint configuration that enables full type information from the TypeScript compiler.\n- `@rushstack/packlets/readme` - requires each packlet to have a README.md file. This rule is disabled by default.\n\n## Requiring a README.md file\n\nIf you'd like to require a README.md file in each packlet folder, enable the optional `@rushstack/packlets/readme` rule.\n\nThe `minimumReadmeWords` option allows you to specify a minimum number of words of documentation in the README.md file. The default value is `10` words.\n\nExample configuration with the `@rushstack/packlets/readme` rule enabled:\n\n**\\<my-project\\>/.eslintrc.js**\n```ts\n// This is a workaround for https://github.com/eslint/eslint/issues/3458\nrequire('@rushstack/eslint-config/patch/modern-module-resolution');\n\nmodule.exports = {\n extends: [\n \"@rushstack/eslint-config/profile/node\",\n \"@rushstack/eslint-config/mixins/packlets\"\n ],\n parserOptions: { tsconfigRootDir: __dirname },\n overrides: [\n {\n files: ['*.ts', '*.tsx'],\n\n rules: {\n '@rushstack/packlets/readme': [ // <--- ADD THIS\n 'warn',\n { minimumReadmeWords: 10 }\n ]\n }\n }\n ]\n};\n```\n\n## Links\n\n- [CHANGELOG.md](\n https://github.com/microsoft/rushstack/blob/main/stack/eslint-plugin-packlets/CHANGELOG.md) - Find\n out what's new in the latest version\n- [@rushstack/eslint-config](https://www.npmjs.com/package/@rushstack/eslint-config) documentation\n\n`@rushstack/eslint-plugin-packlets` is part of the [Rush Stack](https://rushstack.io/) family of projects.\nThe idea for packlets was originally proposed by [@bartvandenende-wm](https://github.com/bartvandenende-wm)\nand [@victor-wm](https://github.com/victor-wm).\n"
45
45
  }