Skip to content

Commit

Permalink
chore: Update typescript-eslint monorepo to v5, eslint and elint-airb…
Browse files Browse the repository at this point in the history
…nb related packages
  • Loading branch information
renovate[bot] authored and stalniy committed Dec 17, 2022
1 parent 8f5909a commit c795e8b
Show file tree
Hide file tree
Showing 8 changed files with 460 additions and 597 deletions.
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"*.d.ts"
],
"extends": [
"airbnb-base",
"airbnb-typescript/base"
],
"plugins": ["import"],
"parserOptions": {
"project": "./tsconfig.json"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/casl-ability/spec/spec_helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chai from 'chai'
import spies from 'chai-spies'
import '../../dx/lib/spec_helper'
import '@casl/dx/lib/spec_helper'

chai.use(spies)

Expand Down
8 changes: 4 additions & 4 deletions packages/casl-ability/src/AbilityBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export class AbilityBuilder<T extends AnyAbility> {
can<
I extends InstanceOf<T, S>,
S extends SubjectTypeOf<T> = SubjectTypeOf<T>
>(...args: BuilderCanParameters<S, I, T>): RuleBuilder<T>
>(...args: BuilderCanParameters<S, I, T>): RuleBuilder<T>;
can<
I extends InstanceOf<T, S>,
F extends string = Keys<I>,
S extends SubjectTypeOf<T> = SubjectTypeOf<T>
>(...args: BuilderCanParametersWithFields<S, I, F | Keys<I>, T>): RuleBuilder<T>
>(...args: BuilderCanParametersWithFields<S, I, F | Keys<I>, T>): RuleBuilder<T>;
can(
action: string | string[],
subject?: SubjectType | SubjectType[],
Expand Down Expand Up @@ -127,12 +127,12 @@ export class AbilityBuilder<T extends AnyAbility> {
cannot<
I extends InstanceOf<T, S>,
S extends SubjectTypeOf<T> = SubjectTypeOf<T>
>(...args: BuilderCanParameters<S, I, T>): RuleBuilder<T>
>(...args: BuilderCanParameters<S, I, T>): RuleBuilder<T>;
cannot<
I extends InstanceOf<T, S>,
F extends string = Keys<I>,
S extends SubjectTypeOf<T> = SubjectTypeOf<T>
>(...args: BuilderCanParametersWithFields<S, I, F | Keys<I>, T>): RuleBuilder<T>
>(...args: BuilderCanParametersWithFields<S, I, F | Keys<I>, T>): RuleBuilder<T>;
cannot(
action: string | string[],
subject?: SubjectType | SubjectType[],
Expand Down
4 changes: 2 additions & 2 deletions packages/casl-ability/src/ForbiddenError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ export class ForbiddenError<T extends AnyAbility> extends NativeError {
return this;
}

throwUnlessCan(...args: Parameters<T['can']>): void
throwUnlessCan(...args: Parameters<T['can']>): void;
throwUnlessCan(action: string, subject?: Subject, field?: string): void {
const error = (this as any).unlessCan(action, subject, field);
if (error) throw error;
}

unlessCan(...args: Parameters<T['can']>): this | undefined
unlessCan(...args: Parameters<T['can']>): this | undefined;
unlessCan(action: string, subject?: Subject, field?: string): this | undefined {
const rule = this.ability.relevantRuleFor(action, subject, field);

Expand Down
6 changes: 3 additions & 3 deletions packages/casl-ability/src/PureAbility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export class PureAbility<
A extends Abilities = AbilityTuple,
Conditions = unknown
> extends RuleIndex<A, Conditions> {
can(...args: CanParameters<A>): boolean
can(...args: CanParameters<A>): boolean;
can(action: string, subject?: Subject, field?: string): boolean {
const rule = (this as PrimitiveAbility).relevantRuleFor(action, subject, field);
return !!rule && !rule.inverted;
}

relevantRuleFor(...args: CanParameters<A>): Rule<A, Conditions> | null
relevantRuleFor(...args: CanParameters<A>): Rule<A, Conditions> | null;
relevantRuleFor(action: string, subject?: Subject, field?: string): Rule<A, Conditions> | null {
const subjectType = this.detectSubjectType(subject);
const rules = (this as any).rulesFor(action, subjectType, field);
Expand All @@ -41,7 +41,7 @@ export class PureAbility<
return null;
}

cannot(...args: CanParameters<A>): boolean
cannot(...args: CanParameters<A>): boolean;
cannot(action: string, subject?: Subject, field?: string): boolean {
return !(this as PrimitiveAbility).can(action, subject, field);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/casl-ability/src/RuleIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class RuleIndex<A extends Abilities, Conditions> {
return indexedRules;
}

possibleRulesFor(...args: AbilitySubjectTypeParameters<A, false>): Rule<A, Conditions>[]
possibleRulesFor(...args: AbilitySubjectTypeParameters<A, false>): Rule<A, Conditions>[];
possibleRulesFor(
action: string,
subjectType: SubjectType = this._anySubjectType
Expand Down Expand Up @@ -199,7 +199,7 @@ export class RuleIndex<A extends Abilities, Conditions> {
return rules;
}

rulesFor(...args: AbilitySubjectTypeParameters<A>): Rule<A, Conditions>[]
rulesFor(...args: AbilitySubjectTypeParameters<A>): Rule<A, Conditions>[];
rulesFor(action: string, subjectType?: SubjectType, field?: string): Rule<A, Conditions>[] {
const rules: Rule<A, Conditions>[] = (this as any).possibleRulesFor(action, subjectType);

Expand Down
15 changes: 6 additions & 9 deletions packages/dx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
"@rollup/plugin-node-resolve": "^13.0.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.0.0",
"eslint": "^7.26.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.30.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"jest": "^28.0.0",
"lint-staged": "^11.0.0",
"rollup": "^2.47.0",
Expand Down
Loading

0 comments on commit c795e8b

Please sign in to comment.