[AAE-7101] - Introduced Eslint to ACA and added some fix to avoid errors (#2424)

* Conversion to ESlint

* Fixed ESLINT for ACA

* [AAE-6638] - typo in eslint file

* [AAE-6638] - attempt to fix problem on linting

* Check caching to improve lint speed

* Improved eslint for content-app

* Added new cache

* Remove cache file

* Removed eslintcache

* Attempt to make eslint run on travis

* Slow ng lint on travis

* Fixed eslint error
This commit is contained in:
Vito
2022-02-09 08:40:04 +00:00
committed by GitHub
parent fde64be498
commit 23262d0949
72 changed files with 3979 additions and 702 deletions

View File

@@ -0,0 +1,124 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"projects/aca-about/tsconfig.lib.json",
"projects/aca-about/tsconfig.spec.json"
],
"createDefaultProgram": true
},
"plugins": [
"eslint-plugin-react",
"eslint-plugin-rxjs",
"eslint-plugin-unicorn"
],
"rules": {
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": [
"lib",
"aca",
"app",
"adf"
],
"style": "kebab-case"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": [
"lib",
"aca",
"app",
"adf"
],
"style": "camelCase"
}
],
"@angular-eslint/no-host-metadata-property": "off",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/semi": [
"off",
null
],
"@typescript-eslint/type-annotation-spacing": "off",
"arrow-parens": [
"off",
"always"
],
"brace-style": [
"off",
"off"
],
"eol-last": "off",
"id-blacklist": "off",
"id-match": "off",
"linebreak-style": "off",
"max-len": "off",
"new-parens": "off",
"newline-per-chained-call": "off",
"no-duplicate-imports": "error",
"no-extra-semi": "off",
"no-irregular-whitespace": "off",
"no-return-await": "error",
"no-underscore-dangle": "off",
"quote-props": "off",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-wrap-multilines": "off",
"rxjs/no-create": "error",
"rxjs/no-subject-unsubscribe": "error",
"rxjs/no-subject-value": "error",
"rxjs/no-unsafe-takeuntil": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"off",
"never"
],
"unicorn/filename-case": "error"
}
},
{
"files": [
"*.html"
],
"rules": {
"@angular-eslint/template/no-autofocus": "error",
"@angular-eslint/template/no-negated-async": "off",
"@angular-eslint/template/no-positive-tabindex": "error"
}
}
]
}

View File

@@ -1,17 +0,0 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
["lib", "aca", "app", "adf"],
"camelCase"
],
"component-selector": [
true,
"element",
["lib", "aca", "app", "adf"],
"kebab-case"
]
}
}

View File

@@ -0,0 +1,124 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"projects/aca-settings/tsconfig.lib.json",
"projects/aca-settings/tsconfig.spec.json"
],
"createDefaultProgram": true
},
"plugins": [
"eslint-plugin-react",
"eslint-plugin-rxjs",
"eslint-plugin-unicorn"
],
"rules": {
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": [
"lib",
"aca",
"app",
"adf"
],
"style": "kebab-case"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": [
"lib",
"aca",
"app",
"adf"
],
"style": "camelCase"
}
],
"@angular-eslint/no-host-metadata-property": "off",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/semi": [
"off",
null
],
"@typescript-eslint/type-annotation-spacing": "off",
"arrow-parens": [
"off",
"always"
],
"brace-style": [
"off",
"off"
],
"eol-last": "off",
"id-blacklist": "off",
"id-match": "off",
"linebreak-style": "off",
"max-len": "off",
"new-parens": "off",
"newline-per-chained-call": "off",
"no-duplicate-imports": "error",
"no-extra-semi": "off",
"no-irregular-whitespace": "off",
"no-return-await": "error",
"no-underscore-dangle": "off",
"quote-props": "off",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-wrap-multilines": "off",
"rxjs/no-create": "error",
"rxjs/no-subject-unsubscribe": "error",
"rxjs/no-subject-value": "error",
"rxjs/no-unsafe-takeuntil": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"off",
"never"
],
"unicorn/filename-case": "error"
}
},
{
"files": [
"*.html"
],
"rules": {
"@angular-eslint/template/no-autofocus": "error",
"@angular-eslint/template/no-negated-async": "off",
"@angular-eslint/template/no-positive-tabindex": "error"
}
}
]
}

View File

@@ -1,17 +0,0 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
["lib", "aca", "app", "adf"],
"camelCase"
],
"component-selector": [
true,
"element",
["lib", "aca", "app", "adf"],
"kebab-case"
]
}
}

View File

@@ -0,0 +1,114 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"projects/aca-shared/tsconfig.lib.json",
"projects/aca-shared/tsconfig.spec.json"
],
"createDefaultProgram": true
},
"plugins": [
"eslint-plugin-react",
"eslint-plugin-rxjs",
"eslint-plugin-unicorn"
],
"rules": {
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": ["aca", "adf", "app"],
"style": "kebab-case"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": ["aca", "adf", "app"],
"style": "camelCase"
}
],
"@angular-eslint/no-host-metadata-property": "off",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/semi": [
"off",
null
],
"@typescript-eslint/type-annotation-spacing": "off",
"arrow-parens": [
"off",
"always"
],
"brace-style": [
"off",
"off"
],
"eol-last": "off",
"id-blacklist": "off",
"id-match": "off",
"linebreak-style": "off",
"max-len": "off",
"new-parens": "off",
"newline-per-chained-call": "off",
"no-duplicate-imports": "error",
"no-extra-semi": "off",
"no-irregular-whitespace": "off",
"no-return-await": "error",
"no-underscore-dangle": "off",
"quote-props": "off",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-wrap-multilines": "off",
"rxjs/no-create": "error",
"rxjs/no-subject-unsubscribe": "error",
"rxjs/no-subject-value": "error",
"rxjs/no-unsafe-takeuntil": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"off",
"never"
],
"unicorn/filename-case": "error"
}
},
{
"files": [
"*.html"
],
"rules": {
"@angular-eslint/template/no-autofocus": "error",
"@angular-eslint/template/no-negated-async": "off",
"@angular-eslint/template/no-positive-tabindex": "error"
}
}
]
}

View File

@@ -35,11 +35,11 @@ export interface AcaRuleContext extends RuleContext {
/**
* Checks if user can copy selected node.
* JSON ref: `app.canCopyNode`
*
* @param context Rule execution context
*/
export function canCopyNode(context: RuleContext): boolean {
return [hasSelection(context), navigation.isNotTrashcan(context), navigation.isNotLibraries(context)].every(Boolean);
}
export const canCopyNode = (context: RuleContext): boolean =>
[hasSelection(context), navigation.isNotTrashcan(context), navigation.isNotLibraries(context)].every(Boolean);
/**
* Checks if user can mark selected nodes as **Favorite**.
@@ -73,29 +73,24 @@ export function canRemoveFavorite(context: RuleContext): boolean {
* Checks if user can share selected file.
* JSON ref: `app.selection.file.canShare`
*/
export function canShareFile(context: RuleContext): boolean {
return [context.selection.file, navigation.isNotTrashcan(context), repository.hasQuickShareEnabled(context), !isShared(context)].every(Boolean);
}
export const canShareFile = (context: RuleContext): boolean =>
[context.selection.file, navigation.isNotTrashcan(context), repository.hasQuickShareEnabled(context), !isShared(context)].every(Boolean);
/**
* Checks if user can perform "Join" or "Cancel Join Request" on a library.
* JSON ref: `canToggleJoinLibrary`
*/
export function canToggleJoinLibrary(context: RuleContext): boolean {
return (
[hasLibrarySelected(context), !isPrivateLibrary(context), hasNoLibraryRole(context)].every(Boolean) ||
[hasLibrarySelected(context), isPrivateLibrary(context), hasNoLibraryRole(context), isAdmin(context)].every(Boolean)
);
}
export const canToggleJoinLibrary = (context: RuleContext): boolean =>
[hasLibrarySelected(context), !isPrivateLibrary(context), hasNoLibraryRole(context)].every(Boolean) ||
[hasLibrarySelected(context), isPrivateLibrary(context), hasNoLibraryRole(context), isAdmin(context)].every(Boolean);
/**
* Checks if user can edit the selected folder.
* JSON ref: `canEditFolder`
*
* @param context Rule execution context
*/
export function canEditFolder(context: RuleContext): boolean {
return [canUpdateSelectedFolder(context), navigation.isNotTrashcan(context)].every(Boolean);
}
export const canEditFolder = (context: RuleContext): boolean => [canUpdateSelectedFolder(context), navigation.isNotTrashcan(context)].every(Boolean);
/**
* Checks if the selected file is already shared.
@@ -166,9 +161,7 @@ export function canUnshareNodes(context: RuleContext): boolean {
* Checks if user selected anything.
* JSON ref: `app.selection.notEmpty`
*/
export function hasSelection(context: RuleContext): boolean {
return !context.selection.isEmpty;
}
export const hasSelection = (context: RuleContext): boolean => !context.selection.isEmpty;
/**
* Checks if user can create a new folder with current path.
@@ -200,9 +193,7 @@ export function canUpload(context: RuleContext): boolean {
*/
export function canDownloadSelection(context: RuleContext): boolean {
if (!context.selection.isEmpty && navigation.isNotTrashcan(context)) {
return context.selection.nodes.every((node: any) => {
return node.entry && (node.entry.isFile || node.entry.isFolder || !!node.entry.nodeId);
});
return context.selection.nodes.every((node: any) => node.entry && (node.entry.isFile || node.entry.isFolder || !!node.entry.nodeId));
}
return false;
}
@@ -211,17 +202,13 @@ export function canDownloadSelection(context: RuleContext): boolean {
* Checks if user has selected a folder.
* JSON ref: `app.selection.folder`
*/
export function hasFolderSelected(context: RuleContext): boolean {
return !!context.selection.folder;
}
export const hasFolderSelected = (context: RuleContext): boolean => !!context.selection.folder;
/**
* Checks if user has selected a library (site).
* JSON ref: `app.selection.library`
*/
export function hasLibrarySelected(context: RuleContext): boolean {
return !!context.selection.library;
}
export const hasLibrarySelected = (context: RuleContext): boolean => !!context.selection.library;
/**
* Checks if user has selected a **private** library (site)
@@ -245,17 +232,13 @@ export function hasLibraryRole(context: RuleContext): boolean {
* Checks if the selected library has no **role** property defined.
* JSON ref: `app.selection.hasNoLibraryRole`
*/
export function hasNoLibraryRole(context: RuleContext): boolean {
return !hasLibraryRole(context);
}
export const hasNoLibraryRole = (context: RuleContext): boolean => !hasLibraryRole(context);
/**
* Checks if user has selected a file.
* JSON ref: `app.selection.file`
*/
export function hasFileSelected(context: RuleContext): boolean {
return !!(context && context.selection && context.selection.file);
}
export const hasFileSelected = (context: RuleContext): boolean => !!(context && context.selection && context.selection.file);
/**
* Checks if user can update the first selected node.
@@ -319,8 +302,8 @@ export function hasLockedFiles(context: RuleContext): boolean {
* Checks if the selected file has **write** or **read-only** locks specified.
* JSON ref: `app.selection.file.isLocked`
*/
export function isWriteLocked(context: RuleContext): boolean {
return !!(
export const isWriteLocked = (context: RuleContext): boolean =>
!!(
context &&
context.selection &&
context.selection.file &&
@@ -329,28 +312,22 @@ export function isWriteLocked(context: RuleContext): boolean {
(context.selection.file.entry.properties['cm:lockType'] === 'WRITE_LOCK' ||
context.selection.file.entry.properties['cm:lockType'] === 'READ_ONLY_LOCK')
);
}
/**
* Checks if the selected file has **write** or **read-only** locks specified,
* and that current user is the owner of the lock.
* JSON ref: `app.selection.file.isLockOwner`
*/
export function isUserWriteLockOwner(context: RuleContext): boolean {
return (
isWriteLocked(context) &&
context.selection.file.entry.properties['cm:lockOwner'] &&
context.selection.file.entry.properties['cm:lockOwner'].id === context.profile.id
);
}
export const isUserWriteLockOwner = (context: RuleContext): boolean =>
isWriteLocked(context) &&
context.selection.file.entry.properties['cm:lockOwner'] &&
context.selection.file.entry.properties['cm:lockOwner'].id === context.profile.id;
/**
* Checks if user can lock selected file.
* JSON ref: `app.selection.file.canLock`
*/
export function canLockFile(context: RuleContext): boolean {
return !isWriteLocked(context) && canUpdateSelectedNode(context);
}
export const canLockFile = (context: RuleContext): boolean => !isWriteLocked(context) && canUpdateSelectedNode(context);
/**
* Checks if user can unlock selected file.
@@ -380,131 +357,124 @@ export function canUploadVersion(context: RuleContext): boolean {
/**
* Checks if user has trashcan item selected.
* JSON ref: `isTrashcanItemSelected`
*
* @param context Rule execution context
*/
export function isTrashcanItemSelected(context: RuleContext): boolean {
return [navigation.isTrashcan(context), hasSelection(context)].every(Boolean);
}
export const isTrashcanItemSelected = (context: RuleContext): boolean => [navigation.isTrashcan(context), hasSelection(context)].every(Boolean);
/**
* Checks if user can view the file.
* JSON ref: `canViewFile`
*
* @param context Rule execution context
*/
export function canViewFile(context: RuleContext): boolean {
return [hasFileSelected(context), navigation.isNotTrashcan(context)].every(Boolean);
}
export const canViewFile = (context: RuleContext): boolean => [hasFileSelected(context), navigation.isNotTrashcan(context)].every(Boolean);
/**
* Checks if user can **Leave** selected library.
* JSON ref: `canLeaveLibrary`
*
* @param context Rule execution context
*/
export function canLeaveLibrary(context: RuleContext): boolean {
return [hasLibrarySelected(context), hasLibraryRole(context)].every(Boolean);
}
export const canLeaveLibrary = (context: RuleContext): boolean => [hasLibrarySelected(context), hasLibraryRole(context)].every(Boolean);
/**
* Checks if user can toggle shared link mode.
* JSON ref: `canToggleSharedLink`
*
* @param context Rule execution context
*/
export function canToggleSharedLink(context: RuleContext): boolean {
return [hasFileSelected(context), [canShareFile(context), isShared(context)].some(Boolean)].every(Boolean);
}
export const canToggleSharedLink = (context: RuleContext): boolean =>
[hasFileSelected(context), [canShareFile(context), isShared(context)].some(Boolean)].every(Boolean);
/**
* Checks if user can show **Info Drawer** for the selected node.
* JSON ref: `canShowInfoDrawer`
*
* @param context Rule execution context
*/
export function canShowInfoDrawer(context: RuleContext): boolean {
return [hasSelection(context), navigation.isNotLibraries(context), navigation.isNotTrashcan(context)].every(Boolean);
}
export const canShowInfoDrawer = (context: RuleContext): boolean =>
[hasSelection(context), navigation.isNotLibraries(context), navigation.isNotTrashcan(context)].every(Boolean);
/**
* Checks if user can manage file versions for the selected node.
* JSON ref: `canManageFileVersions`
*
* @param context Rule execution context
*/
export function canManageFileVersions(context: RuleContext): boolean {
return [hasFileSelected(context), navigation.isNotTrashcan(context), !hasLockedFiles(context)].every(Boolean);
}
export const canManageFileVersions = (context: RuleContext): boolean =>
[hasFileSelected(context), navigation.isNotTrashcan(context), !hasLockedFiles(context)].every(Boolean);
/**
* Checks if user can edit aspects for the selected node.
* JSON ref: `canEditAspects`
*
* @param context Rule execution context
*/
export function canEditAspects(context: RuleContext): boolean {
return [
export const canEditAspects = (context: RuleContext): boolean =>
[
!isMultiselection(context),
canUpdateSelectedNode(context),
!isWriteLocked(context),
navigation.isNotTrashcan(context),
repository.isMajorVersionAvailable(context, '7')
].every(Boolean);
}
/**
* Checks if user can manage permissions for the selected node.
* JSON ref: `canManagePermissions`
*
* @param context Rule execution context
*/
export function canManagePermissions(context: RuleContext): boolean {
return [canUpdateSelectedNode(context), navigation.isNotTrashcan(context)].every(Boolean);
}
export const canManagePermissions = (context: RuleContext): boolean =>
[canUpdateSelectedNode(context), navigation.isNotTrashcan(context)].every(Boolean);
/**
* Checks if user can toggle **Edit Offline** mode for selected node.
* JSON ref: `canToggleEditOffline`
*
* @param context Rule execution context
*/
export function canToggleEditOffline(context: RuleContext): boolean {
return [hasFileSelected(context), navigation.isNotTrashcan(context), canLockFile(context) || canUnlockFile(context)].every(Boolean);
}
export const canToggleEditOffline = (context: RuleContext): boolean =>
[hasFileSelected(context), navigation.isNotTrashcan(context), canLockFile(context) || canUnlockFile(context)].every(Boolean);
/**
* @deprecated Uses workarounds for for recent files and search api issues.
* Checks if user can toggle **Favorite** state for a node.
* @param context Rule execution context
*/
export function canToggleFavorite(context: RuleContext): boolean {
return [
export const canToggleFavorite = (context: RuleContext): boolean =>
[
[canAddFavorite(context), canRemoveFavorite(context)].some(Boolean),
[navigation.isRecentFiles(context), navigation.isSharedFiles(context), navigation.isSearchResults(context), navigation.isFavorites(context)].some(
Boolean
)
].every(Boolean);
}
/**
* Checks if application should render logout option.
* JSON ref: `canShowLogout`
*
* @param context Rule execution context
*/
export function canShowLogout(context: AcaRuleContext): boolean {
return !context.withCredentials;
}
export const canShowLogout = (context: AcaRuleContext): boolean => !context.withCredentials;
/**
* Checks if user is library manager
* JSON ref: `isLibraryManager`
*
* @param context Rule execution context
*/
export function isLibraryManager(context: RuleContext): boolean {
return hasLibrarySelected(context) && context.selection.library.entry && context.selection.library.entry.role === 'SiteManager';
}
export const isLibraryManager = (context: RuleContext): boolean =>
hasLibrarySelected(context) && context.selection.library.entry && context.selection.library.entry.role === 'SiteManager';
/**
* Checks if the preview button for search results can be showed
* JSON ref: `canInfoPreview`
*
* @param context Rule execution context
*/
export function canInfoPreview(context: RuleContext): boolean {
return navigation.isSearchResults(context) && !isMultiselection(context) && !hasFolderSelected(context) && !navigation.isPreview(context);
}
export const canInfoPreview = (context: RuleContext): boolean =>
navigation.isSearchResults(context) && !isMultiselection(context) && !hasFolderSelected(context) && !navigation.isPreview(context);
export function showInfoSelectionButton(context: RuleContext): boolean {
return navigation.isSearchResults(context) && !navigation.isPreview(context);
}
export const showInfoSelectionButton = (context: RuleContext): boolean => navigation.isSearchResults(context) && !navigation.isPreview(context);

View File

@@ -47,9 +47,7 @@ export function isFavorites(context: RuleContext): boolean {
* Checks if the activated route is not **Favorites**.
* JSON ref: `app.navigation.isNotFavorites`
*/
export function isNotFavorites(context: RuleContext): boolean {
return !isFavorites(context);
}
export const isNotFavorites = (context: RuleContext): boolean => !isFavorites(context);
/**
* Checks if a **Shared Files** route is activated.
@@ -64,9 +62,7 @@ export function isSharedFiles(context: RuleContext): boolean {
* Checks if the activated route is not **Shared Files**.
* JSON ref: `app.navigation.isNotSharedFiles`
*/
export function isNotSharedFiles(context: RuleContext): boolean {
return !isSharedFiles(context);
}
export const isNotSharedFiles = (context: RuleContext): boolean => !isSharedFiles(context);
/**
* Checks if a **Trashcan** route is activated.
@@ -81,9 +77,7 @@ export function isTrashcan(context: RuleContext): boolean {
* Checks if the activated route is not **Trashcan**.
* JSON ref: `app.navigation.isNotTrashcan`
*/
export function isNotTrashcan(context: RuleContext): boolean {
return !isTrashcan(context);
}
export const isNotTrashcan = (context: RuleContext): boolean => !isTrashcan(context);
/**
* Checks if a **Personal Files** route is activated.
@@ -116,9 +110,7 @@ export function isLibraries(context: RuleContext): boolean {
* Checks if the activated route is neither **Libraries** nor **Library Search Results**.
* JSON ref: `app.navigation.isNotLibraries`
*/
export function isNotLibraries(context: RuleContext): boolean {
return !isLibraries(context);
}
export const isNotLibraries = (context: RuleContext): boolean => !isLibraries(context);
/**
* Checks if a **Recent Files** route is activated.
@@ -133,16 +125,16 @@ export function isRecentFiles(context: RuleContext): boolean {
* Checks if the activated route is not **Recent Files**.
* JSON ref: `app.navigation.isNotRecentFiles`
*/
export function isNotRecentFiles(context: RuleContext): boolean {
return !isRecentFiles(context);
}
export const isNotRecentFiles = (context: RuleContext): boolean => !isRecentFiles(context);
/**
* Checks if a **Search Results** route is activated.
* JSON ref: `app.navigation.isSearchResults`
*/
export function isSearchResults(context: RuleContext /*,
...args: RuleParameter[]*/): boolean {
export function isSearchResults(
context: RuleContext /*,
...args: RuleParameter[]*/
): boolean {
const { url } = context.navigation;
return url && url.startsWith('/search');
}
@@ -151,9 +143,7 @@ export function isSearchResults(context: RuleContext /*,
* Checks if the activated route is not **Search Results**.
* JSON ref: `app.navigation.isNotSearchResults`
*/
export function isNotSearchResults(context: RuleContext): boolean {
return !isSearchResults(context);
}
export const isNotSearchResults = (context: RuleContext): boolean => !isSearchResults(context);
/**
* Checks if a **Shared Preview** route is activated.

View File

@@ -29,9 +29,7 @@ import { RuleContext } from '@alfresco/adf-extensions';
* Checks if the quick share repository option is enabled or not.
* JSON ref: `repository.isQuickShareEnabled`
*/
export function hasQuickShareEnabled(context: RuleContext): boolean {
return context.repository.status.isQuickShareEnabled;
}
export const hasQuickShareEnabled = (context: RuleContext): boolean => context.repository.status.isQuickShareEnabled;
export function isMajorVersionAvailable(context: RuleContext, versionNumber: string): boolean {
const majorVersion = context.repository.version?.major ? parseInt(context.repository.version.major, 10) : 0;

View File

@@ -29,6 +29,4 @@ import { RuleContext } from '@alfresco/adf-extensions';
* Checks if user is admin.
* JSON ref: `user.isAdmin`
*/
export function isAdmin(context: RuleContext): boolean {
return context.profile.isAdmin;
}
export const isAdmin = (context: RuleContext): boolean => context.profile.isAdmin;

View File

@@ -122,9 +122,7 @@ describe('ExtensionsDataLoaderGuard', () => {
it('should call canActivate only once', () => {
const subject1 = new Subject<true>();
const extensionLoaders = {
fct1: function () {
return subject1.asObservable();
}
fct1: () => subject1.asObservable()
};
const extensionLoaderSpy = spyOn(extensionLoaders, 'fct1').and.callThrough();
const guard = new ExtensionsDataLoaderGuard([extensionLoaders.fct1]);

View File

@@ -30,9 +30,7 @@ import { tap, map, catchError } from 'rxjs/operators';
export type ExtensionLoaderCallback = (route: ActivatedRouteSnapshot) => Observable<boolean>;
export function DefaultExtensionLoaderFactory() {
return [];
}
export const DefaultExtensionLoaderFactory = () => [];
export const EXTENSION_DATA_LOADERS = new InjectionToken<ExtensionLoaderCallback[]>('EXTENSION_DATA_LOADERS', {
providedIn: 'root',
@@ -64,9 +62,9 @@ export class ExtensionsDataLoaderGuard implements CanActivate {
map(() => true),
tap(() => (this.invoked = true)),
catchError((e) => {
// tslint:disable-next-line
// eslint-disable-next-line no-console
console.error('Some of the extension data loader guards has been errored.');
// tslint:disable-next-line
// eslint-disable-next-line no-console
console.error(e);
return of(true);
})

View File

@@ -37,7 +37,7 @@ export class ContextActionsDirective implements OnInit, OnDestroy {
private execute$: Subject<any> = new Subject();
onDestroy$: Subject<boolean> = new Subject<boolean>();
// tslint:disable-next-line:no-input-rename
// eslint-disable-next-line
@Input('acaContextEnable')
enabled = true;
@@ -93,7 +93,7 @@ export class ContextActionsDirective implements OnInit, OnDestroy {
if (el.classList.contains(className)) {
return el;
}
// tslint:disable-next-line:curly
// eslint-disable-next-line curly
while ((el = el.parentElement) && !el.classList.contains(className));
return el;
}

View File

@@ -35,9 +35,7 @@ export class AlfrescoOfficeExtensionService {
this.appConfigService.onLoad
.pipe(
take(1),
map((appConfig) => {
return appConfig.plugins && appConfig.plugins.aosPlugin;
})
map((appConfig) => appConfig.plugins && appConfig.plugins.aosPlugin)
)
.subscribe((aosPlugin) => {
if (aosPlugin) {

View File

@@ -218,67 +218,65 @@ export class AppExtensionService implements RuleContext {
getApplicationNavigation(elements): Array<NavBarGroupRef> {
return elements
.filter((group) => this.filterVisible(group))
.map((group) => {
return {
...group,
items: (group.items || [])
.filter((entry) => !entry.disabled)
.filter((item) => this.filterVisible(item))
.sort(sortByOrder)
.map((item) => {
if (item.children && item.children.length > 0) {
item.children = item.children
.filter((entry) => !entry.disabled)
.filter((child) => this.filterVisible(child))
.sort(sortByOrder)
.map((child) => {
if (child.component) {
return {
...child
};
}
if (!child.click) {
const childRouteRef = this.extensions.getRouteById(child.route);
const childUrl = `/${childRouteRef ? childRouteRef.path : child.route}`;
return {
...child,
url: childUrl
};
}
.map((group) => ({
...group,
items: (group.items || [])
.filter((entry) => !entry.disabled)
.filter((item) => this.filterVisible(item))
.sort(sortByOrder)
.map((item) => {
if (item.children && item.children.length > 0) {
item.children = item.children
.filter((entry) => !entry.disabled)
.filter((child) => this.filterVisible(child))
.sort(sortByOrder)
.map((child) => {
if (child.component) {
return {
...child
};
}
if (!child.click) {
const childRouteRef = this.extensions.getRouteById(child.route);
const childUrl = `/${childRouteRef ? childRouteRef.path : child.route}`;
return {
...child,
action: child.click
url: childUrl
};
});
}
return {
...item
};
}
if (item.component) {
return { ...item };
}
if (!item.click) {
const routeRef = this.extensions.getRouteById(item.route);
const url = `/${routeRef ? routeRef.path : item.route}`;
return {
...item,
url
};
}
return {
...child,
action: child.click
};
});
return {
...item,
action: item.click
...item
};
})
.reduce(reduceEmptyMenus, [])
};
});
}
if (item.component) {
return { ...item };
}
if (!item.click) {
const routeRef = this.extensions.getRouteById(item.route);
const url = `/${routeRef ? routeRef.path : item.route}`;
return {
...item,
url
};
}
return {
...item,
action: item.click
};
})
.reduce(reduceEmptyMenus, [])
}));
}
loadContentMetadata(config: ExtensionConfig): any {

View File

@@ -124,6 +124,7 @@ export class ContentApiService {
/**
* Moves a node to the trashcan.
*
* @param nodeId ID of the target node
* @param options Optional parameters supported by JS-API
* @returns Empty result that notifies when the deletion is complete
@@ -134,6 +135,7 @@ export class ContentApiService {
/**
* Gets the stored information about a node.
*
* @param nodeId ID of the target node
* @param options Optional parameters supported by JS-API
* @returns Node information
@@ -170,6 +172,7 @@ export class ContentApiService {
/**
* Gets the items contained in a folder node.
*
* @param nodeId ID of the target node
* @param options Optional parameters supported by JS-API
* @returns List of child items from the folder
@@ -208,6 +211,7 @@ export class ContentApiService {
/**
* Gets information about a user identified by their username.
*
* @param personId ID of the target user
* @param options Api options
* @returns User information
@@ -230,6 +234,7 @@ export class ContentApiService {
/**
* Gets product information for Content Services.
*
* @returns ProductVersionModel containing product details
*/
getRepositoryInformation(): Observable<DiscoveryEntry> {
@@ -253,19 +258,17 @@ export class ContentApiService {
...opts,
where: '(EXISTS(target/site))'
}).pipe(
map((response: FavoritePaging) => {
return {
list: {
entries: response.list.entries.map(({ entry }: any) => {
entry.target.site.createdAt = entry.createdAt;
return {
entry: entry.target.site
};
}),
pagination: response.list.pagination
}
};
})
map((response: FavoritePaging) => ({
list: {
entries: response.list.entries.map(({ entry }: any) => {
entry.target.site.createdAt = entry.createdAt;
return {
entry: entry.target.site
};
}),
pagination: response.list.pagination
}
}))
);
}

View File

@@ -35,8 +35,13 @@ describe('RouterExtensionService', () => {
let extensionService: ExtensionService;
let service: RouterExtensionService;
let router: Router;
let component1, component2, component3, layoutComponent;
let guard1, guard2, guard3;
let component1;
let component2;
let component3;
let layoutComponent;
let guard1;
let guard2;
let guard3;
beforeEach(() => {
component1 = { name: 'component-1' };
@@ -97,17 +102,15 @@ describe('RouterExtensionService', () => {
});
describe('getApplicationRoutes', () => {
function getDummyRoute(overrides) {
return {
id: 'aca:routes/about',
path: 'ext/about',
component: 'ext:components/about',
layout: 'aca:layouts/main',
auth: ['aca:auth'],
data: { title: 'Custom About' },
...overrides
};
}
const getDummyRoute = (overrides) => ({
id: 'aca:routes/about',
path: 'ext/about',
component: 'ext:components/about',
layout: 'aca:layouts/main',
auth: ['aca:auth'],
data: { title: 'Custom About' },
...overrides
});
it('should calculate path properly', () => {
extensionService.routes = [getDummyRoute({ path: 'aca:routes/about' })];

View File

@@ -68,14 +68,12 @@ export class RouterExtensionService {
parentRoute: route.parentRoute,
children: [
...(route['children']
? route['children'].map(({ path, component, outlet, data }) => {
return {
path,
outlet,
data,
component: this.getComponentById(component)
};
})
? route['children'].map(({ path, component, outlet, data }) => ({
path,
outlet,
data,
component: this.getComponentById(component)
}))
: []),
{
path: '',
@@ -87,7 +85,7 @@ export class RouterExtensionService {
});
}
private getComponentById(id: string): Type<{}> {
private getComponentById(id: string): Type<unknown> {
return this.extensions.getComponentById(id);
}

View File

@@ -33,7 +33,7 @@ export enum SnackbarActionTypes {
export interface SnackbarAction extends Action {
payload: string;
params?: Object;
params?: any;
userAction?: SnackbarUserAction;
duration: number;
}
@@ -48,7 +48,7 @@ export class SnackbarInfoAction implements SnackbarAction {
userAction?: SnackbarUserAction;
duration = 4000;
constructor(public payload: string, public params?: Object) {}
constructor(public payload: string, public params?: any) {}
}
export class SnackbarWarningAction implements SnackbarAction {
@@ -57,7 +57,7 @@ export class SnackbarWarningAction implements SnackbarAction {
userAction?: SnackbarUserAction;
duration = 4000;
constructor(public payload: string, public params?: Object) {}
constructor(public payload: string, public params?: any) {}
}
export class SnackbarErrorAction implements SnackbarAction {
@@ -66,5 +66,5 @@ export class SnackbarErrorAction implements SnackbarAction {
userAction?: SnackbarUserAction;
duration = 4000;
constructor(public payload: string, public params?: Object) {}
constructor(public payload: string, public params?: any) {}
}

View File

@@ -75,7 +75,7 @@ export class SnackbarEffects {
const snackBarRef = this.snackBar.open(message, actionName, {
duration: action.duration || 4000,
panelClass: panelClass
panelClass
});
if (action.userAction) {
@@ -85,7 +85,7 @@ export class SnackbarEffects {
}
}
private translate(message: string, params?: Object): string {
private translate(message: string, params?: any): string {
return this.translationService.instant(message, params);
}
}

View File

@@ -49,26 +49,22 @@ export const isQuickShareEnabled = createSelector(getRepositoryStatus, (info) =>
export const isAdmin = createSelector(selectApp, (state) => state.user.isAdmin);
export const getFileUploadingDialog = createSelector(selectApp, (state) => state.fileUploadingDialog);
export const getSideNavState = createSelector(getAppSelection, getNavigationState, (selection, navigation) => {
return {
selection,
navigation
};
});
export const getSideNavState = createSelector(getAppSelection, getNavigationState, (selection, navigation) => ({
selection,
navigation
}));
export const getRuleContext = createSelector(
getAppSelection,
getNavigationState,
getUserProfile,
getRepositoryStatus,
(selection, navigation, profile, repository) => {
return {
selection,
navigation,
profile,
repository
};
}
(selection, navigation, profile, repository) => ({
selection,
navigation,
profile,
repository
})
);
export const infoDrawerMetadataAspect = createSelector(selectApp, (state) => state.infoDrawerMetadataAspect);

View File

@@ -1,7 +0,0 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [true, "attribute", "aca", "app", "camelCase"],
"component-selector": [true, "element", "aca", "app", "kebab-case"]
}
}

View File

@@ -0,0 +1,114 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"projects/adf-office-services-ext/tsconfig.lib.json",
"projects/adf-office-services-ext/tsconfig.spec.json"
],
"createDefaultProgram": true
},
"plugins": [
"eslint-plugin-react",
"eslint-plugin-rxjs",
"eslint-plugin-unicorn"
],
"rules": {
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "lib",
"style": "kebab-case"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "lib",
"style": "camelCase"
}
],
"@angular-eslint/no-host-metadata-property": "off",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/semi": [
"off",
null
],
"@typescript-eslint/type-annotation-spacing": "off",
"arrow-parens": [
"off",
"always"
],
"brace-style": [
"off",
"off"
],
"eol-last": "off",
"id-blacklist": "off",
"id-match": "off",
"linebreak-style": "off",
"max-len": "off",
"new-parens": "off",
"newline-per-chained-call": "off",
"no-duplicate-imports": "error",
"no-extra-semi": "off",
"no-irregular-whitespace": "off",
"no-return-await": "error",
"no-underscore-dangle": "off",
"quote-props": "off",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-wrap-multilines": "off",
"rxjs/no-create": "error",
"rxjs/no-subject-unsubscribe": "error",
"rxjs/no-subject-value": "error",
"rxjs/no-unsafe-takeuntil": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"off",
"never"
],
"unicorn/filename-case": "error"
}
},
{
"files": [
"*.html"
],
"rules": {
"@angular-eslint/template/no-autofocus": "error",
"@angular-eslint/template/no-negated-async": "off",
"@angular-eslint/template/no-positive-tabindex": "error"
}
}
]
}

View File

@@ -109,11 +109,11 @@ export class AosEditOnlineService {
if (!this.isWindows() && !this.isMacOs()) {
this.notificationService.openSnackMessage('Only supported for Windows and Mac', 3000);
} else {
this.aos_tryToLaunchOfficeByMsProtocolHandler(protocolHandler, url);
this.aosTryToLaunchOfficeByMsProtocolHandler(protocolHandler, url);
}
}
private aos_tryToLaunchOfficeByMsProtocolHandler(protocolHandler: string, url: string) {
private aosTryToLaunchOfficeByMsProtocolHandler(protocolHandler: string, url: string) {
const protocolUrl = protocolHandler + ':ofe%7Cu%7C' + url;
const iframe = document.createElement('iframe');

View File

@@ -30,9 +30,7 @@ describe('evaluators', () => {
it('should return [false] if using SSO', () => {
const context: any = {
auth: {
isOauth() {
return true;
}
isOauth: () => true
}
};

View File

@@ -1,17 +0,0 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"lib",
"camelCase"
],
"component-selector": [
true,
"element",
"lib",
"kebab-case"
]
}
}