Skip to content

Commit d3f53b1

Browse files
committed
Fix ESLint configuration for lint-staged files
1 parent cc2103b commit d3f53b1

27 files changed

+12682
-5359
lines changed

.eslintignore

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

.lintstagedrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module.exports = {
2-
'*.{css,js,json,jsx,md}': 'prettier-eslint --write',
2+
'*.{js,jsx}': ['eslint --fix', 'prettier --write'],
3+
'*.{css,json,md}': ['prettier --write'],
34
};

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: 'es5',
4+
singleQuote: true,
5+
printWidth: 120,
6+
tabWidth: 2,
7+
};

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,19 @@ n.b. Only a handful of websites are configured out of the box, and you'll need t
3030

3131
### Getting Started
3232

33-
1. Install [node](https://nodejs.org/en/) > v10.19.0
34-
1. Install [npm](https://www.npmjs.com/) > v6.14.4
33+
1. Install [node](https://nodejs.org/en/) > v20.15.0
34+
1. Install [npm](https://www.npmjs.com/) > v10.0.0
3535
1. `npm install`
3636
1. `npm run web-ext`
3737

38+
### Available Commands
39+
40+
- `npm run build` - Build extension for development
41+
- `npm run build-production` - Build extension for production
42+
- `npm run test` - Run test suite
43+
- `npm run static-analysis` - Run ESLint code quality checks
44+
- `npm run format` - Format code with Prettier
45+
3846
### Developing for Android
3947

4048
Follow the [Extension Workshop guide](https://extensionworkshop.com/documentation/develop/developing-extensions-for-firefox-for-android/):

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ['@babel/preset-env', '@babel/preset-react'],
3+
};

eslint.config.mjs

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import js from '@eslint/js';
2+
3+
export default [
4+
js.configs.recommended,
5+
// Configuration files (webpack, babel, etc.)
6+
{
7+
files: ['*.config.js', '.eslintrc.js', '.lintstagedrc.js', '.prettierrc.js', 'babel.config.js', 'jest.config.js', 'web-ext-config.js', 'webpack.config.js'],
8+
ignores: ['node_modules/**'],
9+
languageOptions: {
10+
ecmaVersion: 2020,
11+
sourceType: 'commonjs',
12+
globals: {
13+
module: 'readonly',
14+
require: 'readonly',
15+
__dirname: 'readonly',
16+
__filename: 'readonly',
17+
process: 'readonly'
18+
}
19+
},
20+
rules: {
21+
'no-console': 'off'
22+
}
23+
},
24+
// Static extension files (background.js, content-script.js)
25+
{
26+
files: ['static/**/*.js'],
27+
ignores: ['node_modules/**'],
28+
languageOptions: {
29+
ecmaVersion: 2020,
30+
sourceType: 'script',
31+
globals: {
32+
chrome: 'readonly',
33+
window: 'readonly',
34+
document: 'readonly',
35+
console: 'readonly',
36+
setTimeout: 'readonly',
37+
setInterval: 'readonly',
38+
clearTimeout: 'readonly',
39+
clearInterval: 'readonly',
40+
MutationObserver: 'readonly'
41+
}
42+
},
43+
rules: {
44+
'no-console': 'off',
45+
'no-unused-expressions': ['error', { allowTaggedTemplates: true }]
46+
}
47+
},
48+
// React source files
49+
{
50+
files: ['src/**/*.js', 'src/**/*.jsx'],
51+
ignores: ['dist/**', 'node_modules/**', 'web-ext-artifacts/**'],
52+
languageOptions: {
53+
ecmaVersion: 2020,
54+
sourceType: 'module',
55+
parserOptions: {
56+
ecmaFeatures: {
57+
jsx: true
58+
}
59+
},
60+
globals: {
61+
chrome: 'readonly',
62+
window: 'readonly',
63+
document: 'readonly',
64+
console: 'readonly'
65+
}
66+
},
67+
rules: {
68+
'no-console': 'off',
69+
'no-continue': 'off',
70+
'no-param-reassign': 'off',
71+
'no-underscore-dangle': 'off',
72+
'no-unused-vars': ['error', {
73+
argsIgnorePattern: '^_',
74+
varsIgnorePattern: '^(React|.*Component|.*List|.*Field|.*Content|App|Root|Topics|Websites)$'
75+
}],
76+
'max-len': ['error', { code: 140 }], // Relaxed for JSX
77+
'no-undef': 'error'
78+
}
79+
},
80+
// Test files
81+
{
82+
files: ['src/**/*.test.js', 'src/**/*.test.jsx', 'src/test-setup.js'],
83+
languageOptions: {
84+
ecmaVersion: 2020,
85+
sourceType: 'module',
86+
parserOptions: {
87+
ecmaFeatures: {
88+
jsx: true
89+
}
90+
},
91+
globals: {
92+
jest: 'readonly',
93+
beforeEach: 'readonly',
94+
afterEach: 'readonly',
95+
describe: 'readonly',
96+
it: 'readonly',
97+
expect: 'readonly',
98+
global: 'writable',
99+
chrome: 'readonly'
100+
}
101+
},
102+
rules: {
103+
'no-console': 'off',
104+
'no-unused-vars': ['error', {
105+
argsIgnorePattern: '^_',
106+
varsIgnorePattern: '^React$|^App$' // Allow unused React and component imports
107+
}],
108+
'max-len': ['error', { code: 140 }]
109+
}
110+
}
111+
];

jest.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
testEnvironment: 'jsdom',
3+
setupFilesAfterEnv: ['<rootDir>/src/test-setup.js'],
4+
testMatch: ['<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}', '<rootDir>/src/**/*.{test,spec}.{js,jsx,ts,tsx}'],
5+
transform: {
6+
'^.+\\.(js|jsx)$': 'babel-jest',
7+
},
8+
moduleFileExtensions: ['js', 'jsx', 'json'],
9+
collectCoverageFrom: ['src/**/*.{js,jsx}', '!src/**/*.test.{js,jsx}', '!src/test-setup.js'],
10+
};

0 commit comments

Comments
 (0)