-
Notifications
You must be signed in to change notification settings - Fork 778
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'zotero:master' into master
- Loading branch information
Showing
595 changed files
with
147,511 additions
and
38,493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"env": { | ||
"node": true, | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2018 | ||
}, | ||
"rules": { | ||
"notice/notice": "off" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
***** BEGIN LICENSE BLOCK ***** | ||
|
||
Copyright © ${ period } ${ holder } | ||
|
||
This file is part of Zotero. | ||
|
||
Zotero is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
Zotero is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
|
||
You should have received a copy of the GNU Affero General Public License | ||
along with Zotero. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
***** END LICENSE BLOCK ***** | ||
*/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
process.argv = process.argv.map(arg => arg === '--output-json' ? [ '--format', 'json', '--output-file' ] : arg).flat(); | ||
|
||
require('../../../node_modules/.bin/eslint') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @fileoverview Checks Zotero translators for errors and recommended style | ||
* @author Emiliano Heyns | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const requireDir = require('require-dir'); | ||
|
||
module.exports = { | ||
rules: requireDir('./lib/rules'), | ||
processors: { | ||
translator: require('./processor'), | ||
}, | ||
}; |
55 changes: 55 additions & 0 deletions
55
.ci/eslint-plugin-zotero-translator/lib/rules/header-last-updated.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
'use strict'; | ||
|
||
const { parsed, header } = require('../../processor').support; | ||
|
||
module.exports = { | ||
meta: { | ||
type: 'problem', | ||
docs: { | ||
description: 'enforce valid lastUpdated in header', | ||
category: 'Possible Errors', | ||
}, | ||
fixable: 'code', | ||
}, | ||
|
||
create: function (context) { | ||
return { | ||
Program: function (node) { | ||
const filename = context.getFilename(); | ||
const translator = parsed(filename); | ||
if (!translator || !translator.header.fields) return; // regular js source, or header is invalid | ||
|
||
const lastUpdated = header(node).properties.find(p => p.key.value === 'lastUpdated'); | ||
|
||
if (!lastUpdated) { | ||
context.report({ | ||
loc: { start: { line: 1, column: 1 } }, | ||
message: 'Header needs lastUpdated field', | ||
}); | ||
return; | ||
} | ||
|
||
const format = date => date.toISOString().replace('T', ' ').replace(/\..*/, ''); | ||
const now = format(new Date()); | ||
const fix = fixer => fixer.replaceText(lastUpdated.value, `"${now}"`); | ||
|
||
if (typeof lastUpdated.value.value !== 'string' || !lastUpdated.value.value.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/)) { | ||
context.report({ | ||
node: lastUpdated.value, | ||
message: `lastUpdated field must be a string in YYYY-MM-DD HH:MM:SS format`, | ||
fix, | ||
}); | ||
return; | ||
} | ||
|
||
if (translator.lastUpdated && translator.lastUpdated > lastUpdated.value.value) { | ||
context.report({ | ||
node: lastUpdated.value, | ||
message: `lastUpdated field must be updated to be > ${translator.lastUpdated} to push to clients`, | ||
fix, | ||
}); | ||
} | ||
} | ||
}; | ||
}, | ||
}; |
Oops, something went wrong.