mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Add eslint and apply fixes
This commit is contained in:
parent
8e99073b38
commit
a3d28dafb7
17
js-jasmine/.eslintrc.json
Normal file
17
js-jasmine/.eslintrc.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"commonjs": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 12
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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.
|
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.
|
||||||
1937
js-jasmine/package-lock.json
generated
1937
js-jasmine/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -24,6 +24,7 @@
|
|||||||
"babel-core": "^6.26.0",
|
"babel-core": "^6.26.0",
|
||||||
"babel-preset-env": "1.7.0",
|
"babel-preset-env": "1.7.0",
|
||||||
"babel-register": "^6.26.0",
|
"babel-register": "^6.26.0",
|
||||||
|
"eslint": "^7.14.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"jasmine": "^3.2.0",
|
"jasmine": "^3.2.0",
|
||||||
"path": "^0.12.7"
|
"path": "^0.12.7"
|
||||||
|
|||||||
@ -5,3 +5,6 @@ class Item {
|
|||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
module.exports = {
|
||||||
|
Item
|
||||||
|
};
|
||||||
@ -1,5 +1,5 @@
|
|||||||
exports.regex_matcher = /aged brie/;
|
exports.regex_matcher = /aged brie/;
|
||||||
exports.qualityChange = function (sellIn, quality) {
|
exports.qualityChange = function (sellIn) {
|
||||||
if (sellIn <= 0) {
|
if (sellIn <= 0) {
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
exports.regex_matcher = /conjured/;
|
exports.regex_matcher = /conjured/;
|
||||||
exports.qualityChange = function (sellIn, quality) {
|
exports.qualityChange = function (sellIn) {
|
||||||
if (sellIn <= 0) {
|
if (sellIn <= 0) {
|
||||||
return -4;
|
return -4;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ glob.sync('./src/item_types/**/*.js').forEach(function (file) {
|
|||||||
itemTypes.push(require(path.resolve(file)));
|
itemTypes.push(require(path.resolve(file)));
|
||||||
});
|
});
|
||||||
|
|
||||||
const standardItem = require('./standard_update.js')
|
const standardItem = require('./standard_update.js');
|
||||||
class Shop {
|
class Shop {
|
||||||
constructor(items = []) {
|
constructor(items = []) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
@ -17,7 +17,7 @@ class Shop {
|
|||||||
updateQuality() {
|
updateQuality() {
|
||||||
this.items.forEach(item =>
|
this.items.forEach(item =>
|
||||||
this._updateItem(item)
|
this._updateItem(item)
|
||||||
)
|
);
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,8 +27,8 @@ class Shop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_updateItemQuality(item) {
|
_updateItemQuality(item) {
|
||||||
this._conditionallyUpdateQuality(item)
|
this._conditionallyUpdateQuality(item);
|
||||||
this._checkQualityBounds(item)
|
this._checkQualityBounds(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
_conditionallyUpdateQuality(item) {
|
_conditionallyUpdateQuality(item) {
|
||||||
@ -65,4 +65,4 @@ class Shop {
|
|||||||
}
|
}
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Shop
|
Shop
|
||||||
}
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user