comma dangle
This commit is contained in:
+14
-10
@@ -4,38 +4,42 @@ module.exports = {
|
||||
'commonjs': true,
|
||||
'es2021': true,
|
||||
'node': true,
|
||||
'jest/globals': true
|
||||
'jest/globals': true,
|
||||
},
|
||||
'extends': ['eslint:recommended', 'plugin:jest/recommended'],
|
||||
'parserOptions': {
|
||||
'ecmaVersion': 12
|
||||
'ecmaVersion': 12,
|
||||
},
|
||||
'rules': {
|
||||
'indent': [
|
||||
'error',
|
||||
4
|
||||
4,
|
||||
],
|
||||
'linebreak-style': [
|
||||
'error',
|
||||
'unix'
|
||||
'unix',
|
||||
],
|
||||
'quotes': [
|
||||
'error',
|
||||
'single'
|
||||
'single',
|
||||
],
|
||||
'semi': [
|
||||
'error',
|
||||
'always'
|
||||
'always',
|
||||
],
|
||||
'curly': [
|
||||
'error',
|
||||
'all'
|
||||
'all',
|
||||
],
|
||||
'brace-style': [
|
||||
'error',
|
||||
'1tbs'
|
||||
'1tbs',
|
||||
],
|
||||
'jest/no-done-callback': 'off',
|
||||
'jest/expect-expect': 'off'
|
||||
}
|
||||
'jest/expect-expect': 'off',
|
||||
'comma-dangle': [
|
||||
'error',
|
||||
'always-multiline',
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
+4
-4
@@ -93,7 +93,7 @@ module.exports = (config) => {
|
||||
host: host,
|
||||
version: pjson.version,
|
||||
request: req,
|
||||
config: config
|
||||
config: config,
|
||||
};
|
||||
res.render(vPath, data, (err, html) => {
|
||||
if (err && vPath !== path.join(config['data_dir'], config['home']['error'])) {
|
||||
@@ -130,7 +130,7 @@ module.exports = (config) => {
|
||||
//rate limit for safer server
|
||||
const limiter = rateLimit({
|
||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||
max: config['rate_limit']
|
||||
max: config['rate_limit'],
|
||||
});
|
||||
app.use(limiter);
|
||||
|
||||
@@ -174,7 +174,7 @@ module.exports = (config) => {
|
||||
'title': config['rss']['title'],
|
||||
'description': config['rss']['description'],
|
||||
'feed_url': host + req.url,
|
||||
'site_url': host
|
||||
'site_url': host,
|
||||
});
|
||||
Object.values(articles)
|
||||
.slice(0, config['rss']['length'])
|
||||
@@ -182,7 +182,7 @@ module.exports = (config) => {
|
||||
feed.item({
|
||||
title: article.title,
|
||||
url: host + article.url,
|
||||
date: article.date
|
||||
date: article.date,
|
||||
});
|
||||
});
|
||||
lastRSS = feed.xml();
|
||||
|
||||
+2
-2
@@ -92,7 +92,7 @@ module.exports = (config) => {
|
||||
realPath: path.join(config['data_dir'], p[0], p[1], p[2], p[3]),
|
||||
year: parseInt(p[0]),
|
||||
month: parseInt(p[1]),
|
||||
day: parseInt(p[2])
|
||||
day: parseInt(p[2]),
|
||||
};
|
||||
article.date = new Date(article.year, article.month, article.day);
|
||||
article.date.setUTCHours(0);
|
||||
@@ -116,6 +116,6 @@ module.exports = (config) => {
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
+5
-5
@@ -112,9 +112,9 @@ module.exports = (config) => {
|
||||
MathJax: {
|
||||
tex2jax: {
|
||||
inlineMath: [['$', '$']],
|
||||
displayMath: [['$$', '$$']]
|
||||
}
|
||||
}
|
||||
displayMath: [['$$', '$$']],
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ module.exports = (config) => {
|
||||
const mjConf = {
|
||||
math: eq,
|
||||
format: format,
|
||||
speakText: config['mathjax']['speak_text']
|
||||
speakText: config['mathjax']['speak_text'],
|
||||
};
|
||||
mjConf[output] = true;
|
||||
mjAPI.typeset(mjConf, (res) => {
|
||||
@@ -222,7 +222,7 @@ module.exports = (config) => {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+18
-18
@@ -163,7 +163,7 @@ describe('Test root path', () => {
|
||||
utils.createEmptyDirs([
|
||||
path.join(dataDir, '2019', '05', '05'),
|
||||
path.join(dataDir, '2018', '05', '05'),
|
||||
path.join(dataDir, '2017', '05', '05')
|
||||
path.join(dataDir, '2017', '05', '05'),
|
||||
]);
|
||||
utils.createEmptyFiles([
|
||||
path.join(dataDir, '2019', '05', '05', 'draft.md'),
|
||||
@@ -219,11 +219,11 @@ describe('Test RSS feed', () => {
|
||||
test('200 2 rss items', (done, fail) => {
|
||||
utils.createEmptyDirs([
|
||||
path.join(dataDir, '2019', '05', '05'),
|
||||
path.join(dataDir, '2018', '05', '05')
|
||||
path.join(dataDir, '2018', '05', '05'),
|
||||
]);
|
||||
utils.createEmptyFiles([
|
||||
path.join(dataDir, '2019', '05', '05', 'index.md'),
|
||||
path.join(dataDir, '2018', '05', '05', 'index.md')
|
||||
path.join(dataDir, '2018', '05', '05', 'index.md'),
|
||||
]);
|
||||
app.reload(() => {
|
||||
request(app).get('/rsstest').then((response) => {
|
||||
@@ -238,12 +238,12 @@ describe('Test RSS feed', () => {
|
||||
utils.createEmptyDirs([
|
||||
path.join(dataDir, '2019', '05', '05'),
|
||||
path.join(dataDir, '2018', '05', '05'),
|
||||
path.join(dataDir, '2017', '05', '05')
|
||||
path.join(dataDir, '2017', '05', '05'),
|
||||
]);
|
||||
utils.createEmptyFiles([
|
||||
path.join(dataDir, '2019', '05', '05', 'index.md'),
|
||||
path.join(dataDir, '2018', '05', '05', 'index.md'),
|
||||
path.join(dataDir, '2017', '05', '05', 'index.md')
|
||||
path.join(dataDir, '2017', '05', '05', 'index.md'),
|
||||
]);
|
||||
app.reload(() => {
|
||||
request(app).get('/rsstest').then((response) => {
|
||||
@@ -265,10 +265,10 @@ describe('Test webhook', () => {
|
||||
});
|
||||
});
|
||||
test('200 no secret', (done) => {
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05')]);
|
||||
utils.createEmptyFiles([
|
||||
path.join(dataDir, '2019', '05', '05', 'index.md'),
|
||||
path.join(dataDir, testTemplate)
|
||||
path.join(dataDir, testTemplate),
|
||||
]);
|
||||
config['webhook']['pull_command'] = 'git --help';
|
||||
request(app).post('/webhooktest').then((response) => {
|
||||
@@ -280,10 +280,10 @@ describe('Test webhook', () => {
|
||||
});
|
||||
});
|
||||
test('500 command failed', (done) => {
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05')]);
|
||||
utils.createEmptyFiles([
|
||||
path.join(dataDir, '2019', '05', '05', 'index.md'),
|
||||
path.join(dataDir, testTemplate)
|
||||
path.join(dataDir, testTemplate),
|
||||
]);
|
||||
config['webhook']['pull_command'] = 'qzgfqgqz';
|
||||
request(app).post('/webhooktest').then((response) => {
|
||||
@@ -322,7 +322,7 @@ describe('Test articles rendering', () => {
|
||||
});
|
||||
|
||||
test('500 fail to render', (done, fail) => {
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05')]);
|
||||
fs.writeFileSync(path.join(dataDir, '2019', '05', '05', 'index.md'), '# Hello');
|
||||
fs.writeFileSync(path.join(dataDir, testTemplate), '<%- articl.content %><%- `<a href="${article.url}">reload</a>` %>');
|
||||
app.reload(() => {
|
||||
@@ -334,7 +334,7 @@ describe('Test articles rendering', () => {
|
||||
});
|
||||
|
||||
test('500 no template', (done, fail) => {
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05')]);
|
||||
fs.writeFileSync(path.join(dataDir, '2019', '05', '05', 'index.md'), '# Hello');
|
||||
app.reload(() => {
|
||||
request(app).get('/2019/05/05/hello/').then((response) => {
|
||||
@@ -345,7 +345,7 @@ describe('Test articles rendering', () => {
|
||||
});
|
||||
|
||||
test('200 rendered article', (done, fail) => {
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05')]);
|
||||
fs.writeFileSync(path.join(dataDir, '2019', '05', '05', 'index.md'), '# Hello');
|
||||
fs.writeFileSync(path.join(dataDir, testTemplate), '<%- article.content %><%- `<a href="${article.url}">reload</a>` %>');
|
||||
app.reload(() => {
|
||||
@@ -358,7 +358,7 @@ describe('Test articles rendering', () => {
|
||||
});
|
||||
|
||||
test('200 rendered draft', (done, fail) => {
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05')]);
|
||||
fs.writeFileSync(path.join(dataDir, '2019', '05', '05', 'draft.md'), '# Hello');
|
||||
fs.writeFileSync(path.join(dataDir, testTemplate), '<%- article.content %><%- `<a href="${article.url}">reload</a>` %>');
|
||||
app.reload(() => {
|
||||
@@ -371,10 +371,10 @@ describe('Test articles rendering', () => {
|
||||
});
|
||||
|
||||
test('200 other url', (done, fail) => {
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05')]);
|
||||
utils.createEmptyFiles([
|
||||
path.join(dataDir, '2019', '05', '05', 'index.md'),
|
||||
path.join(dataDir, testTemplate)
|
||||
path.join(dataDir, testTemplate),
|
||||
]);
|
||||
app.reload(() => {
|
||||
request(app).get('/2019/05/05/anything/').then((response) => {
|
||||
@@ -385,10 +385,10 @@ describe('Test articles rendering', () => {
|
||||
});
|
||||
|
||||
test('200 other url 2', (done, fail) => {
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05')]);
|
||||
utils.createEmptyFiles([
|
||||
path.join(dataDir, '2019', '05', '05', 'index.md'),
|
||||
path.join(dataDir, testTemplate)
|
||||
path.join(dataDir, testTemplate),
|
||||
]);
|
||||
app.reload(() => {
|
||||
request(app).get('/2019/05/05/').then((response) => {
|
||||
@@ -441,7 +441,7 @@ describe('Test static files', () => {
|
||||
});
|
||||
});
|
||||
test('200 valid resource of article', (done) => {
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05'),]);
|
||||
utils.createEmptyDirs([path.join(dataDir, '2019', '05', '05')]);
|
||||
fs.writeFileSync(path.join(dataDir, '2019', '05', '05', 'somefile.txt'), 'filecontent');
|
||||
request(app).get('/2019/05/05/title/somefile.txt').then((response) => {
|
||||
expect(response.statusCode).toBe(200);
|
||||
|
||||
+13
-13
@@ -15,8 +15,8 @@ const config = {
|
||||
'draft': 'draft.md',
|
||||
'default_title': 'Untitled',
|
||||
'default_thumbnail': 'default.png',
|
||||
'thumbnail_tag': 'thumbnail'
|
||||
}
|
||||
'thumbnail_tag': 'thumbnail',
|
||||
},
|
||||
};
|
||||
|
||||
const fw = require('../src/file_walker')(config);
|
||||
@@ -46,7 +46,7 @@ describe('Test function fileTree', () => {
|
||||
utils.createEmptyDirs([
|
||||
path.join(dataDir, 'test', 'test'),
|
||||
path.join(dataDir, 'test', 'test2'),
|
||||
path.join(dataDir, 'test2')
|
||||
path.join(dataDir, 'test2'),
|
||||
]);
|
||||
fw.fileTree(dataDir, (err, list) => {
|
||||
expect(err).toBeNull();
|
||||
@@ -58,7 +58,7 @@ describe('Test function fileTree', () => {
|
||||
test('simple files', (done) => {
|
||||
const fileList = [
|
||||
path.join(dataDir, 'f1.txt'),
|
||||
path.join(dataDir, 'f2.txt')
|
||||
path.join(dataDir, 'f2.txt'),
|
||||
];
|
||||
utils.createEmptyFiles(fileList);
|
||||
fw.fileTree(dataDir, (err, list) => {
|
||||
@@ -72,13 +72,13 @@ describe('Test function fileTree', () => {
|
||||
test('nested files', (done) => {
|
||||
utils.createEmptyDirs([
|
||||
path.join(dataDir, 'test', 'test'),
|
||||
path.join(dataDir, 'test2')
|
||||
path.join(dataDir, 'test2'),
|
||||
]);
|
||||
const fileList = [
|
||||
path.join(dataDir, 'f1.txt'),
|
||||
path.join(dataDir, 'test', 'f2.txt'),
|
||||
path.join(dataDir, 'test', 'test', 'f3.txt'),
|
||||
path.join(dataDir, 'test2', 'f4.txt')
|
||||
path.join(dataDir, 'test2', 'f4.txt'),
|
||||
];
|
||||
utils.createEmptyFiles(fileList);
|
||||
fw.fileTree(dataDir, (err, list) => {
|
||||
@@ -120,7 +120,7 @@ describe('Test index article reading', () => {
|
||||
expect(err).toBeNull();
|
||||
expect(info).toEqual({
|
||||
title: 'This is an awesome title !?¤',
|
||||
thumbnail: './thumbnail.jpg'
|
||||
thumbnail: './thumbnail.jpg',
|
||||
});
|
||||
done();
|
||||
});
|
||||
@@ -136,7 +136,7 @@ describe('Test index article reading', () => {
|
||||
expect(err).toBeNull();
|
||||
expect(info).toEqual({
|
||||
title: undefined,
|
||||
thumbnail: './thumbnail.jpg'
|
||||
thumbnail: './thumbnail.jpg',
|
||||
});
|
||||
done();
|
||||
});
|
||||
@@ -148,7 +148,7 @@ describe('Test index article reading', () => {
|
||||
expect(err).toBeNull();
|
||||
expect(info).toEqual({
|
||||
title: 'title',
|
||||
thumbnail: undefined
|
||||
thumbnail: undefined,
|
||||
});
|
||||
done();
|
||||
});
|
||||
@@ -164,7 +164,7 @@ describe('Test index article reading', () => {
|
||||
expect(err).toBeNull();
|
||||
expect(info).toEqual({
|
||||
title: 'This is an awesome title !?¤',
|
||||
thumbnail: undefined
|
||||
thumbnail: undefined,
|
||||
});
|
||||
done();
|
||||
});
|
||||
@@ -181,7 +181,7 @@ describe('Test index article reading', () => {
|
||||
expect(err).toBeNull();
|
||||
expect(info).toEqual({
|
||||
title: 'This is an awesome title !?¤',
|
||||
thumbnail: './thumbnail.jpg'
|
||||
thumbnail: './thumbnail.jpg',
|
||||
});
|
||||
done();
|
||||
});
|
||||
@@ -208,12 +208,12 @@ describe('Test article fetching', () => {
|
||||
test('misplaced index file', (done) => {
|
||||
utils.createEmptyDirs([
|
||||
path.join(dataDir, 'test', 'test'),
|
||||
path.join(dataDir, '2019', '05', '05')
|
||||
path.join(dataDir, '2019', '05', '05'),
|
||||
]);
|
||||
utils.createEmptyFiles([
|
||||
path.join(dataDir, testIndex),
|
||||
path.join(dataDir, 'test', 'test', testIndex),
|
||||
path.join(dataDir, '2019', '05', testIndex)
|
||||
path.join(dataDir, '2019', '05', testIndex),
|
||||
]);
|
||||
fw.fetchArticles((err, dict) => {
|
||||
expect(err).toBeNull();
|
||||
|
||||
+10
-10
@@ -15,15 +15,15 @@ const config = {
|
||||
},
|
||||
'showdown': {
|
||||
'simplifiedAutoLink': true,
|
||||
'smartIndentationFix': true
|
||||
'smartIndentationFix': true,
|
||||
},
|
||||
'mathjax': {
|
||||
'output_format': 'html',
|
||||
'speak_text': false
|
||||
'speak_text': false,
|
||||
},
|
||||
'plantuml': {
|
||||
'output_format': 'svg'
|
||||
}
|
||||
'output_format': 'svg',
|
||||
},
|
||||
};
|
||||
|
||||
const renderer = require('../src/renderer')(config);
|
||||
@@ -48,7 +48,7 @@ describe('get parts', () => {
|
||||
const data = 'Hello\nthere\ngeneral\nkenobi';
|
||||
const parts = renderer.getParts(data);
|
||||
expect(parts.map(p => p.text)).toEqual([
|
||||
'Hello\nthere\ngeneral\nkenobi'
|
||||
'Hello\nthere\ngeneral\nkenobi',
|
||||
]);
|
||||
});
|
||||
test('lot of stuff', () => {
|
||||
@@ -58,27 +58,27 @@ describe('get parts', () => {
|
||||
{
|
||||
index: 0,
|
||||
end: 12,
|
||||
text: 'Hello\nthere\n'
|
||||
text: 'Hello\nthere\n',
|
||||
},
|
||||
{
|
||||
index: 22,
|
||||
end: 30,
|
||||
text: '\ngeneral'
|
||||
text: '\ngeneral',
|
||||
},
|
||||
{
|
||||
index: 53,
|
||||
end: 54,
|
||||
text: '\n'
|
||||
text: '\n',
|
||||
},
|
||||
{
|
||||
index: 78,
|
||||
end: 79,
|
||||
text: '\n'
|
||||
text: '\n',
|
||||
},
|
||||
{
|
||||
index: 109,
|
||||
end: 115,
|
||||
text: 'kenobi'
|
||||
text: 'kenobi',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user