Skip to content

Commit

Permalink
ci: add sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Oct 8, 2023
1 parent f413a95 commit 60c3eab
Show file tree
Hide file tree
Showing 7 changed files with 683 additions and 35 deletions.
647 changes: 647 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,28 @@
"eslintConfig": {
"extends": [
"plugin:@taiga-ui/experience/all",
"plugin:@taiga-ui/experience/taiga-naming-convention"
"plugin:@taiga-ui/experience/taiga-naming-convention",
"plugin:sonarjs/recommended",
"plugin:sonar/recommended"
],
"overrides": [
{
"files": [
"**/*.ts"
],
"rules": {
"sonar/for-in": "off",
"sonar/function-name": "off",
"sonar/max-union-size": "off",
"sonar/prefer-default-last": "off",
"sonarjs/cognitive-complexity": "off",
"sonarjs/max-switch-cases": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-identical-functions": "off",
"sonarjs/no-inverted-boolean-check": "error",
"sonarjs/no-nested-template-literals": "off"
}
},
{
"files": [
"**/*.spec.ts"
Expand Down Expand Up @@ -162,6 +181,8 @@
"cypress": "13.3.0",
"cypress-real-events": "1.10.3",
"eslint": "8.51.0",
"eslint-plugin-sonar": "0.12.0",
"eslint-plugin-sonarjs": "0.21.0",
"find-in-files": "0.5.0",
"http-server": "0.13.0",
"husky": "8.0.3",
Expand Down
8 changes: 2 additions & 6 deletions projects/cdk/schematics/ng-add/steps/wrap-with-tui-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ function getAppTemplatePath(mainPath: string): string | undefined {
const appIdentifier = mainInitializer.getElements()[0] as Identifier;
const appComponent = appIdentifier.getDefinitionNodes()[0] as ClassDeclaration;

const templateUrlPath = getTemplatePathFromComponent(appComponent);

return templateUrlPath;
return getTemplatePathFromComponent(appComponent);
}

function getTemplatePathFromComponent(component: ClassDeclaration): string {
Expand All @@ -126,11 +124,9 @@ function getTemplatePathFromComponent(component: ClassDeclaration): string {

const appComponentPath = component.getSourceFile().getFilePath().split(`/`);

const templateUrlPath = `${appComponentPath
return `${appComponentPath
.splice(0, appComponentPath.length - 1)
.join(`/`)}/${templateInitializer?.getText().replace(/['"]/g, ``)}`;

return templateUrlPath;
}

function getTemplateInitializer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export class TuiBadgedContentExample2 {
return this.contentTop === 50 ? 'tuiIconCheck' : 'var(--tui-error-fill)';
}

get contentBottom(): string {
return this.contentTop === 50 ? '' : '';
}

onClick(): void {
this.contentTop++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import {Component} from '@angular/core';
import {FormControl} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {
TuiContextWithImplicit,
TuiIdentityMatcher,
TuiStringHandler,
} from '@taiga-ui/cdk';
import {TuiContextWithImplicit} from '@taiga-ui/cdk';
import {tuiItemsHandlersProvider} from '@taiga-ui/kit';

interface Employee {
Expand All @@ -18,27 +14,18 @@ interface Employee {
readonly name: string;
}

const STRINGIFY_EMPLOYEE: TuiStringHandler<
Employee | TuiContextWithImplicit<Employee>
> = (item: Employee | TuiContextWithImplicit<Employee>) =>
'name' in item
? `${item.name} (${item.dept.title})`
: `${item.$implicit.name} (${item.$implicit.dept.title})`;

const ID_MATCHER_EMPLOYEE: TuiIdentityMatcher<Employee> = (
item1: Employee,
item2: Employee,
) => item1.id === item2.id;

@Component({
selector: 'tui-multi-select-example-8',
templateUrl: './index.html',
changeDetection,
encapsulation,
providers: [
tuiItemsHandlersProvider({
stringify: STRINGIFY_EMPLOYEE,
identityMatcher: ID_MATCHER_EMPLOYEE,
identityMatcher: (item1: Employee, item2: Employee) => item1.id === item2.id,
stringify: (item: Employee | TuiContextWithImplicit<Employee>) =>
'name' in item
? `${item.name} (${item.dept.title})`
: `${item.$implicit.name} (${item.$implicit.dept.title})`,
}),
],
})
Expand Down
10 changes: 5 additions & 5 deletions projects/demo/src/modules/components/select/examples/10/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Component} from '@angular/core';
import {FormControl} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiStringHandler} from '@taiga-ui/cdk';
import {tuiItemsHandlersProvider} from '@taiga-ui/kit';

interface Employee {
Expand All @@ -14,15 +13,16 @@ interface Employee {
readonly name: string;
}

const STRINGIFY_EMPLOYEE: TuiStringHandler<Employee> = (item: Employee) =>
`${item.name} (${item.dept.title})`;

@Component({
selector: 'tui-select-example-10',
templateUrl: './index.html',
changeDetection,
encapsulation,
providers: [tuiItemsHandlersProvider({stringify: STRINGIFY_EMPLOYEE})],
providers: [
tuiItemsHandlersProvider({
stringify: (item: Employee) => `${item.name} (${item.dept.title})`,
}),
],
})
export class TuiSelectExample10 {
readonly testValue = new FormControl(null);
Expand Down
1 change: 1 addition & 0 deletions projects/kit/constants/max-day-range-length-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
tuiObjectFromEntries,
} from '@taiga-ui/cdk';

// eslint-disable-next-line sonar/function-name
export const MAX_DAY_RANGE_LENGTH_MAPPER: TuiMapper<TuiDay, TuiDay> = (
min,
value: TuiDayRange,
Expand Down

0 comments on commit 60c3eab

Please sign in to comment.