Skip to content

Commit

Permalink
feat: v2.0.0 (#358)
Browse files Browse the repository at this point in the history
* fix(builder): pass all results to a single call to format (#328)

BREAKING CHANGE: The format of results output has changed 

* refactor(eslint-plugin): remove use-pipe-decorator rule (#245)

BREAKING CHANGE: The rule no longer exists for use

* feat(template-parser): updated use of parseTemplate to improve loc data

BREAKING CHANGE: Requires @angular/compiler 11.2.0 and above

* feat(schematics): change way indent and quotes are handled by conversion schematics

BREAKING CHANGE: The conversion schematic handle these rules differently
  • Loading branch information
JamesHenry committed Mar 13, 2021
1 parent 27b40cf commit 737fd04
Show file tree
Hide file tree
Showing 462 changed files with 7,609 additions and 5,397 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
push:
branches: [ master, 'next-major-release/**' ]
branches: [ master ]
pull_request:
branches: [ master, 'next-major-release/**' ]

Expand All @@ -20,6 +20,16 @@ jobs:

steps:
- uses: actions/checkout@v2
if: github.ref == 'refs/heads/master'
with:
fetch-depth: 0

# Ensure no detached HEAD state for next-major-release/** PRs, it breaks integration-tests
- uses: actions/checkout@v2
if: github.ref != 'refs/heads/master'
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- name: Use Node.js ${{ env.PRIMARY_NODE_VERSION }}
uses: actions/setup-node@v1
Expand Down Expand Up @@ -82,6 +92,8 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions/setup-node@v1
with:
Expand Down Expand Up @@ -117,6 +129,8 @@ jobs:
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

# Fetch all history for all tags and branches in this job because lerna needs it
- run: |
Expand Down
14 changes: 8 additions & 6 deletions README.md
Expand Up @@ -57,9 +57,13 @@ Read on to find out more about the project and some important things to bear in

## Supported Angular CLI Versions

We support Angular CLI `10.1.0` and onwards, including Angular CLI `11.x`. This range is also captured by our integration-tests package.
For v2.x.x, we currently support Angular CLI `11.2.0` and onwards. This is also captured by our integration-tests package.

### Why Angular `10.1.0`?
For v1.x.x of these packages we supported Angular from `10.1.0` to `11.1.0`.

> NOTE: In the future, we will switch the major version of these packages to match the Angular major version which we support
### Why does Angular support in v1.x.x start at Angular `10.1.0`?

Angular `10.1.0` is significant because at version `10.0.0` the Angular Team switched to using project references and a `tsconfig.base.json` at the root of the project. This ultimately was deemed to be unsuccessful and in `10.1.0` they switched back to the original `tsconfig.json` without project references. Because angular-eslint and typescript-eslint care about your underlying TypeScript config, it is important that you are on the updated version which does _not_ use project references.

Expand Down Expand Up @@ -283,8 +287,8 @@ Let's take a look at full (but minimal), manual example of a config file (**alth
Our schematics already do the "right" thing for you automatically in this regard, but if you have to configure things manually for whatever reason, **a full reference configuration example** can be found in the manual integration test located within this monorepo. Check out the relevant configuration files:

- [packages/integration-tests/fixtures/v1014-multi-project-manual-config/.eslintrc.json](./packages/integration-tests/fixtures/v1014-multi-project-manual-config/.eslintrc.json)
- [packages/integration-tests/fixtures/v1014-multi-project-manual-config/angular.json](./packages/integration-tests/fixtures/v1014-multi-project-manual-config/angular.json)
- [packages/integration-tests/fixtures/v1123-multi-project-manual-config/.eslintrc.json](./packages/integration-tests/fixtures/v1123-multi-project-manual-config/.eslintrc.json)
- [packages/integration-tests/fixtures/v1123-multi-project-manual-config/angular.json](./packages/integration-tests/fixtures/v1123-multi-project-manual-config/angular.json)

If you are looking for general help in migrating specific rules from TSLint to ESLint, you can check out this incredible project that we depend on in our conversion schematic: https://github.com/typescript-eslint/tslint-to-eslint-config

Expand Down Expand Up @@ -621,7 +625,6 @@ If you see a rule below that has **no status** against it, then please feel free
| [`template-use-track-by-function`] | @angular-eslint/template/use-track-by-function | :white_check_mark: |
| [`use-component-selector`] | @angular-eslint/use-component-selector | :white_check_mark: |
| [`use-component-view-encapsulation`] | @angular-eslint/use-component-view-encapsulation | :white_check_mark: |
| [`use-pipe-decorator`] | @angular-eslint/use-pipe-decorator | :white_check_mark: |
| [`use-pipe-transform-interface`] | @angular-eslint/use-pipe-transform-interface | :white_check_mark: |

#### Style
Expand Down Expand Up @@ -694,7 +697,6 @@ If you see a rule below that has **no status** against it, then please feel free
[`use-component-view-encapsulation`]: http://codelyzer.com/rules/use-component-view-encapsulation
[`use-injectable-provided-in`]: http://codelyzer.com/rules/use-injectable-provided-in
[`use-lifecycle-interface`]: http://codelyzer.com/rules/use-lifecycle-interface
[`use-pipe-decorator`]: http://codelyzer.com/rules/use-pipe-decorator
[`use-pipe-transform-interface`]: http://codelyzer.com/rules/use-pipe-transform-interface

<!-- PR Links -->
Expand Down
9 changes: 7 additions & 2 deletions lerna.json
@@ -1,6 +1,11 @@
{
"version": "1.2.0",
"version": "2.0.0-alpha.10",
"npmClient": "yarn",
"useWorkspaces": true,
"stream": true
"stream": true,
"command": {
"version": {
"allowBranch": ["main", "next-major-release/*"]
}
}
}
17 changes: 12 additions & 5 deletions package.json
Expand Up @@ -16,6 +16,7 @@
"build": "nx run-many --target=build --all --parallel",
"test": "nx run-many --target=test --all --parallel",
"integration-tests": "lerna run integration-tests",
"update-integration-tests": "lerna run update-integration-tests",
"check-clean-workspace-after-install": "git diff --quiet --exit-code",
"clean": "lerna clean && nx run-many --target=clean --all --parallel",
"cz": "git-cz",
Expand Down Expand Up @@ -45,24 +46,30 @@
},
"dependencies": {},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.1",
"@angular/compiler": "~11.0.0",
"@angular-devkit/architect": "~0.1102.3",
"@angular-devkit/build-angular": "~0.1102.3",
"@angular/cli": "~11.2.4",
"@angular/compiler": "~11.2.4",
"@angular/compiler-cli": "~11.2.4",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"@nrwl/cli": "11.2.10",
"@nrwl/nx-cloud": "11.1.3",
"@nrwl/tao": "11.2.10",
"@nrwl/workspace": "11.2.10",
"@schematics/angular": "^11.0.1",
"@schematics/angular": "~11.2.3",
"@types/eslint": "^7.2.0",
"@types/eslint-scope": "^3.7.0",
"@types/jest": "^26.0.15",
"@types/node": "^10.12.2",
"@types/prettier": "^1.19.0",
"@typescript-eslint/parser": "4.3.0",
"@typescript-eslint/eslint-plugin": "4.3.0",
"@typescript-eslint/parser": "4.16.1",
"@typescript-eslint/eslint-plugin": "4.16.1",
"eslint": "^7.6.0",
"eslint-config-prettier": "7.1.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "30.7.6",
"eslint-plugin-prefer-arrow": "1.2.2",
"execa": "^3.4.0",
"husky": "^3.0.0",
"jest": "^26.6.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/builder/package.json
@@ -1,6 +1,6 @@
{
"name": "@angular-eslint/builder",
"version": "1.2.0",
"version": "2.0.0-alpha.10",
"description": "Angular CLI builder for ESLint",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -26,7 +26,7 @@
],
"builders": "./builders.json",
"peerDependencies": {
"@angular-devkit/architect": "~0.1001.4 || ~0.1100.1",
"@angular/cli": ">= 11.2.0 < 12.0.0",
"eslint": "*",
"typescript": "*"
},
Expand Down
50 changes: 36 additions & 14 deletions packages/builder/src/index.ts
Expand Up @@ -63,27 +63,49 @@ async function run(
// output fixes to disk, if applicable based on the options
await projectESLint.ESLint.outputFixes(lintResults);

for (const result of lintResults) {
totalErrors += result.errorCount;
totalWarnings += result.warningCount;

if (result.errorCount || (result.warningCount && !reportOnlyErrors)) {
if (reportOnlyErrors) {
// Collect only errors (Linter.Severity === 2)
result.messages = result.messages.filter(
({ severity }) => severity === 2,
);
/**
* Depending on user configuration we may not want to report on all the
* results, so we need to adjust them before formatting.
*/
const finalLintResults: ESLint.LintResult[] = lintResults
.map((result): ESLint.LintResult | null => {
totalErrors += result.errorCount;
totalWarnings += result.warningCount;

if (result.errorCount || (result.warningCount && !reportOnlyErrors)) {
if (reportOnlyErrors) {
// Collect only errors (Linter.Severity === 2)
result.messages = result.messages.filter(
({ severity }) => severity === 2,
);
}

return result;
}

context.logger.info(formatter.format([result]));
}
return null;
})
// Filter out the null values
.filter(Boolean) as ESLint.LintResult[];

const hasWarningsToPrint: boolean =
totalWarnings > 0 && printInfo && !reportOnlyErrors;
const hasErrorsToPrint: boolean = totalErrors > 0 && printInfo;

/**
* It's important that we format all results together so that custom
* formatters, such as checkstyle, can provide a valid output for the
* whole project being linted.
*/
if (hasWarningsToPrint || hasErrorsToPrint) {
context.logger.info(formatter.format(finalLintResults));
}

if (totalWarnings > 0 && printInfo && !reportOnlyErrors) {
if (hasWarningsToPrint) {
context.logger.warn('Lint warnings found in the listed files.\n');
}

if (totalErrors > 0 && printInfo) {
if (hasErrorsToPrint) {
context.logger.error('Lint errors found in the listed files.\n');
}

Expand Down
78 changes: 77 additions & 1 deletion packages/builder/tests/index.test.ts
Expand Up @@ -102,7 +102,7 @@ async function runBuilder(options: Schema) {
logger.subscribe(loggerSpy);

const run = await architect.scheduleBuilder(builderName, options, {
logger,
logger: logger as any,
});

return run.result;
Expand Down Expand Up @@ -202,6 +202,82 @@ describe('Linter Builder', () => {
expect(mockLoadFormatter).toHaveBeenCalledWith('html');
});

it(`should include all the reports in a single call to the formatter's format method`, async () => {
mockReports = [
{
errorCount: 1,
warningCount: 0,
results: [],
messages: [
{
line: 0,
column: 0,
message: 'Mock error message 1',
severity: 2,
ruleId: null,
},
],
usedDeprecatedRules: [],
},
{
errorCount: 1,
warningCount: 0,
results: [],
messages: [
{
line: 1,
column: 1,
message: 'Mock error message 2',
severity: 2,
ruleId: null,
},
],
usedDeprecatedRules: [],
},
];
setupMocks();
await runBuilder(
createValidRunBuilderOptions({
eslintConfig: './.eslintrc',
lintFilePatterns: ['includedFile1', 'includedFile2'],
format: 'checkstyle',
}),
);
expect(mockLoadFormatter).toHaveBeenCalledWith('checkstyle');
expect(mockFormatter.format).toHaveBeenCalledWith([
{
errorCount: 1,
messages: [
{
column: 0,
line: 0,
message: 'Mock error message 1',
ruleId: null,
severity: 2,
},
],
results: [],
usedDeprecatedRules: [],
warningCount: 0,
},
{
errorCount: 1,
messages: [
{
column: 1,
line: 1,
message: 'Mock error message 2',
ruleId: null,
severity: 2,
},
],
results: [],
usedDeprecatedRules: [],
warningCount: 0,
},
]);
});

it('should pass all the reports to the fix engine, even if --fix is false', async () => {
setupMocks();
await runBuilder(
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin-template/package.json
@@ -1,6 +1,6 @@
{
"name": "@angular-eslint/eslint-plugin-template",
"version": "1.2.0",
"version": "2.0.0-alpha.10",
"description": "ESLint plugin for Angular Templates",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -24,12 +24,12 @@
"LICENSE"
],
"dependencies": {
"@typescript-eslint/experimental-utils": "4.3.0",
"@typescript-eslint/experimental-utils": "4.16.1",
"aria-query": "^4.2.2",
"axobject-query": "^2.2.0"
},
"devDependencies": {
"@angular-eslint/utils": "1.2.0",
"@angular-eslint/utils": "2.0.0-alpha.10",
"@types/aria-query": "^4.2.0"
},
"peerDependencies": {
Expand Down

0 comments on commit 737fd04

Please sign in to comment.