@commitlint/config-nx-scopes 16.0.0

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 (4) hide show
  1. package/index.js +31 -0
  2. package/license.md +21 -0
  3. package/package.json +46 -0
  4. package/readme.md +44 -0
package/index.js ADDED
@@ -0,0 +1,31 @@
1
+ const {Workspaces} = require('@nrwl/tao/src/shared/workspace');
2
+
3
+ module.exports = {
4
+ utils: {getProjects},
5
+ rules: {
6
+ 'scope-enum': (ctx) =>
7
+ getProjects(ctx).then((packages) => [2, 'always', packages]),
8
+ },
9
+ };
10
+
11
+ function getProjects(context) {
12
+ return Promise.resolve()
13
+ .then(() => {
14
+ const ctx = context || {};
15
+ const cwd = ctx.cwd || process.cwd();
16
+ const ws = new Workspaces(cwd);
17
+ const workspace = ws.readWorkspaceConfiguration();
18
+ return Object.entries(workspace.projects || {}).map(
19
+ ([name, project]) => ({
20
+ name,
21
+ ...project,
22
+ })
23
+ );
24
+ })
25
+ .then((projects) => {
26
+ return projects
27
+ .filter((project) => project.targets)
28
+ .map((project) => project.name)
29
+ .map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name));
30
+ });
31
+ }
package/license.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 - present Florian Guitton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@commitlint/config-nx-scopes",
3
+ "version": "16.0.0",
4
+ "description": "Shareable commitlint config enforcing nx project and workspace names as scopes",
5
+ "files": [
6
+ "index.js"
7
+ ],
8
+ "scripts": {
9
+ "deps": "dep-check",
10
+ "pkg": "pkg-check"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/conventional-changelog/commitlint.git",
15
+ "directory": "@commitlint/config-nx-scopes"
16
+ },
17
+ "keywords": [
18
+ "conventional-changelog",
19
+ "commitlint",
20
+ "commitlint-config",
21
+ "nx"
22
+ ],
23
+ "author": "Florian Guitton <florian@secretarium.com>",
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/conventional-changelog/commitlint/issues"
27
+ },
28
+ "homepage": "https://commitlint.js.org/",
29
+ "peerDependencies": {
30
+ "@nrwl/tao": "^12.0.0 || ^13.0.0"
31
+ },
32
+ "peerDependenciesMeta": {
33
+ "@nrwl/tao": {
34
+ "optional": true
35
+ }
36
+ },
37
+ "engines": {
38
+ "node": ">=v12"
39
+ },
40
+ "devDependencies": {
41
+ "@commitlint/test": "^16.0.0",
42
+ "@commitlint/utils": "^16.0.0",
43
+ "@nrwl/tao": "^13.0.0"
44
+ },
45
+ "gitHead": "70f7f4688b51774e7ac5e40e896cdaa3f132b2bc"
46
+ }
package/readme.md ADDED
@@ -0,0 +1,44 @@
1
+ > Lint your nx project commits
2
+
3
+ # @commitlint/config-nx-scopes
4
+
5
+ Shareable `commitlint` config enforcing nx project and workspace names as scopes.
6
+ Use with [@commitlint/cli](../cli) and [@commitlint/prompt-cli](../prompt-cli).
7
+
8
+ ## Getting started
9
+
10
+ ```
11
+ npm install --save-dev @commitlint/config-nx-scopes @commitlint/cli
12
+ echo "module.exports = {extends: ['@commitlint/config-nx-scopes']};" > commitlint.config.js
13
+ ```
14
+
15
+ ## Examples
16
+
17
+ ```
18
+ ❯ cat commitlint.config.js
19
+ {
20
+ extends: ['@commitlint/config-nx-scopes']
21
+ }
22
+
23
+ ❯ tree packages
24
+
25
+ packages
26
+ ├── api
27
+ ├── app
28
+ └── web
29
+
30
+ ❯ echo "build(api): change something in api's build" | commitlint
31
+ ⧗ input: build(api): change something in api's build
32
+ ✔ found 0 problems, 0 warnings
33
+
34
+ ❯ echo "test(foo): this won't pass" | commitlint
35
+ ⧗ input: test(foo): this won't pass
36
+ ✖ scope must be one of [api, app, web] [scope-enum]
37
+ ✖ found 1 problems, 0 warnings
38
+
39
+ ❯ echo "ci: do some general maintenance" | commitlint
40
+ ⧗ input: ci: do some general maintenance
41
+ ✔ found 0 problems, 0 warnings
42
+ ```
43
+
44
+ Consult [docs/rules](https://conventional-changelog.github.io/commitlint/#/reference-rules) for a list of available rules.