Skip to content

Commit 718d806

Browse files
authored
Add eslint (#332)
add eslint, start to clean up, re-apply prettier formatting Co-authored-by: Peter Wolanin <107691+pwolanin@users.noreply.github.com>
1 parent f239930 commit 718d806

File tree

16 files changed

+2304
-1204
lines changed

16 files changed

+2304
-1204
lines changed

.eslintignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
dist/
3+
build/
4+
public/
5+
data-scripts/
6+
*.min.js
7+
coverage/
8+
.nyc_output/

.eslintrc.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
es2021: true,
6+
node: true,
7+
},
8+
extends: [
9+
'eslint:recommended',
10+
'airbnb-base',
11+
'plugin:cypress/recommended',
12+
'prettier',
13+
],
14+
parserOptions: {
15+
ecmaVersion: 'latest',
16+
sourceType: 'module',
17+
},
18+
plugins: [
19+
'vue',
20+
'import',
21+
'cypress',
22+
],
23+
rules: {
24+
// General JavaScript rules
25+
'import/no-unresolved': 'off',
26+
'import/extensions': 'off',
27+
'no-console': 'warn',
28+
'no-debugger': 'warn',
29+
'prefer-const': 'error',
30+
'no-var': 'error',
31+
"prefer-destructuring": "off",
32+
33+
// Cypress specific rules
34+
'cypress/no-unnecessary-waiting': 'warn',
35+
'cypress/assertion-before-screenshot': 'warn',
36+
},
37+
overrides: [
38+
{
39+
files: ['cypress/**/*.js'],
40+
env: {
41+
'cypress/globals': true,
42+
},
43+
rules: {
44+
'import/no-extraneous-dependencies': 'off',
45+
'no-unused-expressions': 'off',
46+
},
47+
},
48+
{
49+
files: ['src/**/*.vue'],
50+
extends: ['plugin:vue/vue3-essential'],
51+
rules: {
52+
'vue/multi-word-component-names': 'off',
53+
'vue/no-v-html': 'off',
54+
},
55+
},
56+
],
57+
ignorePatterns: [
58+
'node_modules/',
59+
'dist/',
60+
'build/',
61+
'public/',
62+
'data-scripts/',
63+
],
64+
};

cypress.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ module.exports = defineConfig({
2222
openMode: 0,
2323
},
2424
setupNodeEvents(on, config) {
25-
on("dev-server:start", (options) => {
26-
return startDevServer({
25+
on("dev-server:start", (options) =>
26+
startDevServer({
2727
options,
2828
viteConfig: {
2929
configFile: "vite.config.js", // Path to your Vite config file
3030
},
31-
});
32-
});
31+
}),
32+
);
3333

3434
return config;
3535
},

cypress/e2e/e2e_tests.cy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ describe('E2E Tests', () => {
55
let demURL;
66
let repURL;
77
// Set indices for Leaders used in tests
8-
let demIndex = 22;
9-
let repIndex = 46;
8+
const demIndex = 22;
9+
const repIndex = 46;
1010

1111
describe('Ward Leaders List', () => {
1212
beforeEach(() => {
@@ -120,9 +120,9 @@ describe('E2E Tests', () => {
120120
});
121121

122122
it('should display placeholders when information is missing', () => {
123-
let missingData = Object.keys(demLeader).filter(key => demLeader[key] === null || demLeader[key] === undefined);
123+
const missingData = Object.keys(demLeader).filter(key => demLeader[key] === null || demLeader[key] === undefined);
124124
// Look for missing data in fields besides subward and photo
125-
let filteredMissingData = missingData.filter(item => !['subWard','photo'].includes(item))
125+
const filteredMissingData = missingData.filter(item => !['subWard','photo'].includes(item))
126126
if (filteredMissingData.length > 0) {
127127
cy.get('.unknown').should('have.length.at.least', 1);
128128
}

cypress/support/e2e.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { mount } from 'cypress/vue';
22
import Api from '../../src/api';
33
import { CONTENTFUL_SPACE_ID, CONTENTFUL_ACCESS_TOKEN } from '../../src/config'
4+
45
const api = new Api(CONTENTFUL_SPACE_ID, CONTENTFUL_ACCESS_TOKEN)
56

67
Cypress.Commands.add('mount', mount);
7-
Cypress.Commands.add('fetchLeaders', () => {
8-
return cy.wrap(api.fetchLeaders());
9-
});
8+
Cypress.Commands.add('fetchLeaders', () => cy.wrap(api.fetchLeaders()));

0 commit comments

Comments
 (0)