Skip to content

Commit

Permalink
Merge pull request #383 from P4-Games/feature/linter
Browse files Browse the repository at this point in the history
merge feature/linter into develop
  • Loading branch information
dappsar authored Jul 20, 2024
2 parents 031b0df + f72f8b3 commit 1769efb
Show file tree
Hide file tree
Showing 77 changed files with 1,503 additions and 1,356 deletions.
171 changes: 151 additions & 20 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,36 +1,167 @@
{
"root": true,
"env": {
"browser": true,
"es2021": true
},
"plugins": [
"perfectionist",
"unused-imports",
"prettier",
"react",
"@next/eslint-plugin-next"
],
"extends": [
// "eslint:recommended",
// "plugin:react/recommended",
// "plugin:@next/next/recommended",
// "prettier"
"airbnb",
"airbnb/hooks",
"prettier",
"plugin:react/recommended",
"plugin:@next/next/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"ecmaVersion": 12,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
// "@next/eslint-plugin-next"
],
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx", ".css"]
}
}
},
"rules": {
"arrow-body-style": 1,
"react/prop-types": 1,
"react/display-name": 0,
"import/no-unresolved": 2,
"no-alert": 0,
"camelcase": 0,
"no-console": 0,
"no-unused-vars": [
"off",
{
"ignoreRestSiblings": true
}
],
"no-param-reassign": 0,
"no-underscore-dangle": 0,
"no-restricted-exports": 0,
"react/no-children-prop": 0,
"react/self-closing-comp": 2,
"consistent-return": 0,
"react/react-in-jsx-scope": 0,
"@next/next/no-img-element": 0,
"react/no-unescaped-entities": 0,
"import/no-useless-path-segments": 1,
"no-unused-vars": 0
"jsx-a11y/anchor-is-valid": 0,
"react/no-array-index-key": 0,
"no-promise-executor-return": 0,
"react/require-default-props": 0,
"react/jsx-props-no-spreading": 0,
"react/display-name": 0,
"import/prefer-default-export": 0,
"react/function-component-definition": 0,
"jsx-a11y/control-has-associated-label": 0,
"react/forbid-prop-types": 0,
"no-plusplus": 0,
"no-use-before-define": 0,
"react/jsx-no-useless-fragment": [
1,
{
"allowExpressions": true
}
],
"prefer-destructuring": [
1,
{
"object": true,
"array": false
}
],
"react/no-unstable-nested-components": [
1,
{
"allowAsProps": true
}
],
"react/jsx-no-duplicate-props": [
1,
{
"ignoreCase": false
}
],
// unused-imports
// https://www.npmjs.com/package/eslint-plugin-unused-imports
"unused-imports/no-unused-imports": 1,
"unused-imports/no-unused-vars": [
0,
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
],
// perfectionist
// https://eslint-plugin-perfectionist.azat.io/
"perfectionist/sort-named-imports": [
1,
{
"order": "asc",
"type": "line-length"
}
],
"perfectionist/sort-named-exports": [
1,
{
"order": "asc",
"type": "line-length"
}
],
"perfectionist/sort-exports": [
1,
{
"order": "asc",
"type": "line-length"
}
],
"perfectionist/sort-imports": [
1,
{
"order": "asc",
"type": "line-length",
"newlines-between": "always",
"groups": [
[
"builtin",
"external"
],
"custom-context",
"custom-services",
"custom-hooks",
"custom-utils",
"internal",
"custom-components",
"custom-sections",
"custom-styles",
[
"parent",
"sibling",
"index"
],
"object",
"unknown"
],
"custom-groups": {
"value": {
"custom-context": "src/context/**",
"custom-services": "src/services/**",
"custom-hooks": "src/hooks/**",
"custom-utils": "src/utils/**",
"custom-components": "src/components/**",
"custom-sections": "src/sections/**",
"custom-styles": "src/styles/**"
}
},
"internal-pattern": [
"src/**"
]
}
]
}
}
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { EventEmitter } = require('events');
// Configuración del EventEmitter
const originalAddListener = EventEmitter.prototype.addListener;
EventEmitter.prototype.addListener = function(event) {
console.log(`Adding listener for event: ${event}`);
console.info(`Adding listener for event: ${event}`);
return originalAddListener.apply(this, arguments);
};
EventEmitter.defaultMaxListeners = 50;
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"sharp": "0.32.6",
"styled-components": "^5.3.6",
"sweetalert2": "^11.6.15",
"swiper": "^8.4.5",
"swiper": "8.4.5",
"swr": "^2.0.3",
"url-loader": "^4.1.1",
"use-local-storage": "^2.3.6",
Expand Down
11 changes: 4 additions & 7 deletions public/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ try {
}

try {
console.log("SW installing")
console.info("SW installing")
event.waitUntil(
Promise.all([
fetchFilesFromFolder(IMAGES_FOLDER, ['png', 'jpg', 'jpeg', 'gif']),
Expand All @@ -55,7 +55,7 @@ try {
allFiles.push('/index')
allFiles.push('/alpha')
allFiles.push('/gamma')
console.log('sw', allFiles, caches)
console.info('sw', allFiles, caches)
return caches.open(PRECACHE).then((cache) => cache.addAll(allFiles));
})
.then(self.skipWaiting())
Expand All @@ -72,11 +72,9 @@ try {
// The activate handler takes care of cleaning up old caches.
self.addEventListener("activate", (event) => {
const currentCaches = [PRECACHE, RUNTIME]
// console.log("SW activate cache")
event.waitUntil(
caches.keys().then((cacheNames) => cacheNames.filter((cacheName) => !currentCaches.includes(cacheName))).then((cachesToDelete) =>
// console.log("SW cache is deleting")
Promise.all(cachesToDelete.map((cacheToDelete) => caches.delete(cacheToDelete)))
Promise.all(cachesToDelete.map((cacheToDelete) => caches.delete(cacheToDelete)))
).then(() => self.clients.claim())
)
})
Expand All @@ -85,7 +83,6 @@ try {
// The fetch handler serves responses for same-origin resources from a cache.
// If no response is found, it populates the runtime cache with the response
// from the network before returning it to the page.
//console.log('next', self.location.origin & NEXT)
self.addEventListener("fetch", (event) => {
const isGet = event.request.method === 'GET'
const isHttp = event.request.url.startsWith('http')
Expand All @@ -103,7 +100,7 @@ try {

if (!isValidToCache) {
if (!event.request.url.startsWith(self.location.origin + NEXT_FOLDER))
console.log('**SW Skiping: ', event.request.url)
console.info('**SW Skiping: ', event.request.url)
return
}

Expand Down
5 changes: 2 additions & 3 deletions scripts/resizeImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ async function resizeAndSaveImages() {
await image.writeAsync(`${basePath}/T2/${filename}`)
}

console.log('Images resized and saved successfully.')
console.info('Images resized and saved successfully.')
} catch (error) {
console.log(error)
console.log('An error occurred while processing the images.')
console.error('An error occurred while processing the images.', error)
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/components/CustomImage/CustomImage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useState } from 'react'
/* eslint-disable jsx-a11y/img-redundant-alt */
/* eslint-disable @next/next/no-img-element */
import PropTypes from 'prop-types'
import React, { useState } from 'react'

function CustomImage({ src, alt, className }) {
const [error, setError] = useState(false)
Expand Down
18 changes: 12 additions & 6 deletions src/components/FlipBook/FlipBook.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React, { useEffect, useState } from 'react'
/* eslint-disable react/no-unknown-property */
/* eslint-disable no-nested-ternary */
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable react/no-unstable-nested-components */
import PropTypes from 'prop-types'
import React, { useState, useEffect } from 'react'

import HTMLFlipBook from './HtmlFlipBook'
import { useLayoutContext } from '../../hooks'

Expand Down Expand Up @@ -48,8 +54,8 @@ const FlipBook = (props) => {
minHeight={350}
maxHeight={600}
swipeDistance={30}
showPageCorners={true}
autoSize={true}
showPageCorners
autoSize
startPage={startPage}
ref={bookRef}
usePortrait={windowSize.size}
Expand All @@ -74,12 +80,12 @@ const FlipBook = (props) => {
>
<div className='hero__top__album__book__page__page-content'>
{index % 2 === 0 ? (
<React.Fragment>{content}</React.Fragment>
<>{content}</>
) : (
<React.Fragment>
<>
{showClose && <CloseButton />}
{content}
</React.Fragment>
</>
)}
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/components/FlipBook/HtmlFlipBook.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react'
import PropTypes from 'prop-types'
// import { PageFlip } from 'page-flip'
import { PageFlip } from 'book-flip'
import React, { useRef, useState, useEffect, useCallback, useImperativeHandle } from 'react'

const HTMLFlipBookForward = React.forwardRef((props, ref) => {
const htmlElementRef = useRef(null)
Expand All @@ -17,7 +17,7 @@ const HTMLFlipBookForward = React.forwardRef((props, ref) => {
if (pageFlip.current) {
pageFlip.current.clear()
}
}, []) //eslint-disable-line react-hooks/exhaustive-deps
}, []) // eslint-disable-line react-hooks/exhaustive-deps

const removeHandlers = useCallback(() => {
const flip = pageFlip.current
Expand All @@ -29,7 +29,7 @@ const HTMLFlipBookForward = React.forwardRef((props, ref) => {
flip.off('init')
flip.off('update')
}
}, []) //eslint-disable-line react-hooks/exhaustive-deps
}, []) // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
childRef.current = []
Expand All @@ -54,7 +54,7 @@ const HTMLFlipBookForward = React.forwardRef((props, ref) => {
}
}
removeHandlers()
}, [props.children]) //eslint-disable-line react-hooks/exhaustive-deps
}, [props.children]) // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
const setHandlers = () => {
Expand Down Expand Up @@ -98,7 +98,7 @@ const HTMLFlipBookForward = React.forwardRef((props, ref) => {

setHandlers()
}
}, [pages]) //eslint-disable-line react-hooks/exhaustive-deps
}, [pages]) // eslint-disable-line react-hooks/exhaustive-deps

return (
<div ref={htmlElementRef} className={props.className} style={props.style}>
Expand Down
2 changes: 2 additions & 0 deletions src/components/FlipCard/FlipCard.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable jsx-a11y/no-static-element-interactions */
import { useState } from 'react'

const FlipCard = () => {
Expand Down
Loading

0 comments on commit 1769efb

Please sign in to comment.