Skip to content

Commit

Permalink
Merge pull request #1723 from filipedeschamps/improve-lint-rules
Browse files Browse the repository at this point in the history
Habilita mais regras do ESLint
  • Loading branch information
aprendendofelipe authored Jun 13, 2024
2 parents d00f4cc + b1b6301 commit b7f063f
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 17 deletions.
7 changes: 5 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
],
"rules": {
"vitest/no-conditional-in-test": "error",
"vitest/no-disabled-tests": "warn"
"vitest/no-disabled-tests": "warn",
"vitest/no-focused-tests": "error",
"vitest/require-to-throw-message": "error"
},
"env": {
"vitest-globals/env": true
Expand Down Expand Up @@ -86,6 +88,7 @@
"vars": "all",
"args": "after-used"
}
]
],
"prefer-const": "error"
}
}
2 changes: 1 addition & 1 deletion models/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ async function findTree(options = {}) {
}

function validateWhereSchema(where) {
let options = {};
const options = {};

if (where.parent_id) {
options.parent_id = 'required';
Expand Down
2 changes: 1 addition & 1 deletion pages/interface/components/PasswordInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function PasswordInput({ inputRef, id, name, label, errorObject,

function focusAfterEnd(ref) {
setTimeout(() => {
let len = ref.current.value.length;
const len = ref.current.value.length;
ref.current.focus();
ref.current.setSelectionRange(len, len);
}, 5);
Expand Down
4 changes: 2 additions & 2 deletions pages/interface/hooks/useCollapse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function useCollapse({
setChildrenState((lastState) => {
const childIndex = lastState.findIndex((child) => child.id === id);
let grouperIndex = childIndex;
let childrenToExpand = [];
const childrenToExpand = [];

while (lastState[grouperIndex]?.renderIntent === 0) {
childrenToExpand.push(lastState[grouperIndex]);
Expand All @@ -42,7 +42,7 @@ export default function useCollapse({
function handleCollapse(id) {
setChildrenState((lastState) => {
const childIndex = lastState.findIndex((child) => child.id === id);
let children = [...lastState];
const children = [...lastState];

if (childIndex < 0) return children;

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api/v1/activation/patch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe('PATCH /api/v1/activation', () => {
let defaultUser = await orchestrator.createUser();
defaultUser = await orchestrator.activateUser(defaultUser);
const activationToken = await activation.create(defaultUser);
let defaultUserSession = await orchestrator.createSession(defaultUser);
const defaultUserSession = await orchestrator.createSession(defaultUser);

const response = await fetch(`${orchestrator.webserverUrl}/api/v1/activation`, {
method: 'PATCH',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ describe('POST /api/v1/contents/tabcoins', () => {

const postTabCoinsResponsesStatus = postTabCoinsResponses.map(({ response }) => response.status);

let successPostIndexes = [postTabCoinsResponsesStatus.indexOf(201)];
const successPostIndexes = [postTabCoinsResponsesStatus.indexOf(201)];

for (let i = 0; i < timesSuccessfully; i++) {
successPostIndexes.push(postTabCoinsResponsesStatus.indexOf(201, successPostIndexes[i] + 1));
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api/v1/migrations/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('GET /api/v1/migrations', () => {
test('Retrieving pending migrations', async () => {
let defaultUser = await orchestrator.createUser();
defaultUser = await orchestrator.activateUser(defaultUser);
let defaultUserSession = await orchestrator.createSession(defaultUser);
const defaultUserSession = await orchestrator.createSession(defaultUser);

const response = await fetch(`${orchestrator.webserverUrl}/api/v1/migrations`, {
method: 'GET',
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/api/v1/migrations/post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ describe('POST /api/v1/migrations', () => {

describe('User with default features', () => {
test('Running pending migrations', async () => {
let defaultUser = await orchestrator.createUser();
const defaultUser = await orchestrator.createUser();
await orchestrator.activateUser(defaultUser);
let defaultUserSession = await orchestrator.createSession(defaultUser);
const defaultUserSession = await orchestrator.createSession(defaultUser);

const response = await fetch(`${orchestrator.webserverUrl}/api/v1/migrations`, {
method: 'POST',
Expand All @@ -60,11 +60,11 @@ describe('POST /api/v1/migrations', () => {

describe('User with "create:migration" feature', () => {
test('Running pending migrations', async () => {
let privilegedUser = await orchestrator.createUser();
const privilegedUser = await orchestrator.createUser();
await orchestrator.activateUser(privilegedUser);
await orchestrator.addFeaturesToUser(privilegedUser, ['create:migration']);

let privilegedUserSession = await orchestrator.createSession(privilegedUser);
const privilegedUserSession = await orchestrator.createSession(privilegedUser);

const response = await fetch(`${orchestrator.webserverUrl}/api/v1/migrations`, {
method: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api/v1/status/votes/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('GET /api/v1/status/votes', () => {
test('Should not retrieve voting data', async () => {
let defaultUser = await orchestrator.createUser();
defaultUser = await orchestrator.activateUser(defaultUser);
let defaultUserSession = await orchestrator.createSession(defaultUser);
const defaultUserSession = await orchestrator.createSession(defaultUser);

const response = await fetch(`${orchestrator.webserverUrl}/api/v1/status/votes`, {
method: 'GET',
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api/v1/users/[username]/patch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('PATCH /api/v1/users/[username]', () => {
let defaultUser = await orchestrator.createUser();
defaultUser = await orchestrator.activateUser(defaultUser);
const defaultUserSession = await orchestrator.createSession(defaultUser);
let secondUser = await orchestrator.createUser();
const secondUser = await orchestrator.createUser();

const response = await fetch(`${orchestrator.webserverUrl}/api/v1/users/${secondUser.username}`, {
method: 'PATCH',
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/api/v1/users/firewall.post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ describe('POST /api/v1/users [FIREWALL]', () => {

const user1 = await user.findOneById(request1Body.id);
const user2 = await user.findOneById(request2Body.id);
await expect(user.findOneByUsername('request3')).rejects.toThrow();
await expect(user.findOneByUsername('request3')).rejects.toThrow(
'O "username" informado não foi encontrado no sistema.',
);

expect(user1.features).toStrictEqual([]);
expect(user2.features).toStrictEqual([]);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api/v1/users/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('GET /api/v1/users', () => {

describe('Default user', () => {
test('User without "read:user:list" feature', async () => {
let defaultUserSession = await orchestrator.createSession(defaultUser);
const defaultUserSession = await orchestrator.createSession(defaultUser);

const response = await fetch(`${orchestrator.webserverUrl}/api/v1/users`, {
method: 'GET',
Expand Down

0 comments on commit b7f063f

Please sign in to comment.