Skip to content

Commit 8bc8921

Browse files
committed
Add ESLint configuration and integrate linting scripts
- Added ESLint as a dependency and created configuration files (.eslintrc.json and .eslintignore). - Introduced linting scripts in package.json for code quality checks. - Updated JavaScript files to adhere to ESLint rules, including consistent use of double quotes and improved error handling. - Removed unused function computeSavedGroup from options.js. - Ensured proper export of functions in core.js and feedly.api.js. - Refactored message handling in background.js for better readability and consistency.
1 parent 0bfccfc commit 8bc8921

File tree

12 files changed

+1206
-92
lines changed

12 files changed

+1206
-92
lines changed

.eslintignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules/
2+
build/
3+
test-results/
4+
logos/
5+
translations/
6+
src/styles/
7+
src/images/
8+
src/_locales/
9+
src/sound/
10+

.eslintrc.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"browser": true,
5+
"es2021": true
6+
},
7+
"parserOptions": {
8+
"ecmaVersion": 2021,
9+
"sourceType": "script"
10+
},
11+
"extends": ["eslint:recommended"],
12+
"globals": {
13+
"browser": "readonly",
14+
"chrome": "readonly",
15+
"$": "readonly",
16+
"jQuery": "readonly",
17+
"Mustache": "readonly",
18+
"DOMPurify": "readonly",
19+
"timeago": "readonly",
20+
"importScripts": "readonly"
21+
},
22+
"overrides": [
23+
{
24+
"files": ["src/scripts/background.js"],
25+
"globals": {
26+
"appGlobal": "readonly",
27+
"getFeeds": "readonly",
28+
"getSavedFeeds": "readonly",
29+
"markAsRead": "readonly",
30+
"toggleSavedFeed": "readonly",
31+
"openFeedlyTab": "readonly",
32+
"resetCounter": "readonly",
33+
"getAccessToken": "readonly"
34+
}
35+
},
36+
{
37+
"files": ["Gruntfile.js"],
38+
"env": { "node": true }
39+
},
40+
{
41+
"files": ["src/scripts/core.js", "src/scripts/options.js"],
42+
"globals": { "FeedlyApiClient": "readonly" }
43+
}
44+
],
45+
"rules": {
46+
"indent": ["error", 4, { "SwitchCase": 1 }],
47+
"quotes": ["error", "double", { "avoidEscape": true }],
48+
"semi": ["error", "always"],
49+
"curly": ["error", "all"],
50+
"no-console": "off",
51+
"no-unused-vars": ["warn", { "args": "none" }],
52+
"no-var": "off",
53+
"no-empty": ["error", { "allowEmptyCatch": true }]
54+
}
55+
}

.github/workflows/automerge.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ jobs:
1212
- uses: actions/checkout@v5
1313
- uses: actions/setup-node@v4
1414
with:
15-
node-version: "16.x"
15+
node-version: "20.x"
1616
cache: "npm"
1717

1818
- run: npm install
19+
- run: npm run lint
1920
- run: npx grunt build --clientId=${{ secrets.FEEDLY_CLIENT_ID }} --clientSecret=${{ secrets.FEEDLY_CLIENT_SECRET }} --browser=${{ matrix.browser }}
2021

2122
automerge:

AGENTS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ Load locally: Browser → Extensions → Developer Mode → “Load unpacked”
2626
- Indentation: 4 spaces; UTF‑8; trim trailing whitespace (enforced by `.editorconfig`).
2727
- JavaScript: use strict mode; prefer `const/let`, camelCase for variables/functions, PascalCase for constructors; keep filenames lowercase with dashes or dots (e.g., `feedly.api.js`).
2828
- HTML/CSS: keep inline scripts minimal; reuse existing classes; keep assets under `images/`, `styles/`, `sound/`.
29-
- No linter is configured; match surrounding style and keep changes focused.
29+
- ESLint is configured; keep changes focused and fix lint issues as you go.
30+
31+
## Linting
32+
- Command: `npm run lint` (auto-fix: `npm run lint:fix`).
33+
- Scope: ESLint across `.js` files; ignores `build/`, `node_modules/`, assets, and locales.
34+
- Agent rule: after every code change, run `npm run lint` and fix issues before builds or PRs.
3035

3136
## Testing Guidelines
3237
- No unit test suite in-repo. Perform manual smoke tests across supported browsers (Chrome, Firefox, Edge/Opera):

Gruntfile.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
module.exports = function (grunt) {
22
grunt.initConfig({
3-
pkg: grunt.file.readJSON('package.json'),
3+
pkg: grunt.file.readJSON("package.json"),
44
copy: {
55
main: {
66
files: [
7-
{expand: true, cwd: '<%= pkg.sourcePath %>/', src: ['**'], dest: '<%= pkg.buildPath %>/'}
7+
{expand: true, cwd: "<%= pkg.sourcePath %>/", src: ["**"], dest: "<%= pkg.buildPath %>/"}
88
]
99
},
1010
bower: {
1111
files: [
12-
{src: '<%= pkg.libPath %>/jquery/dist/jquery.min.js', dest: '<%= pkg.buildPath %>/scripts/jquery.min.js'},
12+
{src: "<%= pkg.libPath %>/jquery/dist/jquery.min.js", dest: "<%= pkg.buildPath %>/scripts/jquery.min.js"},
1313

14-
{src: '<%= pkg.libPath %>/webextension-polyfill/dist/browser-polyfill.min.js', dest: '<%= pkg.buildPath %>/scripts/browser-polyfill.min.js'},
14+
{src: "<%= pkg.libPath %>/webextension-polyfill/dist/browser-polyfill.min.js", dest: "<%= pkg.buildPath %>/scripts/browser-polyfill.min.js"},
1515

16-
{src: '<%= pkg.libPath %>/mustache/mustache.min.js', dest: '<%= pkg.buildPath %>/scripts/mustache.min.js'},
16+
{src: "<%= pkg.libPath %>/mustache/mustache.min.js", dest: "<%= pkg.buildPath %>/scripts/mustache.min.js"},
1717

18-
{src: '<%= pkg.libPath %>/dompurify/dist/purify.min.js', dest: '<%= pkg.buildPath %>/scripts/purify.min.js'},
18+
{src: "<%= pkg.libPath %>/dompurify/dist/purify.min.js", dest: "<%= pkg.buildPath %>/scripts/purify.min.js"},
1919

20-
{src: '<%= pkg.libPath %>/timeago.js/dist/timeago.full.min.js', dest: '<%= pkg.buildPath %>/scripts/timeago.full.min.js'},
20+
{src: "<%= pkg.libPath %>/timeago.js/dist/timeago.full.min.js", dest: "<%= pkg.buildPath %>/scripts/timeago.full.min.js"},
2121
]
2222
}
2323
},
@@ -84,8 +84,8 @@ module.exports = function (grunt) {
8484
build: {
8585
cwd: "<%= pkg.buildPath %>/",
8686
src: ["<%= pkg.buildPath %>/**"],
87-
dest: '<%= pkg.buildPath %>/feedly-notifier-' + grunt.option('browser') + '.zip',
88-
compression: 'DEFLATE'
87+
dest: "<%= pkg.buildPath %>/feedly-notifier-" + grunt.option("browser") + ".zip",
88+
compression: "DEFLATE"
8989
}
9090
},
9191
clean: {
@@ -125,10 +125,10 @@ module.exports = function (grunt) {
125125
});
126126

127127
grunt.loadNpmTasks("grunt-contrib-copy");
128-
grunt.loadNpmTasks('grunt-string-replace');
129-
grunt.loadNpmTasks('grunt-zip');
130-
grunt.loadNpmTasks('grunt-contrib-clean');
131-
grunt.loadNpmTasks('grunt-preprocess');
128+
grunt.loadNpmTasks("grunt-string-replace");
129+
grunt.loadNpmTasks("grunt-zip");
130+
grunt.loadNpmTasks("grunt-contrib-clean");
131+
grunt.loadNpmTasks("grunt-preprocess");
132132

133133
grunt.registerTask("build", ["clean:pre-build", "copy", "string-replace:keys", "preprocess", "zip", "clean:build"]);
134134
grunt.registerTask("sandbox", ["copy", "string-replace", "preprocess"]);

0 commit comments

Comments
 (0)