Merge pull request #1222 from acelaya-forks/feature/update-coding-standard

Update coding standard to v3.0.0
This commit is contained in:
Alejandro Celaya 2024-06-20 19:41:35 +02:00 committed by GitHub
commit a6ec7be0d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 834 additions and 99 deletions

View file

@ -1,10 +0,0 @@
{
"root": true,
"extends": [
"@shlinkio/js-coding-standard"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"ignorePatterns": ["src/service*.ts"]
}

View file

@ -15,7 +15,7 @@ updates:
eslint-plugins: # TODO Add eslint back once updated to v9 eslint-plugins: # TODO Add eslint back once updated to v9
patterns: patterns:
- '@shlinkio/eslint-config-js-coding-standard' - '@shlinkio/eslint-config-js-coding-standard'
- '@typescript-eslint/*' - 'typescript-eslint'
- '*eslint-plugin*' - '*eslint-plugin*'
shlink: shlink:
patterns: patterns:

View file

@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed ### Changed
* Update to `@shlinkio/shlink-web-component` 0.7 and use `ShlinkWebSettings` to replace local settings UI. * Update to `@shlinkio/shlink-web-component` 0.7 and use `ShlinkWebSettings` to replace local settings UI.
* Update to `@shlinkio/eslint-config-js-coding-standard` 3.0, and migrate to ESLint flat config.
### Deprecated ### Deprecated
* *Nothing* * *Nothing*

4
eslint.config.js Normal file
View file

@ -0,0 +1,4 @@
import shlink from '@shlinkio/eslint-config-js-coding-standard';
/* eslint-disable-next-line no-restricted-exports */
export default shlink;

895
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@
"scripts": { "scripts": {
"lint": "npm run lint:css && npm run lint:js", "lint": "npm run lint:css && npm run lint:js",
"lint:css": "stylelint src/*.scss src/**/*.scss", "lint:css": "stylelint src/*.scss src/**/*.scss",
"lint:js": "eslint --ext .js,.ts,.tsx src test", "lint:js": "eslint src test config/test",
"lint:fix": "npm run lint:css:fix && npm run lint:js:fix", "lint:fix": "npm run lint:css:fix && npm run lint:js:fix",
"lint:css:fix": "npm run lint:css -- --fix", "lint:css:fix": "npm run lint:css -- --fix",
"lint:js:fix": "npm run lint:js -- --fix", "lint:js:fix": "npm run lint:js -- --fix",
@ -57,7 +57,7 @@
"workbox-strategies": "^7.1.0" "workbox-strategies": "^7.1.0"
}, },
"devDependencies": { "devDependencies": {
"@shlinkio/eslint-config-js-coding-standard": "~2.5.1", "@shlinkio/eslint-config-js-coding-standard": "~3.0.0",
"@shlinkio/stylelint-config-css-coding-standard": "~1.1.1", "@shlinkio/stylelint-config-css-coding-standard": "~1.1.1",
"@stylistic/eslint-plugin": "^2.2.0", "@stylistic/eslint-plugin": "^2.2.0",
"@testing-library/jest-dom": "^6.4.6", "@testing-library/jest-dom": "^6.4.6",
@ -67,8 +67,6 @@
"@types/react": "^18.3.3", "@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^18.3.0",
"@types/uuid": "^9.0.8", "@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"@vitejs/plugin-react": "^4.3.1", "@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-v8": "^1.6.0", "@vitest/coverage-v8": "^1.6.0",
"adm-zip": "^0.5.14", "adm-zip": "^0.5.14",
@ -84,6 +82,7 @@
"sass": "^1.77.5", "sass": "^1.77.5",
"stylelint": "^15.11.0", "stylelint": "^15.11.0",
"typescript": "^5.4.5", "typescript": "^5.4.5",
"typescript-eslint": "^7.13.1",
"vite": "^5.3.1", "vite": "^5.3.1",
"vite-plugin-pwa": "^0.20.0", "vite-plugin-pwa": "^0.20.0",
"vitest": "^1.2.2" "vitest": "^1.2.2"

View file

@ -9,7 +9,7 @@
import { clientsClaim } from 'workbox-core'; import { clientsClaim } from 'workbox-core';
import { ExpirationPlugin } from 'workbox-expiration'; import { ExpirationPlugin } from 'workbox-expiration';
import { precacheAndRoute, createHandlerBoundToURL } from 'workbox-precaching'; import { createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching';
import { registerRoute } from 'workbox-routing'; import { registerRoute } from 'workbox-routing';
import { StaleWhileRevalidate } from 'workbox-strategies'; import { StaleWhileRevalidate } from 'workbox-strategies';
import pack from '../package.json'; import pack from '../package.json';
@ -50,7 +50,7 @@ registerRoute(
// Return true to signal that we want to use the handler. // Return true to signal that we want to use the handler.
return true; return true;
}, },
createHandlerBoundToURL(`${pack.homepage}/index.html`) createHandlerBoundToURL(`${pack.homepage}/index.html`),
); );
// An example runtime caching route for requests that aren't handled by the // An example runtime caching route for requests that aren't handled by the
@ -66,7 +66,7 @@ registerRoute(
// least-recently used images are removed. // least-recently used images are removed.
new ExpirationPlugin({ maxEntries: 50 }), new ExpirationPlugin({ maxEntries: 50 }),
], ],
}) }),
); );
// This allows the web app to trigger skipWaiting via // This allows the web app to trigger skipWaiting via

View file

@ -9,14 +9,14 @@
// To learn more about the benefits of this model and instructions on how to // To learn more about the benefits of this model and instructions on how to
// opt-in, read https://cra.link/PWA // opt-in, read https://cra.link/PWA
import pack from'../package.json'; import pack from '../package.json';
const isLocalhost = Boolean( const isLocalhost = Boolean(
window.location.hostname === 'localhost' || window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address. // [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' || window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4. // 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
); );
type Config = { type Config = {
@ -47,7 +47,7 @@ export function register(config?: Config) {
navigator.serviceWorker.ready.then(() => { navigator.serviceWorker.ready.then(() => {
console.log( console.log(
'This web app is being served cache-first by a service ' + 'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://cra.link/PWA' 'worker. To learn more, visit https://cra.link/PWA',
); );
}); });
} else { } else {
@ -75,7 +75,7 @@ function registerValidSW(swUrl: string, config?: Config) {
// content until all client tabs are closed. // content until all client tabs are closed.
console.log( console.log(
'New content is available and will be used when all ' + 'New content is available and will be used when all ' +
'tabs for this page are closed. See https://cra.link/PWA.' 'tabs for this page are closed. See https://cra.link/PWA.',
); );
// Execute callback // Execute callback