Skip to content

Commit

Permalink
Run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
scottrosen14 committed Nov 21, 2024
1 parent f8297be commit 46b5771
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 81 deletions.
36 changes: 34 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
/build/**
/src/__tests__/__setup__/data.json
# Build outputs
build/
dist/
out/
.next/
coverage/

# Dependencies
node_modules/
**/node_modules/

# Config files
*.config.js

# Public assets
public/

# Cache
.cache/
.eslintcache

# Environment files
.env*
!.env.example

# Test files (optional, depending on your needs)
/src/__tests__/__setup__/data.json
# **/*.test.js
# **/*.spec.js
# **/*.cy.js

# Generated files
*.min.js
*.bundle.js
50 changes: 29 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Production
build/
dist/
out/
.next/
coverage/

# dependencies
/node_modules
/.pnp
node_modules/
.pnp
.pnp.js

# IDE settings
/.vscode
/.idea
.vscode/
.idea/

# testing
/coverage
coverage/
cypress/screenshots
cypress/videos
cypress/downloads
src/__tests__/__setup__/data.json

# production
/build

# misc
.DS_Store

# environment variables
.env*

# Cache and logs
.cache/
*.log
logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*

/.gcloudignore
/app.yaml
/main.py
/requirements.txt
.pnpm-debug.log*
.eslintcache
.stylelintcache
**/__pycache__
/src/__tests__/__setup__/data.json

venv/*
# environment variables
.env*

# Misc
.DS_Store
.gcloudignore
app.yaml
main.py
requirements.txt
5 changes: 1 addition & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@

# production
/build
/dist

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
Expand Down
15 changes: 14 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
{}
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"arrowParens": "avoid",
"endOfLine": "auto",
"bracketSameLine": false
}
24 changes: 12 additions & 12 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const { defineConfig } = require('cypress');
require('dotenv').config({
path: `.env.${process.env.STAGE_ENV || 'development'}`
const { defineConfig } = require("cypress");
require("dotenv").config({
path: `.env.${process.env.STAGE_ENV || "development"}`,
});

module.exports = defineConfig({
e2e: {
baseUrl: process.env.REACT_APP_POLICYENGINE_DOMAIN,
supportFile: 'cypress/support/e2e.js',
specPattern: 'cypress/tests/**/*.cy.js',
supportFile: "cypress/support/e2e.js",
specPattern: "cypress/tests/**/*.cy.js",
},
setupNodeEvents(on, config) {
on('task', {
on("task", {
log(message) {
console.log(message)
return null
}
})
}
});
console.log(message);
return null;
},
});
},
});
2 changes: 1 addition & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
// }
4 changes: 2 additions & 2 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')
// require('./commands')
46 changes: 23 additions & 23 deletions cypress/tests/us/home.cy.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import { checkCountryRedirect } from "../../utils/checkCountryRedirect"
import { checkCountryRedirect } from "../../utils/checkCountryRedirect";

describe('PolicyEngine Homepage', () => {
describe("PolicyEngine Homepage", () => {
const regexArg = /the\s(us|u\.s\.|usa|united states)/;

beforeEach(() => {
cy.visit('/')
})
cy.visit("/");
});

afterEach(() => {
Object.defineProperty(window.navigator, 'language', {
Object.defineProperty(window.navigator, "language", {
value: window.navigator.language,
configurable: true
})
})
configurable: true,
});
});

it('should redirect from root to US homepage by default', () => {
Object.defineProperty(window.navigator, 'language', {
value: '',
configurable: true
})
checkCountryRedirect('us', regexArg)
})
it("should redirect from root to US homepage by default", () => {
Object.defineProperty(window.navigator, "language", {
value: "",
configurable: true,
});
checkCountryRedirect("us", regexArg);
});

it('should redirect from root to US homepage if browser language is en-US', () => {
Object.defineProperty(window.navigator, 'language', {
value: 'en-US',
configurable: true
})
checkCountryRedirect('us', regexArg)
})
})
it("should redirect from root to US homepage if browser language is en-US", () => {
Object.defineProperty(window.navigator, "language", {
value: "en-US",
configurable: true,
});
checkCountryRedirect("us", regexArg);
});
});
24 changes: 12 additions & 12 deletions cypress/utils/checkCountryRedirect.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const checkCountryRedirect = (country, regexArg = '') => {
cy.location('pathname').should((loc) => {
const path = loc.split('/')
expect(path[1]).to.equal(country)
})
cy.get('#home-used-by').then(($ele) => {
const text = $ele.text()?.toLowerCase();
const regex = new RegExp(regexArg, 'i')
expect(regex.test(text)).to.equal(true)
})
}
export const checkCountryRedirect = (country, regexArg = "") => {
cy.location("pathname").should((loc) => {
const path = loc.split("/");
expect(path[1]).to.equal(country);
});

cy.get("#home-used-by").then(($ele) => {
const text = $ele.text()?.toLowerCase();
const regex = new RegExp(regexArg, "i");
expect(regex.test(text)).to.equal(true);
});
};
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"homepage": "https://policyengine.org",
"engines": {
"node": ">=22.0.0"
"node": ">=19.0.0"
},
"dependencies": {
"@ant-design/icons": "^5.5.1",
Expand Down Expand Up @@ -66,7 +66,8 @@
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject",
"fix": "eslint --fix --ext js,jsx . && prettier -w .",
"fix": "eslint --fix --ext js,jsx,ts,tsx . && prettier -w .",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss}\"",
"lint": "eslint --ext js,jsx --max-warnings 0 . && prettier -c .",
"prepare-husky": "husky",
"cy:dev": "npm start & wait-on http://localhost:3000 && STAGE_ENV=development cypress run",
Expand All @@ -87,7 +88,7 @@
]
},
"lint-staged": {
"*.{js,jsx}": "eslint --fix",
"*.{js,jsx,ts,tsx}": "eslint --fix",
"*": "prettier -w"
},
"devDependencies": {
Expand Down

0 comments on commit 46b5771

Please sign in to comment.