Skip to content

Commit 06966c6

Browse files
chore: add ESLint config file and deps
1 parent 72921d8 commit 06966c6

File tree

8 files changed

+874
-1108
lines changed

8 files changed

+874
-1108
lines changed

.eslintrc

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"browser": true
5+
},
6+
"extends": "plugin:@wordpress/eslint-plugin/recommended",
7+
"parserOptions": {
8+
"ecmaFeatures": {
9+
"jsx": true
10+
},
11+
"ecmaVersion": "latest"
12+
},
13+
"ignorePatterns": ["**/vendor/**", "**/build/**", "**/*.min.js", "**/node_modules/**"],
14+
"rules": {
15+
"@wordpress/i18n-text-domain": ["error", {
16+
"allowedTextDomain": ["feedzy-rss-feeds"]
17+
}],
18+
"@wordpress/i18n-no-flanking-whitespace": "error",
19+
"@wordpress/data-no-store-string-literals": "error",
20+
"@wordpress/wp-global-usage": "error",
21+
"prettier/prettier": "warn",
22+
"import/no-extraneous-dependencies": "warn",
23+
"prefer-const": "warn",
24+
"dot-notation": "warn",
25+
"react/jsx-key": "warn",
26+
"jsx-a11y/no-static-element-interactions": "warn",
27+
"no-undef": "warn",
28+
"object-shorthand": "warn",
29+
"no-else-return": "warn",
30+
"jsx-a11y/click-events-have-key-events": "warn",
31+
"jsx-a11y/anchor-is-valid": "warn",
32+
"camelcase": "warn",
33+
"jsdoc/check-line-alignment": "warn",
34+
"jsdoc/check-alignment": "warn",
35+
"jsx-a11y/label-has-associated-control": "warn",
36+
"react/no-unknown-property": "warn",
37+
"@wordpress/no-unused-vars-before-return": "warn",
38+
"jsdoc/empty-tags": "warn",
39+
"no-lonely-if": "warn",
40+
"no-var": "warn",
41+
"no-unused-vars": "warn",
42+
"no-console": "warn",
43+
"jsx-a11y/alt-text": "warn",
44+
"react/no-deprecated": "warn",
45+
"jsx-a11y/no-noninteractive-element-interactions": "warn",
46+
"jsx-a11y/no-autofocus": "warn",
47+
"no-nested-ternary": "warn",
48+
"jsdoc/require-param": "warn",
49+
"jsdoc/require-returns-description": "warn",
50+
"jsdoc/require-returns-type": "warn"
51+
}
52+
}

.github/workflows/test-lint-js.yml

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
name: NPM Tests
1+
name: Check JS files and build
22
concurrency:
33
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
44
cancel-in-progress: true
55
on:
66
push:
77
branches-ignore:
8-
- 'master'
9-
- 'dependabot/**'
8+
- "master"
9+
- "dependabot/**"
1010

1111
jobs:
1212
npm:
1313
runs-on: ubuntu-latest
14-
env:
15-
CYPRESS_INSTALL_BINARY: 0
16-
strategy:
17-
matrix:
18-
node-version: [18.x]
1914
steps:
2015
- name: Checkout source code
21-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
2217
- name: Setup node
23-
uses: actions/setup-node@v1
18+
uses: actions/setup-node@v4
2419
with:
25-
node-version: ${{ matrix.node-version }}
20+
node-version: "18"
21+
cache: "npm"
2622
- name: Install Dependencies
2723
run: npm install
2824
- name: Run JS check
29-
run: npm run lint:js || true # Remove `|| true` when working on https://github.com/Codeinwp/feedzy-rss-feeds/issues/948
30-
- name: Build source
25+
run: npm run lint:js
26+
- name: Check if we can build the project
3127
run: npm run build

js/ActionPopup/action-popup.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ const ActionModal = () => {
212212
}
213213
}
214214
let tag = event.target.getAttribute( 'data-action_popup' ) || '';
215-
let fieldName = event.target.getAttribute( 'data-field-name' ) || '';
215+
let dataFieldName = event.target.getAttribute( 'data-field-name' ) || '';
216216
if ( '' === tag ) {
217217
event.target.closest('.dropdown-item').click();
218218
return;
219219
}
220220
setShortCode( tag );
221-
setFieldName( fieldName );
221+
setFieldName( dataFieldName );
222222
openModal();
223223
} );
224224
} );

js/FeedBack/feedback-form.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const helpTextByStatus = {
4141
* Displays a button that opens a modal for sending feedback
4242
*
4343
* @param {import('./type').FeedbackFormProps} props
44-
* @returns
44+
* @return
4545
*/
4646
const FeedbackForm = ({
4747
source,

js/FeedBack/feedback.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const FeedBack = () => {
3434

3535
document.querySelectorAll( '[role="button"]' ).forEach((button) => {
3636
button.addEventListener('keydown', (evt) => {
37-
if(evt.keyCode == 13 || evt.keyCode == 32) {
37+
if(evt.keyCode === 13 || evt.keyCode === 32) {
3838
button.click();
3939
}
4040
});

js/FeedzyBlock/utils.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export const filterData = ( arr, sortType, allowedKeywords, bannedKeywords, maxS
6262
};
6363

6464
export const inArray = ( value, arr ) => {
65-
if ( arr === undefined ) return false;
65+
if ( arr === undefined ) {
66+
return false;
67+
};
6668
let exists = false;
6769
for( let i = 0; i < arr.length; i++ ) {
6870
let name = arr[i];

0 commit comments

Comments
 (0)