diff --git a/src/formatters/stylish.js b/src/formatters/stylish.js index 78419ef2..3076cfa1 100644 --- a/src/formatters/stylish.js +++ b/src/formatters/stylish.js @@ -6,7 +6,7 @@ const stylizeRuleErrorWith = (maxErrorMsgLength, maxLineChars) => (error) => { let str = ' '; // indent 2 spaces so it looks pretty const padding = ' '; // padding of 4 spaces, will be used between line numbers, error msgs and rule names let {line} = error.location; - line = line ? line.toString() : ''; + line = line.toString(); // add spaces until the line string is as long as our longest line string while (line.length < maxLineChars) { diff --git a/src/rules/indentation.js b/src/rules/indentation.js index 5fbbd083..eb257c9e 100644 --- a/src/rules/indentation.js +++ b/src/rules/indentation.js @@ -28,11 +28,6 @@ const defaultConfig = { 'Step': 2, 'Examples': 0, 'example': 2, - 'given': 2, - 'when': 2, - 'then': 2, - 'and': 2, - 'but': 2, 'DocString': 4, }; @@ -93,10 +88,6 @@ const checkTags = (testNode) => (node) => { return flatMap(compose(testNode, getFirstTag))(tagsPerLine); }; -const findKey = (obj, predicate) => { - return Object.keys(obj).find((key) => predicate(obj[key])); -}; - const testDocString = (parseDocString, test) => (step) => { if (!step.argument || step.argument.type !== 'DocString') { return []; @@ -109,16 +100,8 @@ const testDocString = (parseDocString, test) => (step) => { return docString.lines.map(test('DocString line')); }; -const getStepType = (feature, languageKeywords, config) => (step) => { - const keyword = step.keyword; - const stepType = findKey(languageKeywords, (values) => { - return values instanceof Array && values.indexOf(keyword) !== -1; - }); - return stepType in config ? stepType : 'Step'; -}; - -const testStep = (getStepType, testDocstring, testNode) => (step) => { - const stepType = getStepType(step); +const testStep = (testDocstring, testNode) => (step) => { + const stepType = step.type; return applyOver([ testNode(stepType), testDocstring, @@ -168,7 +151,6 @@ const run = ({feature, languageKeywords, file, config}) => { return testFeature( testStep( - getStepType(feature, languageKeywords, config), testDocString(parseDocString(lines), test), test ), diff --git a/src/utils/generic.js b/src/utils/generic.js index 0153c96e..822e7a91 100644 --- a/src/utils/generic.js +++ b/src/utils/generic.js @@ -11,11 +11,6 @@ const reduce = (reducer, acc) => (input) => { if (Array.isArray(input)) { return input.reduce(reducer, acc); } - for (const name in input) { - if (({}).hasOwnProperty.call(input, name)) { - acc = reducer(acc, input[name]); - } - } return acc; }; diff --git a/test/rules-parser.js b/test/rules-parser.js index 007f42b8..b8b7d900 100644 --- a/test/rules-parser.js +++ b/test/rules-parser.js @@ -77,8 +77,6 @@ describe('Rule Parser', function() { 'Background': 1, 'Scenario': 1, 'Step': 1, - 'given': 1, - 'and': 1, }], }); return hasRules(rulesOrErrors, []); diff --git a/test/rules/indentation/indentation.js b/test/rules/indentation/indentation.js index b3706d75..b0c13a4d 100644 --- a/test/rules/indentation/indentation.js +++ b/test/rules/indentation/indentation.js @@ -115,19 +115,19 @@ const wrongIndentationErrors = [{ }]; describe('Indentation rule', () => { - it('doesn\'t raise errors when the default conifguration is used and there are no indentation violations (spaces)', () => { + it('does not raise errors when the default conifguration is used and there are no indentation violations (spaces)', () => { return runTest('indentation/CorrectIndentationSpaces.feature', {}, []); }); - it('doesn\'t raise errors when scenario outline does not have examples', () => { + it('does not raise errors when scenario outline does not have examples', () => { return runTest('indentation/CorrectIndentationWithoutExamples.feature', {}, []); }); - it('doesn\'t raise errors when the file is empty', () => { + it('does not raise errors when the file is empty', () => { return runTest('Empty.feature', {}, []); }); - it('doesn\'t raise errors when the default conifguration is used are and there no indentation violations (tabs)', () => { + it('does not raise errors when the default conifguration is used are and there no indentation violations (tabs)', () => { return runTest('indentation/CorrectIndentationTabs.feature', {}, []); }); @@ -261,31 +261,6 @@ describe('Indentation rule', () => { }, []); }); - it('Wrong "then" step in customized configuration', () => { - return runTest('indentation/WrongSteps.feature', { - Feature: 1, - Background: 4, - Scenario: 1, - Examples: 2, - example: 4, - then: 0, - }, [{ - message: message({element: 'then', expected: 0, actual: 3}), - rule: ruleName, - location: { - line: 7, - column: 4, - }, - }, { - message: message({element: 'then', expected: 0, actual: 5}), - rule: ruleName, - location: { - line: 12, - column: 6, - }, - }]); - }); - context('DocString', () => { it('Correct indentation', () => { return runTest('indentation/CorrectIndentationDocStrings.feature', {