mirror of
https://github.com/nestjs/docs.nestjs.com.git
synced 2026-02-21 20:31:32 +00:00
chore(deps): upgrade to eslint v9
This commit is contained in:
193
.eslintrc.js
193
.eslintrc.js
@@ -1,193 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
"env": {
|
|
||||||
"browser": true,
|
|
||||||
"es6": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"parserOptions": {
|
|
||||||
"project": "tsconfig.json",
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
"@angular-eslint/eslint-plugin",
|
|
||||||
"@typescript-eslint",
|
|
||||||
"@typescript-eslint/tslint"
|
|
||||||
],
|
|
||||||
"extends": [
|
|
||||||
'plugin:@typescript-eslint/eslint-recommended',
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
'prettier',
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"@angular-eslint/component-class-suffix": "error",
|
|
||||||
"@angular-eslint/component-selector": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"type": "element",
|
|
||||||
"prefix": "app",
|
|
||||||
"style": "kebab-case"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@angular-eslint/directive-class-suffix": "error",
|
|
||||||
"@angular-eslint/directive-selector": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"type": "attribute",
|
|
||||||
"prefix": "app",
|
|
||||||
"style": "camelCase"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@angular-eslint/no-host-metadata-property": "error",
|
|
||||||
"@angular-eslint/no-input-rename": "error",
|
|
||||||
"@angular-eslint/no-inputs-metadata-property": "error",
|
|
||||||
"@angular-eslint/no-output-rename": "error",
|
|
||||||
"@angular-eslint/no-outputs-metadata-property": "error",
|
|
||||||
"@angular-eslint/use-lifecycle-interface": "error",
|
|
||||||
"@angular-eslint/use-pipe-transform-interface": "error",
|
|
||||||
"@typescript-eslint/consistent-type-definitions": "error",
|
|
||||||
"@typescript-eslint/dot-notation": "off",
|
|
||||||
"@typescript-eslint/explicit-member-accessibility": [
|
|
||||||
"off",
|
|
||||||
{
|
|
||||||
"accessibility": "explicit"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@typescript-eslint/indent": "error",
|
|
||||||
"@typescript-eslint/member-delimiter-style": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"multiline": {
|
|
||||||
"delimiter": "semi",
|
|
||||||
"requireLast": true
|
|
||||||
},
|
|
||||||
"singleline": {
|
|
||||||
"delimiter": "semi",
|
|
||||||
"requireLast": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@typescript-eslint/member-ordering": "off",
|
|
||||||
"@typescript-eslint/naming-convention": "error",
|
|
||||||
"@typescript-eslint/no-empty-function": "off",
|
|
||||||
"@typescript-eslint/no-empty-interface": "error",
|
|
||||||
"@typescript-eslint/no-inferrable-types": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"ignoreParameters": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@typescript-eslint/no-misused-new": "error",
|
|
||||||
"@typescript-eslint/no-non-null-assertion": "error",
|
|
||||||
"@typescript-eslint/no-shadow": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"hoist": "all"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@typescript-eslint/no-unused-expressions": "off",
|
|
||||||
"@typescript-eslint/prefer-function-type": "error",
|
|
||||||
"@typescript-eslint/quotes": [
|
|
||||||
"error",
|
|
||||||
"single"
|
|
||||||
],
|
|
||||||
"@typescript-eslint/semi": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
],
|
|
||||||
"@typescript-eslint/type-annotation-spacing": "error",
|
|
||||||
"@typescript-eslint/unified-signatures": "error",
|
|
||||||
"arrow-body-style": "error",
|
|
||||||
"brace-style": [
|
|
||||||
"error",
|
|
||||||
"1tbs"
|
|
||||||
],
|
|
||||||
"constructor-super": "error",
|
|
||||||
"curly": "error",
|
|
||||||
"dot-notation": "off",
|
|
||||||
"eol-last": "off",
|
|
||||||
"eqeqeq": [
|
|
||||||
"error",
|
|
||||||
"smart"
|
|
||||||
],
|
|
||||||
"guard-for-in": "error",
|
|
||||||
"id-blacklist": "off",
|
|
||||||
"id-match": "off",
|
|
||||||
"indent": "error",
|
|
||||||
"max-len": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"code": 140
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-bitwise": "error",
|
|
||||||
"no-caller": "error",
|
|
||||||
"no-console": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"allow": [
|
|
||||||
"log",
|
|
||||||
"warn",
|
|
||||||
"dir",
|
|
||||||
"timeLog",
|
|
||||||
"assert",
|
|
||||||
"clear",
|
|
||||||
"count",
|
|
||||||
"countReset",
|
|
||||||
"group",
|
|
||||||
"groupEnd",
|
|
||||||
"table",
|
|
||||||
"dirxml",
|
|
||||||
"error",
|
|
||||||
"groupCollapsed",
|
|
||||||
"Console",
|
|
||||||
"profile",
|
|
||||||
"profileEnd",
|
|
||||||
"timeStamp",
|
|
||||||
"context"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-debugger": "error",
|
|
||||||
"no-empty": "off",
|
|
||||||
"no-empty-function": "off",
|
|
||||||
"no-eval": "error",
|
|
||||||
"no-fallthrough": "error",
|
|
||||||
"no-new-wrappers": "error",
|
|
||||||
"no-restricted-imports": "error",
|
|
||||||
"no-shadow": "error",
|
|
||||||
"no-throw-literal": "error",
|
|
||||||
"no-trailing-spaces": "error",
|
|
||||||
"no-undef-init": "error",
|
|
||||||
"no-underscore-dangle": "off",
|
|
||||||
"no-unused-expressions": "off",
|
|
||||||
"no-unused-labels": "error",
|
|
||||||
"no-var": "error",
|
|
||||||
"prefer-const": "error",
|
|
||||||
"quotes": "error",
|
|
||||||
"radix": "error",
|
|
||||||
"semi": "error",
|
|
||||||
"spaced-comment": [
|
|
||||||
"error",
|
|
||||||
"always",
|
|
||||||
{
|
|
||||||
"markers": [
|
|
||||||
"/"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"valid-typeof": "error",
|
|
||||||
"@typescript-eslint/tslint/config": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"rules": {
|
|
||||||
"import-spacing": true,
|
|
||||||
"invoke-injectable": true,
|
|
||||||
"no-access-missing-member": true,
|
|
||||||
"templates-use-public": true,
|
|
||||||
"whitespace": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,4 +1 @@
|
|||||||
#!/bin/sh
|
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
npx --no-install commitlint --edit $1
|
npx --no-install commitlint --edit $1
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
#!/bin/sh
|
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
npx --no-install lint-staged
|
npx --no-install lint-staged
|
||||||
61
eslint.config.js
Normal file
61
eslint.config.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
// @ts-check
|
||||||
|
const eslint = require('@eslint/js');
|
||||||
|
const tseslint = require('typescript-eslint');
|
||||||
|
const angular = require('angular-eslint');
|
||||||
|
|
||||||
|
module.exports = tseslint.config(
|
||||||
|
{
|
||||||
|
// Everything in this config object targets our TypeScript files (Components, Directives, Pipes etc)
|
||||||
|
files: ['**/*.ts'],
|
||||||
|
extends: [
|
||||||
|
// Apply the recommended core rules
|
||||||
|
eslint.configs.recommended,
|
||||||
|
// Apply the recommended TypeScript rules
|
||||||
|
...tseslint.configs.recommended,
|
||||||
|
// Optionally apply stylistic rules from typescript-eslint that improve code consistency
|
||||||
|
...tseslint.configs.stylistic,
|
||||||
|
// Apply the recommended Angular rules
|
||||||
|
...angular.configs.tsRecommended,
|
||||||
|
],
|
||||||
|
// Set the custom processor which will allow us to have our inline Component templates extracted
|
||||||
|
// and treated as if they are HTML files (and therefore have the .html config below applied to them)
|
||||||
|
processor: angular.processInlineTemplates,
|
||||||
|
// Override specific rules for TypeScript files (these will take priority over the extended configs above)
|
||||||
|
rules: {
|
||||||
|
'@angular-eslint/directive-selector': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
type: 'attribute',
|
||||||
|
prefix: 'app',
|
||||||
|
style: 'camelCase',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'@angular-eslint/component-selector': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
type: 'element',
|
||||||
|
prefix: 'app',
|
||||||
|
style: 'kebab-case',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Everything in this config object targets our HTML files (external templates,
|
||||||
|
// and inline templates as long as we have the `processor` set on our TypeScript config above)
|
||||||
|
files: ['**/*.html'],
|
||||||
|
extends: [
|
||||||
|
// Apply the recommended Angular template rules
|
||||||
|
...angular.configs.templateRecommended,
|
||||||
|
// Apply the Angular template rules which focus on accessibility of our apps
|
||||||
|
...angular.configs.templateAccessibility,
|
||||||
|
],
|
||||||
|
rules: {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/no-unused-expressions': 'off',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
995
package-lock.json
generated
995
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
|||||||
"e2e": "ng e2e",
|
"e2e": "ng e2e",
|
||||||
"docs": "npm run docs-only",
|
"docs": "npm run docs-only",
|
||||||
"docs-only": "ts-node -P tools/tsconfig.json tools/dgeni-cli.ts tools/transforms/nestjs-package/index",
|
"docs-only": "ts-node -P tools/tsconfig.json tools/dgeni-cli.ts tools/transforms/nestjs-package/index",
|
||||||
"prepare": "husky install"
|
"prepare": "husky"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"**/*.{ts,json}": []
|
"**/*.{ts,json}": []
|
||||||
@@ -46,12 +46,13 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "18.2.9",
|
"@angular-devkit/build-angular": "18.2.9",
|
||||||
"@angular-eslint/eslint-plugin": "16.0.3",
|
"@angular-eslint/eslint-plugin": "18.3.1",
|
||||||
"@angular/cli": "18.2.9",
|
"@angular/cli": "18.2.9",
|
||||||
"@angular/compiler-cli": "18.2.8",
|
"@angular/compiler-cli": "18.2.8",
|
||||||
"@angular/language-service": "18.2.8",
|
"@angular/language-service": "18.2.8",
|
||||||
"@commitlint/cli": "19.5.0",
|
"@commitlint/cli": "19.5.0",
|
||||||
"@commitlint/config-angular": "19.5.0",
|
"@commitlint/config-angular": "19.5.0",
|
||||||
|
"@eslint/js": "^9.12.0",
|
||||||
"@types/jasmine": "5.1.4",
|
"@types/jasmine": "5.1.4",
|
||||||
"@types/jasminewd2": "2.0.10",
|
"@types/jasminewd2": "2.0.10",
|
||||||
"@types/lodash": "4.14.195",
|
"@types/lodash": "4.14.195",
|
||||||
@@ -59,10 +60,12 @@
|
|||||||
"@types/node": "20.3.1",
|
"@types/node": "20.3.1",
|
||||||
"@types/prismjs": "1.26.0",
|
"@types/prismjs": "1.26.0",
|
||||||
"@types/rimraf": "4.0.5",
|
"@types/rimraf": "4.0.5",
|
||||||
|
"angular-eslint": "^18.3.1",
|
||||||
"chokidar": "4.0.1",
|
"chokidar": "4.0.1",
|
||||||
"concurrently": "9.0.1",
|
"concurrently": "9.0.1",
|
||||||
"dgeni": "0.4.14",
|
"dgeni": "0.4.14",
|
||||||
"dgeni-packages": "0.30.0",
|
"dgeni-packages": "0.30.0",
|
||||||
|
"eslint": "^9.12.0",
|
||||||
"husky": "9.1.6",
|
"husky": "9.1.6",
|
||||||
"jasmine-core": "5.0.1",
|
"jasmine-core": "5.0.1",
|
||||||
"jasmine-spec-reporter": "7.0.0",
|
"jasmine-spec-reporter": "7.0.0",
|
||||||
@@ -77,6 +80,7 @@
|
|||||||
"rimraf": "6.0.1",
|
"rimraf": "6.0.1",
|
||||||
"ts-node": "10.9.1",
|
"ts-node": "10.9.1",
|
||||||
"typescript": "5.4.5",
|
"typescript": "5.4.5",
|
||||||
|
"typescript-eslint": "^8.10.0",
|
||||||
"uuid": "10.0.0",
|
"uuid": "10.0.0",
|
||||||
"yargs": "17.7.2"
|
"yargs": "17.7.2"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export class HomepageComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
|
|
||||||
this.scrollSubscription = fromEvent(window, 'scroll')
|
this.scrollSubscription = fromEvent(window, 'scroll')
|
||||||
.pipe(debounceTime(this.scrollDebounceTime))
|
.pipe(debounceTime(this.scrollDebounceTime))
|
||||||
.subscribe((_) => {
|
.subscribe(() => {
|
||||||
this.checkViewportBoundaries();
|
this.checkViewportBoundaries();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ export class MenuComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.router.events
|
this.router.events
|
||||||
.pipe(filter((ev) => ev instanceof NavigationEnd))
|
.pipe(filter((ev) => ev instanceof NavigationEnd))
|
||||||
.subscribe((event) => this.toggleCategory());
|
.subscribe(() => this.toggleCategory());
|
||||||
|
|
||||||
this.toggleCategory();
|
this.toggleCategory();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { BasePageComponent } from '../../page/page.component';
|
import { BasePageComponent } from '../../page/page.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-libraries',
|
selector: 'app-libraries',
|
||||||
templateUrl: './libraries.component.html',
|
templateUrl: './libraries.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class CliLibrariesComponent extends BasePageComponent {}
|
export class CliLibrariesComponent extends BasePageComponent {}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { BasePageComponent } from '../../page/page.component';
|
import { BasePageComponent } from '../../page/page.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-overview',
|
selector: 'app-overview',
|
||||||
templateUrl: './overview.component.html',
|
templateUrl: './overview.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class CliOverviewComponent extends BasePageComponent {}
|
export class CliOverviewComponent extends BasePageComponent {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { BasePageComponent } from '../../page/page.component';
|
import { BasePageComponent } from '../../page/page.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { BasePageComponent } from '../../page/page.component';
|
import { BasePageComponent } from '../../page/page.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { BasePageComponent } from '../../page/page.component';
|
import { BasePageComponent } from '../../page/page.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|||||||
import { BasePageComponent } from '../../page/page.component';
|
import { BasePageComponent } from '../../page/page.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'devtools-ci-cd',
|
selector: 'app-devtools-ci-cd',
|
||||||
templateUrl: './ci-cd.component.html',
|
templateUrl: './ci-cd.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|||||||
import { BasePageComponent } from '../../page/page.component';
|
import { BasePageComponent } from '../../page/page.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'devtools-overview',
|
selector: 'app-devtools-overview',
|
||||||
templateUrl: './overview.component.html',
|
templateUrl: './overview.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|||||||
import { BasePageComponent } from '../../page/page.component';
|
import { BasePageComponent } from '../../page/page.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'keep-alive-connections',
|
selector: 'app-keep-alive-connections',
|
||||||
templateUrl: './keep-alive-connections.component.html',
|
templateUrl: './keep-alive-connections.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tabs',
|
selector: 'app-tabs',
|
||||||
templateUrl: './tabs.component.html',
|
templateUrl: './tabs.component.html',
|
||||||
styleUrls: ['./tabs.component.scss'],
|
styleUrls: ['./tabs.component.scss'],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class TabsComponent {
|
export class TabsComponent {
|
||||||
public isJsActive = false;
|
public isJsActive = false;
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { DOCUMENT } from '@angular/common';
|
|
||||||
import {
|
import {
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
Inject,
|
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
@@ -54,7 +52,7 @@ export class TocComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.scrollSubscription = fromEvent(window, 'scroll')
|
this.scrollSubscription = fromEvent(window, 'scroll')
|
||||||
.pipe(debounceTime(this.scrollDebounceTime))
|
.pipe(debounceTime(this.scrollDebounceTime))
|
||||||
.subscribe((_) => {
|
.subscribe(() => {
|
||||||
this.findCurrentHeading();
|
this.findCurrentHeading();
|
||||||
this.checkViewportBoundaries();
|
this.checkViewportBoundaries();
|
||||||
});
|
});
|
||||||
@@ -70,6 +68,7 @@ export class TocComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.scrollSubscription && this.scrollSubscription.unsubscribe();
|
this.scrollSubscription && this.scrollSubscription.unsubscribe();
|
||||||
|
|
||||||
this.timerSubscription && this.timerSubscription.unsubscribe();
|
this.timerSubscription && this.timerSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import {
|
import { ActivatedRouteSnapshot, CanActivateFn } from '@angular/router';
|
||||||
ActivatedRouteSnapshot,
|
|
||||||
CanActivateFn,
|
|
||||||
RouterStateSnapshot,
|
|
||||||
} from '@angular/router';
|
|
||||||
|
|
||||||
export const RedirectGuard: CanActivateFn = (
|
export const RedirectGuard: CanActivateFn = (route: ActivatedRouteSnapshot) => {
|
||||||
route: ActivatedRouteSnapshot,
|
|
||||||
state: RouterStateSnapshot,
|
|
||||||
) => {
|
|
||||||
window.location.href = route.data['externalUrl'];
|
window.location.href = route.data['externalUrl'];
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import 'zone.js/dist/fake-async-test';
|
|||||||
import { getTestBed } from '@angular/core/testing';
|
import { getTestBed } from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
BrowserDynamicTestingModule,
|
BrowserDynamicTestingModule,
|
||||||
platformBrowserDynamicTesting
|
platformBrowserDynamicTesting,
|
||||||
} from '@angular/platform-browser-dynamic/testing';
|
} from '@angular/platform-browser-dynamic/testing';
|
||||||
|
|
||||||
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
|
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
|
||||||
@@ -17,12 +17,13 @@ declare const __karma__: any;
|
|||||||
declare const require: any;
|
declare const require: any;
|
||||||
|
|
||||||
// Prevent Karma from running prematurely.
|
// Prevent Karma from running prematurely.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
__karma__.loaded = function () {};
|
__karma__.loaded = function () {};
|
||||||
|
|
||||||
// First, initialize the Angular testing environment.
|
// First, initialize the Angular testing environment.
|
||||||
getTestBed().initTestEnvironment(
|
getTestBed().initTestEnvironment(
|
||||||
BrowserDynamicTestingModule,
|
BrowserDynamicTestingModule,
|
||||||
platformBrowserDynamicTesting()
|
platformBrowserDynamicTesting(),
|
||||||
);
|
);
|
||||||
// Then we find all the tests.
|
// Then we find all the tests.
|
||||||
const context = require.context('./', true, /\.spec\.ts$/);
|
const context = require.context('./', true, /\.spec\.ts$/);
|
||||||
|
|||||||
2
src/typings.d.ts
vendored
2
src/typings.d.ts
vendored
@@ -1,5 +1,5 @@
|
|||||||
/* SystemJS module definition */
|
/* SystemJS module definition */
|
||||||
declare var module: NodeModule;
|
declare let module: NodeModule;
|
||||||
interface NodeModule {
|
interface NodeModule {
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||||
import { Dgeni } from 'dgeni';
|
import { Dgeni } from 'dgeni';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
|
|
||||||
const argv = require('yargs').argv;
|
const argv = require('yargs').argv;
|
||||||
const packagePaths = argv._;
|
const packagePaths = argv._;
|
||||||
|
|
||||||
const packages = packagePaths.map(packagePath => {
|
const packages = packagePaths.map((packagePath) => {
|
||||||
if (packagePath.indexOf('.') === 0) {
|
if (packagePath.indexOf('.') === 0) {
|
||||||
packagePath = resolve(packagePath);
|
packagePath = resolve(packagePath);
|
||||||
}
|
}
|
||||||
@@ -13,10 +14,10 @@ const packages = packagePaths.map(packagePath => {
|
|||||||
|
|
||||||
new Dgeni(packages)
|
new Dgeni(packages)
|
||||||
.generate()
|
.generate()
|
||||||
.then(docs => {
|
.then((docs) => {
|
||||||
console.log(`${docs.length} docs generated.`);
|
console.log(`${docs.length} docs generated.`);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,19 +3,19 @@ import { Processor, DocCollection } from 'dgeni';
|
|||||||
/**
|
/**
|
||||||
* Extracts the title of a content file.
|
* Extracts the title of a content file.
|
||||||
* This processor assumes that the first line of the
|
* This processor assumes that the first line of the
|
||||||
* content includes the title.
|
* content includes the title.
|
||||||
*/
|
*/
|
||||||
export class ExtractContentTitleProcessor implements Processor {
|
export class ExtractContentTitleProcessor implements Processor {
|
||||||
$runAfter = ['renderDocsProcessor'];
|
$runAfter = ['renderDocsProcessor'];
|
||||||
$runBefore = ['convertToJsonProcessor'];
|
$runBefore = ['convertToJsonProcessor'];
|
||||||
$process(docs: DocCollection) {
|
$process(docs: DocCollection) {
|
||||||
docs.forEach(doc => {
|
docs.forEach((doc) => {
|
||||||
if (doc.docType === 'content') {
|
if (doc.docType === 'content') {
|
||||||
try {
|
try {
|
||||||
const firstLine: string = doc.content.split('\n')[0];
|
const firstLine: string = doc.content.split('\n')[0];
|
||||||
const title = firstLine.replace(/#/g, '').trim();
|
const title = firstLine.replace(/#/g, '').trim();
|
||||||
doc.title = title;
|
doc.title = title;
|
||||||
} catch (ex) {
|
} catch {
|
||||||
// We do not care if the title does not exist here
|
// We do not care if the title does not exist here
|
||||||
// convertToJson will complain later in case the title
|
// convertToJson will complain later in case the title
|
||||||
// does not exist
|
// does not exist
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ export function nestjsMarkedNunjucksTag(renderNestJSMarkdown: RenderNestJSMarkdo
|
|||||||
parse: function(parser: any, nodes: any) {
|
parse: function(parser: any, nodes: any) {
|
||||||
parser.advanceAfterBlockEnd();
|
parser.advanceAfterBlockEnd();
|
||||||
|
|
||||||
var content = parser.parseUntilBlocks('endmarked');
|
const content = parser.parseUntilBlocks('endmarked');
|
||||||
var tag = new nodes.CallExtension(this, 'process', null, [content]);
|
const tag = new nodes.CallExtension(this, 'process', null, [content]);
|
||||||
parser.advanceAfterBlockEnd();
|
parser.advanceAfterBlockEnd();
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
|
|||||||
@@ -25,6 +25,5 @@ export function renderNestJSMarkdown() {
|
|||||||
applyHeadingRenderer(renderer);
|
applyHeadingRenderer(renderer);
|
||||||
applyBlockQuoteRenderer(renderer);
|
applyBlockQuoteRenderer(renderer);
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
return (content: string) => marked(content, { renderer });
|
return (content: string) => marked(content, { renderer });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ export function applyCodeRenderer(renderer: Renderer) {
|
|||||||
if (filenameIndex >= 0) {
|
if (filenameIndex >= 0) {
|
||||||
const output = replaceFilename(
|
const output = replaceFilename(
|
||||||
(text, directiveRef) =>
|
(text, directiveRef) =>
|
||||||
// @ts-ignore
|
|
||||||
renderer.code(text, language, isEscaped, directiveRef, true),
|
renderer.code(text, language, isEscaped, directiveRef, true),
|
||||||
code,
|
code,
|
||||||
filenameKey,
|
filenameKey,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export class ConvertToJsonProcessor implements Processor {
|
|||||||
const docTypes = this.docTypes;
|
const docTypes = this.docTypes;
|
||||||
docs.forEach((doc: any) => {
|
docs.forEach((doc: any) => {
|
||||||
if (docTypes.includes(doc.docType)) {
|
if (docTypes.includes(doc.docType)) {
|
||||||
let contents = doc.renderedContent || '';
|
const contents = doc.renderedContent || '';
|
||||||
|
|
||||||
let title = doc.title;
|
let title = doc.title;
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +1,50 @@
|
|||||||
import { Package } from 'dgeni';
|
import { Package } from 'dgeni';
|
||||||
|
|
||||||
import { CONTENTS_PATH } from '../config';
|
import { CONTENTS_PATH } from '../config';
|
||||||
import nestjsBasePackage, {
|
import nestjsBasePackage from '../nestjs-base-package';
|
||||||
ConvertToJsonProcessor
|
|
||||||
} from '../nestjs-base-package';
|
|
||||||
import contentPackage, { contentFileReader } from '../content-package';
|
import contentPackage, { contentFileReader } from '../content-package';
|
||||||
|
|
||||||
export default new Package('nestjs-content', [
|
export default new Package('nestjs-content', [
|
||||||
nestjsBasePackage,
|
nestjsBasePackage,
|
||||||
contentPackage
|
contentPackage,
|
||||||
])
|
])
|
||||||
.config((readFilesProcessor: any) => {
|
.config((readFilesProcessor: any) => {
|
||||||
readFilesProcessor.sourceFiles = readFilesProcessor.sourceFiles.concat([
|
readFilesProcessor.sourceFiles = readFilesProcessor.sourceFiles.concat([
|
||||||
{
|
{
|
||||||
basePath: CONTENTS_PATH,
|
basePath: CONTENTS_PATH,
|
||||||
include: CONTENTS_PATH + '/**/*.md',
|
include: CONTENTS_PATH + '/**/*.md',
|
||||||
fileReader: contentFileReader.name
|
fileReader: contentFileReader.name,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
basePath: CONTENTS_PATH,
|
basePath: CONTENTS_PATH,
|
||||||
include: CONTENTS_PATH + '/navigation.json',
|
include: CONTENTS_PATH + '/navigation.json',
|
||||||
fileReader: 'jsonFileReader'
|
fileReader: 'jsonFileReader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
basePath: CONTENTS_PATH,
|
basePath: CONTENTS_PATH,
|
||||||
include: CONTENTS_PATH + '/discover/who-uses.json',
|
include: CONTENTS_PATH + '/discover/who-uses.json',
|
||||||
fileReader: 'jsonFileReader'
|
fileReader: 'jsonFileReader',
|
||||||
}
|
},
|
||||||
]);
|
]);
|
||||||
})
|
})
|
||||||
|
|
||||||
.config((computePathsProcessor: any) => {
|
.config((computePathsProcessor: any) => {
|
||||||
// Replace any path templates inherited from other packages
|
// Replace any path templates inherited from other packages
|
||||||
// (we want full and transparent control)
|
// (we want full and transparent control)
|
||||||
computePathsProcessor.pathTemplates = computePathsProcessor.pathTemplates.concat(
|
computePathsProcessor.pathTemplates =
|
||||||
[
|
computePathsProcessor.pathTemplates.concat([
|
||||||
{
|
{
|
||||||
docTypes: ['content', 'who-uses'],
|
docTypes: ['content', 'who-uses'],
|
||||||
getPath: doc => `${doc.id.replace(/\/index$/, '')}`,
|
getPath: (doc) => `${doc.id.replace(/\/index$/, '')}`,
|
||||||
outputPathTemplate: '${path}.json'
|
outputPathTemplate: '${path}.json',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
docTypes: ['who-uses-json'],
|
docTypes: ['who-uses-json'],
|
||||||
pathTemplate: '${id}',
|
pathTemplate: '${id}',
|
||||||
outputPathTemplate: '../${id}.json'
|
outputPathTemplate: '../${id}.json',
|
||||||
}
|
},
|
||||||
]
|
]);
|
||||||
);
|
});
|
||||||
})
|
// .config((convertToJsonProcessor: ConvertToJsonProcessor) => {
|
||||||
// .config((convertToJsonProcessor: ConvertToJsonProcessor) => {
|
// convertToJsonProcessor.docTypes.push('content');
|
||||||
// convertToJsonProcessor.docTypes.push('content');
|
// });
|
||||||
// });
|
|
||||||
|
|||||||
Reference in New Issue
Block a user