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

Develop #35

Merged
merged 5 commits into from
Jan 2, 2021
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
3 changes: 2 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ engines:
- javascript
eslint:
enabled: true
channel: "eslint-3"
channel: "eslint-6"
checks:
import/no-unresolved:
enabled: false
Expand All @@ -23,3 +23,4 @@ ratings:
- "**.md"
exclude_paths:
- "node_modules/**/*"
- "docs/**/*"
42 changes: 26 additions & 16 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
{
"extends": "airbnb-base",
"rules": {
"comma-dangle": 0,
"indent": [2, 4],
"max-len": [2, 120, { "ignoreStrings": true }],
"radix": [2, "as-needed"],
"no-console": 0
},
"settings": {
"import/core-modules": [ "node_helper" ]
},
"env": {
"browser": true,
"node": true,
"es6": true
}
"extends": ["esnext", "esnext/style-guide", "node", "node/style-guide"],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"settings": {
"import/core-modules": [ "node_helper" ]
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"rules": {
"import/no-commonjs": 0,
"import/no-nodejs-modules": 0,
"semi": 0,
"comma-dangle": 0,
"indent": ["error", 4],
"template-curly-spacing": 0,
"no-console": 0,
"curly": ["error", "all"],
"array-bracket-spacing": 0,
"space-before-function-paren": 0,
"object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }]
}
}
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: node_js
node_js:
- "8"
- "9"
- "stable"
- "10"
- "12"
- "14"
script:
- npm run lint
cache:
Expand Down
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# MMM-soccer Changelog

## [2.1.1]

### Added

* JSDoc dependency
* package-lock.json

### Changed

* Travis config
* Updated eslint
* Updated config

### Fixed

* Linting issues

## [2.1.0]

**Requires version > 2.14 of MagicMirror!**
**Requires version >= 2.14 of MagicMirror!**

### Added

Expand All @@ -28,7 +45,7 @@

### Added

* French translations (Thanks to https://github.com/laventin85)
* French translations (Thanks to [Laventin85](https://github.com/laventin85))

### Changed

Expand Down
21 changes: 13 additions & 8 deletions MMM-soccer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @see https://github.com/fewieden/MMM-soccer
*/

/* global Module Log */

/**
* @external Module
* @see https://github.com/MichMich/MagicMirror/blob/master/js/module.js
Expand All @@ -28,7 +26,8 @@
*/
Module.register('MMM-soccer', {
/**
* @member {string} requiresVersion - Defines the required minimum version of the MagicMirror framework in order to run this verion of the module.
* @member {string} requiresVersion - Defines the required minimum version of the MagicMirror framework in order to
* run this version of the module.
*/
requiresVersion: '2.14.0',

Expand Down Expand Up @@ -91,6 +90,8 @@ Module.register('MMM-soccer', {
* @function start
* @description Adds nunjuck filters and requests for league data.
* @override
*
* @returns {void}
*/
start() {
Log.info(`Starting module: ${this.name}`);
Expand All @@ -103,8 +104,10 @@ Module.register('MMM-soccer', {
},

/**
* @function start
* @function getData
* @description Sends request to the node_helper to fetch data for the current selected league.
*
* @returns {void}
*/
getData() {
this.sendSocketNotification('GET_DATA', { league: this.currentLeague, api_key: this.config.api_key });
Expand Down Expand Up @@ -308,7 +311,7 @@ Module.register('MMM-soccer', {
* @function isMaxTeamsLessAll
* @description Are there more entries than the config option specifies.
*
* @returns {boolean}
* @returns {boolean} Is max teams less than all teams?
*/
isMaxTeamsLessAll() {
return this.config.max_teams && this.config.max_teams <= this.standing.length;
Expand Down Expand Up @@ -339,6 +342,8 @@ Module.register('MMM-soccer', {
* @function getFirstAndLastTeam
* @description Helper function to get the boundaries of the teams that should be displayed.
*
* @param {number} index - Index of the focus_on team.
*
* @returns {Object} Index of the first and the last team.
*/
getFirstAndLastTeam(index) {
Expand All @@ -352,8 +357,8 @@ Module.register('MMM-soccer', {
lastTeam = firstTeam + this.config.max_teams;
} else {
lastTeam = this.standing.length;
firstTeam = lastTeam - this.config.max_teams >= 0 ?
lastTeam - this.config.max_teams : 0;
firstTeam = lastTeam - this.config.max_teams >= 0
? lastTeam - this.config.max_teams : 0;
}
} else {
firstTeam = 0;
Expand Down Expand Up @@ -406,7 +411,7 @@ Module.register('MMM-soccer', {
if (this.config.max_teams && focus >= 0) {
if (index !== focus) {
const currentStep = Math.abs(index - focus);
return `opacity: ${1 - ((1 / this.config.max_teams) * currentStep)}`;
return `opacity: ${1 - 1 / this.config.max_teams * currentStep}`;
}
}

Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ European Soccer Standings Module for MagicMirror²

## Installation

1. Clone this repo into `~/MagicMirror/modules` directory.
1. Configure your `~/MagicMirror/config/config.js`:

```
{
module: 'MMM-soccer',
position: 'bottom_right',
config: {
// add your config options here
}
* Clone this repo into `~/MagicMirror/modules` directory.
* Configure your `~/MagicMirror/config/config.js`:

```js
{
module: 'MMM-soccer',
position: 'bottom_right',
config: {
// add your config options here
}
```
}
```

1. Run command `npm i --production` in `~/MagicMirror/modules/MMM-soccer` directory.
1. Optional: Get a free api key [here](http://api.football-data.org/register)
* Run command `npm i --production` in `~/MagicMirror/modules/MMM-soccer` directory.
* Optional: Get a free api key [here](http://api.football-data.org/register)

## Config Options

Expand Down
7 changes: 6 additions & 1 deletion node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ module.exports = NodeHelper.create({
* @function start
* @description Logs a start message to the console.
* @override
*
* @returns {void}
*/
start() {
console.log(`Starting module: ${this.name}`);
Expand All @@ -47,6 +49,8 @@ module.exports = NodeHelper.create({
*
* @param {string} notification - Notification name
* @param {*} payload - Detailed payload of the notification.
*
* @returns {void}
*/
socketNotificationReceived(notification, payload) {
if (notification === 'GET_DATA') {
Expand All @@ -65,9 +69,10 @@ module.exports = NodeHelper.create({
* @description Request data from the supplied URL and broadcast it to the MagicMirror module if it's received.
*
* @param {Object} options - request optionsthe notification.
*
* @returns {void}
*/
getData(options) {
console.log(`Get league table for url ${options.url}`);
request(options, (error, response, body) => {
if (response.statusCode === 200) {
this.sendSocketNotification('DATA', JSON.parse(body));
Expand Down
Loading