Add eslint and apply fixes

This commit is contained in:
Dan Holmes 2020-12-04 09:20:21 +00:00
parent 8e99073b38
commit a3d28dafb7
8 changed files with 1967 additions and 8 deletions

17
js-jasmine/.eslintrc.json Normal file
View File

@ -0,0 +1,17 @@
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
"semi": [
"error",
"always"
]
}
}

View File

@ -19,3 +19,4 @@ The test spec required that I did not alter the Item class. This made it more di
My tests verged on state driven rather than behaviour driven. I could not find an equivalent of RSpec's "change by" matcher for Jasmine. Any tips would be appreciated.
With more time I would add a 'sellInChange' function to each item type to mirror the qualityChange. The different sellIn change for Sulfurus is still handled by exception.

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,7 @@
"babel-core": "^6.26.0",
"babel-preset-env": "1.7.0",
"babel-register": "^6.26.0",
"eslint": "^7.14.0",
"glob": "^7.1.6",
"jasmine": "^3.2.0",
"path": "^0.12.7"

View File

@ -4,4 +4,7 @@ class Item {
this.sellIn = sellIn;
this.quality = quality;
}
}
}
module.exports = {
Item
};

View File

@ -1,5 +1,5 @@
exports.regex_matcher = /aged brie/;
exports.qualityChange = function (sellIn, quality) {
exports.qualityChange = function (sellIn) {
if (sellIn <= 0) {
return 2;
} else {

View File

@ -1,5 +1,5 @@
exports.regex_matcher = /conjured/;
exports.qualityChange = function (sellIn, quality) {
exports.qualityChange = function (sellIn) {
if (sellIn <= 0) {
return -4;
} else {

View File

@ -7,7 +7,7 @@ glob.sync('./src/item_types/**/*.js').forEach(function (file) {
itemTypes.push(require(path.resolve(file)));
});
const standardItem = require('./standard_update.js')
const standardItem = require('./standard_update.js');
class Shop {
constructor(items = []) {
this.items = items;
@ -17,7 +17,7 @@ class Shop {
updateQuality() {
this.items.forEach(item =>
this._updateItem(item)
)
);
return this.items;
}
@ -27,8 +27,8 @@ class Shop {
}
_updateItemQuality(item) {
this._conditionallyUpdateQuality(item)
this._checkQualityBounds(item)
this._conditionallyUpdateQuality(item);
this._checkQualityBounds(item);
}
_conditionallyUpdateQuality(item) {
@ -65,4 +65,4 @@ class Shop {
}
module.exports = {
Shop
}
};