-
-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unknown reason for "range null" with eslintIntegration #842
Comments
Happens with JS files, too, if there are backtick string literals in the file.
|
prettier/prettier-eslint#213 |
Thanks @tim0991 , with This is formatted to (missing before parenthesis) : import { AuthenticationError, ForbiddenError } from 'apollo-server-core'
import { UserJWT, UserRole } from '@/database/admin/User'
/**
* Check if user is logged
*
* @param user the user info
* @param throwErr the error is throw
*/
function isAuth(user: UserJWT | false, throwErr: boolean = false): boolean {
if (user === false && throwErr) {
throw new AuthenticationError('Access denied! You are not logged !')
}
return user !== false
}
/**
* Check if user has role
*
* @param user the user data
* @param roles the roles
* @param throwErr thr error is throw
*/
function hasRole(
user: UserJWT | false,
roles: UserRole[] | UserRole = UserRole.CLIENT,
throwErr: boolean = false
): boolean {
if (!isAuth(user, throwErr)) {
return false
}
user = user as UserJWT // Fix type checking
if (
(typeof user.role === 'string' && user.role !== roles) ||
!roles.includes(user.role)
) {
if (throwErr) {
throw new ForbiddenError(
"Access denied! You don't have permission for this action!"
)
}
return false
}
return true
}
function hasKey(
key: string,
tryKey: string | true = null,
throwErr: boolean = false
): boolean {
if ((tryKey === true && key === null) || key !== tryKey) {
if (throwErr) {
throw new ForbiddenError(
"Access denied! You don't have permission for this action! (The key is incorrect)"
)
}
return false
}
return true
}
export default {
isAuth,
hasRole,
hasKey
} |
Prettier breaks when "as" cast is present:
|
This issue is linked to It can be very easily fixed by upgrading to It's incredibly frustrating if you are using TypeScript with this extension :/ The issue is located here, where The PR to fix the bug is here #861 |
Next release will have ESLint 9.0.0. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hello,
I have an error sometime on some typescript files.
Note: On the editor and with
eslint
command i don't have lint errorThe error :
My file :
My eslintrc :
Thanks.
The text was updated successfully, but these errors were encountered: