Skip to content

Commit eedebff

Browse files
committed
Update ESLint to v9
1 parent 2955633 commit eedebff

16 files changed

Lines changed: 796 additions & 480 deletions

.eslintignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 87 deletions
This file was deleted.

demos/network-idle.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ navigator.serviceWorker.getRegistration()
2121
* networkIdleCallback works similar to requestIdleCallback,
2222
* detecting and notifying you when network activity goes idle
2323
* in your current tab.
24-
* @param {*} fn - A valid function
25-
* @param {*} options - An options object
24+
* @param {(state: {didTimeout: boolean}) => void} fn - Callback invoked when the network is idle
25+
* @param {{timeout?: number}} options - Configuration options
2626
*/
2727
function networkIdleCallback(fn, options = {timeout: 0}) {
2828
// Call the function immediately if required features are absent
@@ -90,7 +90,7 @@ if ('serviceWorker' in navigator) {
9090

9191
/**
9292
* Handle message passing
93-
* @param {*} event - A valid event
93+
* @param {MessageEvent} event - Message event from the service worker
9494
*/
9595
function handleMessage(event) {
9696
if (!event.data) {

demos/sw.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-env serviceworker */
2-
31
'use strict';
42

53
importScripts('https://unpkg.com/network-idle-callback@1.0.1/lib/request-monitor.js');

eslint.config.js

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat');
2+
const globals = require('globals');
3+
const googleConfig = require('eslint-config-google');
4+
const jsdocPlugin = require('eslint-plugin-jsdoc');
5+
const reactPlugin = require('eslint-plugin-react');
6+
7+
const jsdocRecommended = jsdocPlugin.configs['flat/recommended'] || jsdocPlugin.configs.recommended;
8+
9+
const [reactRecommended] = fixupConfigRules(reactPlugin.configs.recommended);
10+
const googleRules = {
11+
...googleConfig.rules,
12+
};
13+
delete googleRules['valid-jsdoc'];
14+
delete googleRules['require-jsdoc'];
15+
16+
module.exports = [
17+
{
18+
ignores: [
19+
'**/*.min.js',
20+
'**/dist/',
21+
'**/build/',
22+
'**/vendor/',
23+
'eslint.config.js',
24+
],
25+
},
26+
{
27+
name: 'quicklink/base',
28+
languageOptions: {
29+
ecmaVersion: 2017,
30+
sourceType: 'script',
31+
parserOptions: {
32+
ecmaFeatures: {
33+
jsx: true,
34+
},
35+
},
36+
globals: {
37+
...globals.browser,
38+
...globals.node,
39+
},
40+
},
41+
plugins: {
42+
react: fixupPluginRules(reactPlugin),
43+
},
44+
settings: {
45+
react: {
46+
version: 'detect',
47+
},
48+
},
49+
rules: {
50+
...(reactRecommended?.rules ?? reactPlugin.configs.recommended.rules),
51+
...googleRules,
52+
'max-len': [
53+
'warn',
54+
{
55+
code: 130,
56+
},
57+
],
58+
'arrow-parens': [
59+
'error',
60+
'as-needed',
61+
],
62+
'space-before-function-paren': [
63+
'error',
64+
{
65+
anonymous: 'always',
66+
named: 'never',
67+
},
68+
],
69+
'no-negated-condition': 'warn',
70+
'no-const-assign': 'error',
71+
'prefer-destructuring': [
72+
'off',
73+
{
74+
object: true,
75+
array: false,
76+
},
77+
],
78+
'prefer-template': 'error',
79+
strict: [
80+
'error',
81+
'global',
82+
],
83+
'spaced-comment': [
84+
'error',
85+
'always',
86+
{
87+
exceptions: [
88+
'/',
89+
],
90+
},
91+
],
92+
},
93+
},
94+
{
95+
files: [
96+
'src/**',
97+
],
98+
languageOptions: {
99+
sourceType: 'module',
100+
},
101+
rules: {
102+
strict: [
103+
'error',
104+
'never',
105+
],
106+
},
107+
},
108+
...(Array.isArray(jsdocRecommended) ? jsdocRecommended : [jsdocRecommended]),
109+
{
110+
files: [
111+
'site/src/assets/js/**',
112+
],
113+
languageOptions: {
114+
sourceType: 'script',
115+
globals: {
116+
...globals.browser,
117+
},
118+
},
119+
rules: {
120+
'jsdoc/require-jsdoc': 'off',
121+
strict: [
122+
'error',
123+
'function',
124+
],
125+
},
126+
},
127+
];

0 commit comments

Comments
 (0)