Skip to content

Commit 1474103

Browse files
authored
Release v5.2.0 (#407)
### eslint-plugin v5.2.0 #### Added - feat: Start supporting new template data and syntax, as described in [#370](#370). Not added to the documentation yet, as it is still in beta testing phase. - feat: Add setting `legacy-templates` to enable/disable the old template data and syntax. By default, it is enabled for backward compatibility. Not added to the documentation yet, as the new template data and syntax is still in beta testing phase. - feat([#371](#371)): Publish eslint-plugin both to @boundaries/eslint-plugin and eslint-plugin-boundaries package names. - feat: Add `cache` setting to enable/disable the new cache mechanism used to boost performance. By default, it is enabled. We recommend to keep it enabled unless you experience issues. In such case, please, open an issue describing the problem. #### Changed - feat: Improve performance in approximately 30% in large codebases by optimizing cache usage and reducing redundant computations when resolving elements and matching rules. - refactor([#371](#371)): Extract element descriptors and matching logic to a separate module to improve code organization, readability and reusability. - refactor: Overall performance improvements and code optimizations. - feat: Add empty schema to rules without options to validate them correctly. #### Fixed - fix: Assign internalPaths correctly when in elements setting the mode is 'file' but the pattern matches folders, not files. Now it returns the correct internalPaths instead of the matched folder name. - fix: Assign relationships correctly in dependencies. Now ancestor and nephew relationships are assigned correctly. Previously, all ancestors with a common parent were considered uncles. ### elements v1.1.0 #### Added - feat: Implement cache for micromatch results, regex and captures to improve performance. - feat: Add `cache` option to allow disabling the cache. #### Changed - refactor: Overall performance improvements and code optimizations. #### Fixed - fix: Fix cache performance issues by implementing custom string generation for well-known objects, and removing caching for keys based on complex objects to avoid performance degradation. - fix: Legacy selectors being an array with only one element now correctly treated as a single string selector.
1 parent 5cececc commit 1474103

File tree

443 files changed

+17102
-4177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

443 files changed

+17102
-4177
lines changed

.github/CONTRIBUTING.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# Table of Contents
44

55
- [Getting started](#getting-started)
6-
- [package tasks](#package-tasks)
6+
- [Contributing workflow](#contributing-workflow)
7+
- [Package Tasks](#package-tasks)
78
- [Branching model](#branching-model)
89
- [Pull Request](#pull-request)
910
- [Release process](#release-process)
@@ -29,7 +30,19 @@ To get started, clone the repository and install the dependencies:
2930
pnpm install
3031
```
3132

32-
# Package tasks
33+
# Contributing workflow
34+
35+
In short, the contributing workflow is as follows:
36+
37+
1. Create an RFC (if needed)
38+
2. Create Issue(s) from RFC
39+
3. Break Down into Sub-Issues (if needed)
40+
4. Add to Project & Assign to Milestone
41+
5. Contributors Pick Up Tasks
42+
43+
Read the full details in the [contributing workflow guide](../docs/contributing-workflow.md).
44+
45+
# Package Tasks
3346

3447
Package task names are standardized across the repository. This enables to define common dependencies and files impacting them in the root `nx.json` file. The following are the most common tasks:
3548

@@ -38,20 +51,21 @@ Package task names are standardized across the repository. This enables to defin
3851
* `check:spell`: Checks the spelling in the package.
3952
* `build`: Builds the package.
4053
* `test:unit`: Runs the unit tests.
54+
* `test:mutation`: Runs the mutation tests.
4155
* `test:e2e`: Runs the end-to-end tests.
4256
* `check:all`: Run all the checks and build the package.
4357

44-
You can also rewrite the tasks to fit the package's needs. For example, if a package has special requirements for unit tests, you can define a `test:unit` task in the package's `project.json` file, redefining the Nx inputs, outputs, and dependencies in order to fit the package's needs and optimize the cache accordingly. _(See how the `eslint-plugin-boundaries` package does this for an example)_
58+
You can also rewrite the tasks to fit the package's needs. For example, if a package has special requirements for unit tests, you can define a `test:unit` task in the package's `project.json` file, redefining the Nx inputs, outputs, and dependencies in order to fit the package's needs and optimize the cache accordingly. _(See how the `eslint-plugin` package does this for an example)_
4559

4660
> [!WARNING]
4761
> It is crucial to configure properly the tasks dependencies, input, and output files, so __Nx can keep or clean the cache correctly, avoiding running unnecessary tasks__, both locally or in the pipeline.
4862
4963
## Running tasks in packages
5064

51-
Nx provides a way to run commands in a specific package, taking care of the task dependencies. To run a command in a package, use the following syntax: `pnpm nx run <task> <package>`. For example, to run the unit tests in the `eslint-plugin-boundaries` package, use the following command:
65+
Nx provides a way to run commands in a specific package, taking care of the task dependencies. To run a command in a package, use the following syntax: `pnpm nx run <task> <package>`. For example, to run the unit tests in the `eslint-plugin` package, use the following command:
5266

5367
```bash
54-
pnpm nx test:unit eslint-plugin-boundaries
68+
pnpm nx test:unit eslint-plugin
5569
```
5670

5771
> ![TIP]
@@ -86,7 +100,7 @@ Some important points to consider:
86100
* It is long-lived because we also have bots that will open PRs. So, they can be configured to open PRs to the "release" branch, and their changes will also enter in the process of preparing the release, such as changes from any other contributor.
87101
* __The "release" branch is the default branch for PRs.__ Only a project maintainer should open a PR to the "main" branch, and only when the release is ready to be published.
88102
* Usually, feature branches should be short-lived, and they should be merged into the "release" branch as soon as possible. This way, the changes will be included in the next release, and the feature branch can be deleted.
89-
* When necessary, a medium-lived branch can be created from the "release" branch to group changes that will be released together and require more time to be prepared. Once the changes are ready, the branch can be merged into the "release" branch.
103+
* When necessary, a medium-lived branch can be created from the "release" branch to group changes that will be released together and require more time to be prepared, such as `release-<version>`. Once the changes are ready, the branch can be merged into the "release" branch.
90104
* For publishing beta versions or fix versions of precedent releases, medium-lived branches should be also created from the "release" branch. A branch naming convention should be followed in order to identify these branches easily. For example:
91105
* `release-X.Y.Z-beta.N`: For beta versions of the next release.
92106

@@ -99,7 +113,7 @@ We use the __squash and merge strategy for merging PRs to the release branch__.
99113

100114
But we use the __merge commit strategy for merging PRs to the main branch from the release branch__. The reasons are:
101115

102-
* To keep in the history the information about the features that were merged separately into the release branch. This is very important, because we may have changes from different packages in the release branch. Squashing all the changes into a single commit would make it difficult to understand or revert the changes for a specific package.
116+
* To keep in the history the information about the features that were merged separately into the release branch. This is very important, because we may have changes from different packages in the release branch, or from features that are not related. Squashing all the changes into a single commit would make it difficult to understand or revert the changes for a specific package or feature.
103117
* To avoid having to rebase the release branch every time a PR is merged to the main branch.
104118

105119
# Pull Request

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: javierbrea

.github/actions/install/action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
node-version:
66
description: The Node.js version to use
77
required: true
8+
windows-fix-symlinks:
9+
description: Whether to apply Windows-specific PNPM symlink fixes
10+
required: false
11+
default: 'false'
812

913
runs:
1014
using: composite
@@ -24,7 +28,13 @@ runs:
2428
uses: actions/cache@v4
2529
with:
2630
path: node_modules
27-
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
31+
key: pnpm-windows-${{ hashFiles('pnpm-lock.yaml') }}
32+
33+
- name: Fix PNPM symlinks on Windows
34+
if: ${{ inputs.windows-fix-symlinks == 'true' }}
35+
shell: bash
36+
run: |
37+
pnpm config set node-linker hoisted
2838
2939
- name: Install Node.js dependencies
3040
shell: bash

.github/workflows/build.yml

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ on:
44
branches:
55
- master
66
- release
7-
- refactor/monorepo
7+
- release-v*
88
pull_request:
9+
910
concurrency:
1011
group: ${{ github.workflow }}-${{ github.ref }}
1112
cancel-in-progress: true
13+
1214
jobs:
1315
check-root:
1416
runs-on: ubuntu-latest
@@ -33,62 +35,99 @@ jobs:
3335
- uses: ./.github/actions/install
3436
with:
3537
node-version: ${{ matrix.node }}
36-
# NOTE: For the moment, we run the check:all target in all packages instead of running affected check in affected packages only
37-
- name: Check all
38-
if: ${{ matrix.node == '22.14.0' }}
39-
run: pnpm nx run-many --target=check:all --all --output-style=stream --parallel=1
4038
# NOTE: In other Node versions, we only run unit tests to save time in the CI and to avoid dev tools Node incompatibilities
4139
- name: Test Unit
4240
if: ${{ matrix.node != '22.14.0' }}
4341
run: pnpm nx run-many --target=test:unit --all
44-
- name: Upload test results
42+
# NOTE: For the moment, we run the check:all target in all packages instead of running affected check in affected packages only
43+
- name: Check all
44+
if: ${{ matrix.node == '22.14.0' }}
45+
run: pnpm nx run-many --target=check:all --all --output-style=stream --parallel=1
46+
- name: Upload elements test results
47+
if: ${{ matrix.node == '22.14.0' }}
4548
uses: actions/upload-artifact@v4
4649
with:
47-
name: coverage-${{ matrix.node }}
48-
path: packages/eslint-plugin-boundaries/coverage
50+
name: elements-coverage
51+
path: packages/elements/coverage
52+
retention-days: 1
53+
- name: Upload eslint-plugin test results
54+
if: ${{ matrix.node == '22.14.0' }}
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: eslint-plugin-coverage
58+
path: packages/eslint-plugin/coverage
59+
retention-days: 1
60+
- name: Upload elements build
61+
if: ${{ matrix.node == '22.14.0' }}
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: elements-build
65+
path: packages/elements/dist
4966
retention-days: 1
5067
build-windows:
5168
runs-on: windows-2022
52-
strategy:
53-
matrix:
54-
node: ["18.20.3", "20.13.1", "22.14.0"]
69+
needs: build
5570
steps:
5671
- name: Checkout
5772
uses: actions/checkout@v4
5873
- uses: ./.github/actions/install
5974
with:
60-
node-version: ${{ matrix.node }}
61-
- name: Check all
62-
if: ${{ matrix.node == '22.14.0' }}
63-
run: pnpm nx run-many --target=check:all --all
64-
# NOTE: In other Node versions, we only run unit tests to save time in the CI and to avoid dev tools Node incompatibilities
65-
- name: Test Unit
66-
if: ${{ matrix.node != '22.14.0' }}
67-
run: pnpm nx run-many --target=test:unit --all
75+
node-version: "22.14.0"
76+
windows-fix-symlinks: "true"
77+
- name: Download elements build
78+
uses: actions/download-artifact@v4
79+
with:
80+
name: elements-build
81+
path: packages/elements/dist
82+
- name: Test Unit ESLint Plugin
83+
working-directory: ./packages/eslint-plugin
84+
run: pnpm test:unit
6885
reports:
6986
runs-on: ubuntu-latest
7087
needs: build
88+
env:
89+
SONAR_TOKEN_ELEMENTS: ${{ secrets.SONAR_TOKEN_ELEMENTS }}
90+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7191
steps:
7292
- name: Checkout
7393
uses: actions/checkout@v4
7494
with:
7595
fetch-depth: 0
76-
- name: Download test results
96+
- name: Download elements test results
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: elements-coverage
100+
path: packages/elements/coverage
101+
- name: Download eslint-plugin test results
77102
uses: actions/download-artifact@v4
78103
with:
79-
name: coverage-22.14.0
80-
path: packages/eslint-plugin-boundaries/coverage
81-
- name: Coveralls
104+
name: eslint-plugin-coverage
105+
path: packages/eslint-plugin/coverage
106+
- name: Coveralls for Elements
82107
uses: coverallsapp/github-action@v2
83108
with:
84109
github-token: ${{ secrets.GITHUB_TOKEN }}
85-
base-path: packages/eslint-plugin-boundaries
86-
# TODO: Configure sonarcloud for monorepo
87-
- name: SonarCloud Scan
110+
path-to-lcov: ./packages/elements/coverage/lcov.info
111+
flag-name: elements
112+
- name: Coveralls for Eslint Plugin
113+
uses: coverallsapp/github-action@v2
114+
with:
115+
github-token: ${{ secrets.GITHUB_TOKEN }}
116+
path-to-lcov: ./packages/eslint-plugin/coverage/lcov.info
117+
flag-name: eslint-plugin
118+
- name: SonarCloud Scan - Elements
119+
if: env.SONAR_TOKEN_ELEMENTS != ''
120+
uses: SonarSource/sonarqube-scan-action@v6
121+
with:
122+
projectBaseDir: packages/elements
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_ELEMENTS }}
126+
- name: SonarCloud Scan - Eslint Plugin
88127
if: env.SONAR_TOKEN != ''
89-
uses: sonarsource/sonarcloud-github-action@master
128+
uses: SonarSource/sonarqube-scan-action@v6
90129
with:
91-
projectBaseDir: packages/eslint-plugin-boundaries
130+
projectBaseDir: packages/eslint-plugin
92131
env:
93132
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94133
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/publish-beta.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/publish-to-github.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ jobs:
3333
env:
3434
HUSKY_SKIP_INSTALL: 1
3535

36-
- run: pnpm nx run-many -t check:all --all
36+
- run: pnpm check:all
3737

3838
- uses: MerthinTechnologies/edit-json-action@v1
3939
with:
40-
filename: './packages/eslint-plugin-boundaries/package.json'
40+
filename: './packages/eslint-plugin/package.json'
4141
key: 'name'
4242
value: '@javierbrea/eslint-plugin-boundaries'
4343

.github/workflows/publish.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,49 @@ name: publish-to-npm
22
on:
33
release:
44
types: [created]
5+
6+
permissions:
7+
id-token: write # Required for OIDC
8+
contents: read
9+
510
jobs:
611
publish:
712
runs-on: ubuntu-latest
813
if: contains(github.event.release.target_commitish, '-beta.') == false
914
steps:
1015
- uses: actions/checkout@v4
1116
- uses: ./.github/actions/install
12-
- run: pnpm nx run-many -t check:all --all
17+
- run: pnpm check:all
1318
- run: pnpm -r publish --no-git-checks
1419
env:
1520
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1621
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22+
- uses: MerthinTechnologies/edit-json-action@v1
23+
with:
24+
filename: './packages/eslint-plugin/package.json'
25+
key: 'name'
26+
value: 'eslint-plugin-boundaries'
27+
- run: pnpm -r publish --no-git-checks
28+
env:
29+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
30+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
31+
publish-beta:
32+
runs-on: ubuntu-latest
33+
if: contains(github.event.release.target_commitish, 'release-') && contains(github.event.release.target_commitish, '-beta.')
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: ./.github/actions/install
37+
- run: pnpm check:all
38+
- run: pnpm -r publish --no-git-checks --tag beta
39+
env:
40+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42+
- uses: MerthinTechnologies/edit-json-action@v1
43+
with:
44+
filename: './packages/eslint-plugin/package.json'
45+
key: 'name'
46+
value: 'eslint-plugin-boundaries'
47+
- run: pnpm -r publish --no-git-checks --tag beta
48+
env:
49+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
50+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Test Mutation
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- release
7+
pull_request:
8+
branches:
9+
- master
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
test-mutation:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- uses: ./.github/actions/install
22+
with:
23+
node-version: 22.14.0
24+
- name: Test Mutation Elements
25+
run: pnpm nx test:mutation elements
26+
env:
27+
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
28+
- name: Upload test mutation report for elements
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: report-test-mutation-elements
32+
path: packages/elements/reports/mutation
33+
retention-days: 1

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
},
66
"sonarlint.connectedMode.project": {
77
"connectionId": "javierbrea",
8-
"projectKey": "javierbrea_eslint-plugin-boundaries"
8+
"projectKey": "javierbrea_eslint-plugin-boundaries_elements"
99
}
1010
}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,18 @@ You can also provide an absolute path in the environment variable, but it may be
320320
321321
</details>
322322
323+
#### __`boundaries/cache`__
324+
325+
Enable or disable the cache mechanism used to boost performance. By default, it is enabled. We recommend to keep it enabled unless you experience issues. In such case, please, open an issue describing the problem.
326+
327+
```js
328+
export default [{
329+
settings: {
330+
"boundaries/cache": true // or false to disable the cache
331+
}
332+
}]
333+
```
334+
323335
### Predefined configurations
324336
325337
The plugin is distributed with two different predefined configurations: "recommended" and "strict".

0 commit comments

Comments
 (0)