Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR] Lint and Prettier #238

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,21 @@ module.exports = {
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'

],
// required to lint *.vue files
plugins: [
'vue',
'strict-vue'
],
plugins: ['vue', 'strict-vue'],
// add your custom rules here
rules: {
// allow async-await
'no-multi-spaces': 'off',
'generator-star-spacing': 'off',
'camelcase': [0, { 'properties': 'never' }],
camelcase: [0, { properties: 'never' }],
'strict-vue/require-jsdoc': 'off',
'strict-vue/no-root-store-calls': 'error',
'strict-vue/no-root-store-assets': 'error',
'vue/no-use-v-if-with-v-for': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'space-in-parens': [1, 'always']
}
}
18 changes: 18 additions & 0 deletions .prettierc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
// Specify the line length to match ESLint's max-len rule.
printWidth: 120,

// Use single quotes for strings.
singleQuote: true,

// Use a trailing comma in arrays and objects.
trailingComma: 'none',

// Use parentheses around arrow function parameters only when necessary.
arrowParens: 'avoid',

// Indent with 2 spaces to match ESLint's indent rule.
tabWidth: 2,

semi: false
}
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
<img src='https://dashboard.sustainability.oregonstate.edu/images/readme_logo.png' height=80 />

# OSU Energy Dashboard
![Frontend Status](https://github.com/OSU-Sustainability-Office/energy-dashboard/actions/workflows/gh-deploy.yml/badge.svg)![API Status](https://github.com/OSU-Sustainability-Office/energy-dashboard/actions/workflows/API-deploy.yml/badge.svg) ![Test Build Status](https://github.com/OSU-Sustainability-Office/energy-dashboard/actions/workflows/test-build-s3.yml/badge.svg)



![Frontend Status](https://github.com/OSU-Sustainability-Office/energy-dashboard/actions/workflows/gh-deploy.yml/badge.svg)![API Status](https://github.com/OSU-Sustainability-Office/energy-dashboard/actions/workflows/API-deploy.yml/badge.svg) ![Test Build Status](https://github.com/OSU-Sustainability-Office/energy-dashboard/actions/workflows/test-build-s3.yml/badge.svg)

This Energy Dashboard has been developed by the Oregon State University Sustainability Office to enable members of the OSU community to access, view, and analyze energy consumption trends. The production build of this application can be found at [https://dashboard.sustainability.oregonstate.edu](https://dashboard.sustainability.oregonstate.edu). A test build is hosted on an AWS S3 bucket [here](http://energy-dashboard.s3-website-us-west-2.amazonaws.com).

### Contributors "Hall of Fame"
- [Brogan Miner](https://github.com/broha22)
- [Jack Woods](https://github.com/jackrwoods)

- [Brogan Miner](https://github.com/broha22)
- [Jack Woods](https://github.com/jackrwoods)

### Testing Locally
### Testing Locally

We recommend setting up `nvm` to set your node installation to version 16 (`nvm use 16`).

Running `npm run serve` will run the front-end locally.

To run the serverless backend API locally you'll want to run `sam local start-api` (docker will need to be running first).

### Formatting

Run both in order

- `npm run prettier`
- `npm run lint --fix`

### Documentation
For more detailed information about how the dashboard front-end works internally, there's a README.md with the vue components described under the `documents/frontend` directory.

For more detailed information about how the dashboard front-end works internally, there's a README.md with the vue components described under the `documents/frontend` directory.
12 changes: 5 additions & 7 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
* @Last modified time: 2019-02-01T12:55:07-08:00
*/

module.exports = function (api) {
api.cache(true)
const presets = [
'@vue/app'
]
module.exports = function ( api ) {
api.cache( true )
const presets = ['@vue/app']

const plugins = []

// add babel-require hook so web-pack directives don't brick jest
if (process.env.NODE_ENV === 'test') {
plugins.push('require-context-hook')
if ( process.env.NODE_ENV === 'test' ) {
plugins.push( 'require-context-hook' )
}

return {
Expand Down
18 changes: 9 additions & 9 deletions backend/app/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* @Last Modified Time: Saturday February 1st 2020
* @Copyright: (c) Oregon State University 2020
*/
const Response = require('/opt/nodejs/response.js')
const User = require('/opt/nodejs/user.js')
const EUser = require('/opt/nodejs/models/user.js')
const Response = require("/opt/nodejs/response.js");
const User = require("/opt/nodejs/user.js");
const EUser = require("/opt/nodejs/models/user.js");

exports.users = async (event, context) => {
let response = new Response(event)
let user = new User(event, response)
await user.resolved
response.body = await EUser.all(user)
return response
}
let response = new Response(event);
let user = new User(event, response);
await user.resolved;
response.body = await EUser.all(user);
return response;
};
74 changes: 40 additions & 34 deletions backend/app/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,65 @@
* @Copyright: Oregon State University 2019
*/

const Alert = require('/opt/nodejs/models/alert.js')
const Response = require('/opt/nodejs/response.js')
const User = require('/opt/nodejs/user.js')
const Alert = require("/opt/nodejs/models/alert.js");
const Response = require("/opt/nodejs/response.js");
const User = require("/opt/nodejs/user.js");

exports.get = async (event, context) => {
let response = new Response(event)
response.body = JSON.stringify((await (new Alert(event.queryStringParameters['id'])).get()).data)
return response
}
let response = new Response(event);
response.body = JSON.stringify(
(await new Alert(event.queryStringParameters["id"]).get()).data,
);
return response;
};

exports.post = async (event, context) => {
let response = new Response(event)
let user = new User(event, response)
let response = new Response(event);
let user = new User(event, response);
try {
response.body = JSON.stringify((await Alert.create(
event.body.lowThreshold,
event.body.highThreshold,
event.body.point,
event.body.meterId,
user
)).data)
response.body = JSON.stringify(
(
await Alert.create(
event.body.lowThreshold,
event.body.highThreshold,
event.body.point,
event.body.meterId,
user,
)
).data,
);
} catch (err) {
response.body = err.message
response.status = 400
response.body = err.message;
response.status = 400;
}
}
};

exports.put = async (event, context) => {
let response = new Response(event)
let user = new User(event, response)
let response = new Response(event);
let user = new User(event, response);
try {
await Alert(event.body.id).update(
event.body.lowThreshold,
event.body.highThreshold,
event.body.point,
event.body.meterId,
user
)
user,
);
} catch (error) {
response.body = error.message
response.status = 400
response.body = error.message;
response.status = 400;
}
return response
}
return response;
};

exports.delete = async (event, context) => {
let response = new Response(event)
let user = new User(event, response)
let response = new Response(event);
let user = new User(event, response);
try {
await Alert(event.body.id).delete(user)
await Alert(event.body.id).delete(user);
} catch (error) {
response.body = error.message
response.status = 400
response.body = error.message;
response.status = 400;
}
return response
}
return response;
};
90 changes: 48 additions & 42 deletions backend/app/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,74 @@
* @Copyright: Oregon State University 2019
*/

const Block = require('/opt/nodejs/models/block.js')
const Response = require('/opt/nodejs/response.js')
const User = require('/opt/nodejs/user.js')
const Block = require("/opt/nodejs/models/block.js");
const Response = require("/opt/nodejs/response.js");
const User = require("/opt/nodejs/user.js");

exports.get = async (event, context) => {
let response = new Response(event)
response.body = JSON.stringify((await (new Block(event.queryStringParameters['id'])).get()).data)
return response
}
let response = new Response(event);
response.body = JSON.stringify(
(await new Block(event.queryStringParameters["id"]).get()).data,
);
return response;
};

exports.post = async (event, context) => {
let response = new Response(event)
let user = new User(event, response)
await user.resolved
let response = new Response(event);
let user = new User(event, response);
await user.resolved;
try {
response.body = JSON.stringify((await Block.create(
event.body.dateStart,
event.body.dateEnd,
event.body.graphType,
event.body.name,
event.body.dateInterval,
event.body.intervalUnit,
event.body.storyId,
user
)).data)
response.body = JSON.stringify(
(
await Block.create(
event.body.dateStart,
event.body.dateEnd,
event.body.graphType,
event.body.name,
event.body.dateInterval,
event.body.intervalUnit,
event.body.storyId,
user,
)
).data,
);
} catch (err) {
response.body = err.message
response.status = 400
response.body = err.message;
response.status = 400;
}
return response
}
return response;
};

exports.put = async (event, context) => {
let response = new Response(event)
let user = new User(event, response)
await user.resolved
let response = new Response(event);
let user = new User(event, response);
await user.resolved;
try {
await (new Block(event.body.id)).update(
await new Block(event.body.id).update(
event.body.dateStart,
event.body.dateEnd,
event.body.graphType,
event.body.name,
event.body.dateInterval,
event.body.intervalUnit,
user
)
user,
);
} catch (error) {
response.body = error.message
response.status = 400
response.body = error.message;
response.status = 400;
}
return response
}
return response;
};

exports.delete = async (event, context) => {
let response = new Response(event)
let user = new User(event, response)
await user.resolved
let response = new Response(event);
let user = new User(event, response);
await user.resolved;
try {
await (new Block(event.body.id)).delete(user)
await new Block(event.body.id).delete(user);
} catch (error) {
response.body = error.message
response.status = 400
response.body = error.message;
response.status = 400;
}
return response
}
return response;
};
Loading
Loading