test(aio): enable linting of transforms/ and add rules for jasmine

This commit is contained in:
Georgios Kalpakas
2017-04-01 21:34:10 +03:00
committed by Pete Bacon Darwin
parent a562c64ed6
commit 62f9738a9a
41 changed files with 101 additions and 96 deletions

View File

@ -4,7 +4,7 @@
* Later on we can extract the regions, via "shredding"; and we can also construct runnable examples
* for passing to plunker and the like.
*/
module.exports = function exampleFileReader(log) {
module.exports = function exampleFileReader() {
return {
name: 'exampleFileReader',
getDocs: function(fileInfo) {

View File

@ -1,5 +1,3 @@
var path = require('canonical-path');
var fs = require('fs');
var entities = require('entities');
/**
@ -28,7 +26,7 @@ module.exports = function exampleInlineTagDef(parseArgString, createDocMessage,
if (regionName === '\'\'') regionName = '';
var title = tagArgs.title || (unnamedArgs.length > 2 ? unnamedArgs.slice(2).join(' ') : null);
var linenums = tagArgs.linenums;
var stylePattern = tagArgs.stylePattern; // TODO: not yet implemented here
// var stylePattern = tagArgs.stylePattern; // TODO: not yet implemented here
const sourceCode = getExampleRegion(doc, relativePath, regionName);

View File

@ -14,8 +14,7 @@ var fs = require('fs');
* -titles="Hello app1, Hello app2" }
* @kind function
*/
module.exports = function exampleTabsInlineTagDef(
getLinkInfo, parseArgString, createDocMessage, log) {
module.exports = function exampleTabsInlineTagDef(getLinkInfo, parseArgString) {
return {
name: 'exampleTabs',
description:
@ -32,9 +31,10 @@ module.exports = function exampleTabsInlineTagDef(
}
// TODO: not yet implemented here
var stylePatterns = tagArgs.stylePattern;
// var stylePatterns = tagArgs.stylePattern;
var mixinPaths = relativePaths.map(function(relativePath, ix) {
// eslint-disable-next-line no-undef
var fragFileName = getApiFragmentFileName(relativePath, regions && regions[ix]);
if (!fs.existsSync(fragFileName)) {
// TODO: log.warn(createDocMessage('Invalid example (unable to locate fragment file: ' +
@ -43,7 +43,7 @@ module.exports = function exampleTabsInlineTagDef(
return path.join('_api', relativePath);
});
var comma = ', '
var comma = ', ';
var pathsArg = quote(mixinPaths.join(','));
var regionsArg = regions ? quote(regions.join(',')) : 'null';
var titlesArg = titles ? quote(titles) : 'null';

View File

@ -65,7 +65,7 @@ module.exports = function collectExamples(exampleMap, regionParser, log, createD
function createRegionDoc(folder, relativePath, regionName, regionContents) {
const path = folder + '/' + relativePath;
const id = path + '#' + regionName
const id = path + '#' + regionName;
return {
docType: 'example-region',
path: path,
@ -74,4 +74,4 @@ function createRegionDoc(folder, relativePath, regionName, regionContents) {
aliases: [id],
contents: regionContents
};
}
}

View File

@ -8,7 +8,7 @@ describe('collectExampleRegions processor', () => {
beforeEach(function() {
regionParser = jasmine.createSpy('regionParser').and.callFake(function(contents, extension) {
return { contents: 'PARSED:' + contents, regions: {dummy: extension} }
return { contents: 'PARSED:' + contents, regions: {dummy: extension} };
});
const dgeni =
@ -82,7 +82,7 @@ describe('collectExampleRegions processor', () => {
createDoc('Other doc 2', 'other/b/c.js', 'content')
];
const processedDocs = processor.$process(docs);
processor.$process(docs);
expect(regionParser).toHaveBeenCalledTimes(3);
expect(regionParser).toHaveBeenCalledWith('Example A', 'js');

View File

@ -1,9 +1,8 @@
var testPackage = require('../../helpers/test-package');
var Dgeni = require('dgeni');
var path = require('path');
describe('renderExamples processor', () => {
var injector, processor, exampleMap, regionParser, collectExamples, exampleMap;
var injector, processor, exampleMap, collectExamples;
beforeEach(function() {
const dgeni = new Dgeni([testPackage('examples-package', true)]);
@ -24,7 +23,7 @@ describe('renderExamples processor', () => {
});
it('should run before the correct processor', () => {
expect(processor.$runBefore).toEqual(['writing-files'])
expect(processor.$runBefore).toEqual(['writing-files']);
});
it('should run after the correct processor', () => {
@ -90,4 +89,4 @@ describe('renderExamples processor', () => {
});
})
);
});
});

View File

@ -47,12 +47,12 @@ module.exports = function parseArgString() {
key = key.substr(1);
}
} else {
unnammedArgs.push(arg)
unnammedArgs.push(arg);
key = null;
}
}
}
} while (match !== null);
return args;
}
}
};
};

View File

@ -3,7 +3,6 @@ const html = require('./region-matchers/html');
const inlineC = require('./region-matchers/inline-c');
const inlineCOnly = require('./region-matchers/inline-c-only');
const inlineHash = require('./region-matchers/inline-hash');
const NO_NAME_REGION = '';
const DEFAULT_PLASTER = '. . .';
const {mapObject} = require('../utils');
@ -140,4 +139,4 @@ function RegionParserError(message, index) {
this.stack = (new Error()).stack;
}
RegionParserError.prototype = Object.create(Error.prototype);
RegionParserError.prototype.constructor = RegionParserError;
RegionParserError.prototype.constructor = RegionParserError;

View File

@ -172,7 +172,7 @@ describe('regionParser service', () => {
expect(output.regions['A']).toEqual(t('abc', 'xyz'));
expect(output.regions['B']).toEqual(t('abc'));
expect(output.regions['C']).toEqual(t('xyz'));
})
});
});
function t() {

View File

@ -17,7 +17,7 @@ module.exports = {
*/
parseAttributes(str) {
const attrMap = {};
let index = 0, key, value;
let index = 0;
skipSpace();
@ -64,7 +64,7 @@ module.exports = {
function tryQuote() {
const quote = str[index];
if (['"', "'"].indexOf(quote) !== -1) {
if (['"', '\''].indexOf(quote) !== -1) {
index++;
return quote;
}
@ -90,4 +90,4 @@ module.exports = {
return attrMap;
}
};
};

View File

@ -71,6 +71,6 @@ describe('utils', () => {
expect(() => parseAttributes('a="" b="two')).toThrowError(
'Unterminated quoted attribute value in `a="" b="two`. Starting at 8. Expected a " but got "end of string".'
);
})
});
});
});
});