Skip to content

Commit

Permalink
Bump prettier from 1.19.1 to 2.0.4 (OctoLinker#873)
Browse files Browse the repository at this point in the history
* Bump prettier from 1.19.1 to 2.0.4

Bumps [prettier](https://github.com/prettier/prettier) from 1.19.1 to 2.0.4.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](prettier/prettier@1.19.1...2.0.4)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* Auot fix formatting after bumping prettier

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Stefan Buck <[email protected]>
  • Loading branch information
dependabot-preview[bot] and stefanbuck committed Apr 12, 2020
1 parent efa2efe commit ad77c34
Show file tree
Hide file tree
Showing 46 changed files with 92 additions and 107 deletions.
2 changes: 1 addition & 1 deletion _jestsetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ global.chrome.runtime = {
chrome.runtime.id = 'fake-chrome';

global.fixture = {
load: file => {
load: (file) => {
const fullPath = path.join(__dirname, file);
const fixture = fs.readFileSync(fullPath);
document.body.innerHTML = fixture.toString();
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = api => {
module.exports = (api) => {
const isTest = api.env('test');

const plugins = [
Expand Down
2 changes: 1 addition & 1 deletion e2e/automated.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('End to End tests', () => {
]);

try {
const authError = await page.$eval('#login .flash-error', el =>
const authError = await page.$eval('#login .flash-error', (el) =>
el.textContent.trim(),
);
throw new Error(authError);
Expand Down
2 changes: 1 addition & 1 deletion e2e/generate-fixtures-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function readContent(files) {
const readFile = util.promisify(fs.readFile);
const mapLimit = util.promisify(async.mapLimit);

return mapLimit(files, 10, async file => {
return mapLimit(files, 10, async (file) => {
const content = await readFile(file, 'utf8');

return {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"jest-fetch-mock": "^3.0.2",
"jest-puppeteer": "^4.2.0",
"json-loader": "^0.5.7",
"prettier": "^1.18.2",
"prettier": "^2.0.4",
"puppeteer": "^2.0.0",
"recursive-readdir": "^2.2.2",
"sinon": "^9.0.0",
Expand Down
28 changes: 7 additions & 21 deletions packages/blob-reader/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ function getPath(el) {
}

let ret = $(rootSelector)
.filter(function() {
return (
$(this)
.text()
.trim() === 'View file'
);
.filter(function () {
return $(this).text().trim() === 'View file';
})
.attr('href');

Expand All @@ -79,9 +75,7 @@ function getPath(el) {

// When current page is a gist, get path from blob name
if (!ret && isGist()) {
ret = $('.gist-blob-name', el.parentElement)
.text()
.trim();
ret = $('.gist-blob-name', el.parentElement).text().trim();
if (ret && !ret.startsWith('/')) {
ret = `/${ret}`;
}
Expand Down Expand Up @@ -123,17 +117,11 @@ function getLineNumber(el) {
}

// split diff view
let lineNumber = $(el)
.closest('td')
.prev()
.data('line-number');
let lineNumber = $(el).closest('td').prev().data('line-number');

// unified diff view
if (!lineNumber) {
lineNumber = $(el)
.closest('tr')
.find('td')
.data('line-number');
lineNumber = $(el).closest('tr').find('td').data('line-number');
}

if (lineNumber) {
Expand All @@ -146,9 +134,7 @@ function getLineNumber(el) {
}

function diffMetaInformation(el) {
const td = $(el)
.closest('td')
.get(0);
const td = $(el).closest('td').get(0);

// Blob view
if (td.classList.contains('js-file-line')) {
Expand Down Expand Up @@ -221,7 +207,7 @@ function readLines(el) {

return getBlobCodeInner(el)
.map(readLine)
.filter(line => !!line);
.filter((line) => !!line);
}

export { getPath, getBlobWrapper, readLines, getParentSha, isGist };
4 changes: 2 additions & 2 deletions packages/blob-reader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function parseBlob(el) {
lines.filter(({ side }) => ['left', 'right'].includes(side)).length > 0;

if (isDiff) {
const diffLineFilter = type => ({ side, ...rest }) => {
const diffLineFilter = (type) => ({ side, ...rest }) => {
if ([type, 'context'].includes(side)) {
return { ...rest };
}
Expand Down Expand Up @@ -60,7 +60,7 @@ export default class BlobReader {
read(rootElement) {
return [].concat(
...getBlobWrapper(rootElement)
.map(el => {
.map((el) => {
return parseBlob(el);
})
.filter(Boolean),
Expand Down
6 changes: 3 additions & 3 deletions packages/core/__tests__/load-plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('load-plugins', () => {

assert(Array.isArray(plugins));

plugins.forEach(plugin => {
plugins.forEach((plugin) => {
assert.equal(typeof plugin, 'object');
assert(plugin.name);
assert(plugin.resolve);
Expand All @@ -28,11 +28,11 @@ describe('load-plugins', () => {
);
});

const presets = Object.values(loadPlugins).map(plugin =>
const presets = Object.values(loadPlugins).map((plugin) =>
plugin.getPattern(),
);
for (const [lang, value] of Object.entries(presets)) {
value.githubClasses.forEach(className => {
value.githubClasses.forEach((className) => {
if (!className.includes('highlight')) {
return;
}
Expand Down
14 changes: 7 additions & 7 deletions packages/core/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function run(rootElement) {
}

matches = matches
.filter(result => result !== undefined)
.filter((result) => result !== undefined)
.map(({ link, urls }) => {
const urlsSorted = helperSortUrls(urls, link.innerText);

Expand All @@ -60,7 +60,7 @@ function watch(viewSpy) {
...document.getElementsByClassName('js-diff-progressive-container'),
];

elements.forEach(element => {
elements.forEach((element) => {
viewSpy.observe(element, {
childList: true,
});
Expand All @@ -79,22 +79,22 @@ function init() {
run(document);
});

const viewSpy = new MutationObserver(mutationRecords => {
mutationRecords.forEach(mutationRecord => {
const viewSpy = new MutationObserver((mutationRecords) => {
mutationRecords.forEach((mutationRecord) => {
if (mutationRecord.addedNodes.length > 0) {
run(mutationRecord.target);
watch(viewSpy);
}
});
});

document.body.addEventListener('click', event => {
document.body.addEventListener('click', (event) => {
if (!event.target.closest('.js-expandable-line')) {
return;
}

const expandDiffObserver = new MutationObserver(mutationRecords => {
mutationRecords.forEach(mutationRecord => {
const expandDiffObserver = new MutationObserver((mutationRecords) => {
mutationRecords.forEach((mutationRecord) => {
if (mutationRecord.addedNodes.length > 0) {
expandDiffObserver.disconnect();
run(mutationRecord.target.closest('.js-file'));
Expand Down
2 changes: 1 addition & 1 deletion packages/core/debug-mode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function(enable = false) {
export default function (enable = false) {
if (!enable) {
return;
}
Expand Down
10 changes: 5 additions & 5 deletions packages/core/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function injectLiveDemoUrl(url) {

function groupMatchesByType(matches) {
const flattenUrls = [].concat(
...matches.map(match =>
match.urls.map(url => ({
...matches.map((match) =>
match.urls.map((url) => ({
...url,
link: match.link,
})),
Expand Down Expand Up @@ -79,7 +79,7 @@ function insertLinks({
break;
}
} else if (item.type === 'github-search') {
const allMatches = githubTree.filter(path =>
const allMatches = githubTree.filter((path) =>
path.endsWith(item.target),
);

Expand Down Expand Up @@ -118,7 +118,7 @@ function insertLinks({
});
}

export default async function(matches) {
export default async function (matches) {
const { apiItems, internalItems, trustedItems } = groupMatchesByType(matches);

let octolinkerApiResponsePromise = [];
Expand All @@ -139,7 +139,7 @@ export default async function(matches) {
}
}

trustedItems.forEach(item => {
trustedItems.forEach((item) => {
item.link.href = item.target;
});

Expand Down
4 changes: 2 additions & 2 deletions packages/core/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const pkgVersion = require('./package.json')
.slice(0, -1)
.join('.');

document.body.addEventListener('click', event => {
document.body.addEventListener('click', (event) => {
if (
event.target.classList.contains('js-hide-new-version') ||
event.target.classList.contains('js-flash-close-update-info')
Expand All @@ -19,7 +19,7 @@ document.body.addEventListener('click', event => {
}
});

export default async function() {
export default async function () {
const showUpdateNotification = storage.get('showUpdateNotification');

if (!showUpdateNotification) {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/plugin-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ function updatePluginsForKey(lookup, plugin, key) {
function buildPluginCache(plugins) {
const lookup = new Map();

plugins.forEach(plugin => {
plugin.getPattern().pathRegexes.forEach(pattern => {
plugins.forEach((plugin) => {
plugin.getPattern().pathRegexes.forEach((pattern) => {
updatePluginsForKey(lookup, plugin, pattern);
});

if (!plugin.getPattern().githubClasses) {
return;
}

plugin.getPattern().githubClasses.forEach(githubClass => {
plugin.getPattern().githubClasses.forEach((githubClass) => {
updatePluginsForKey(lookup, plugin, githubClass);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/utils/array.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function flattenAndCompact(arr) {
return [].concat(...arr).filter(item => !!item);
return [].concat(...arr).filter((item) => !!item);
}
2 changes: 1 addition & 1 deletion packages/helper-github-api/fetch-tree.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as storage from '@octolinker/helper-settings';
import rateLimitNotification from '@octolinker/ratelimit-notification';

export default async function({ user, repo, branch }) {
export default async function ({ user, repo, branch }) {
const token = storage.get('githubToken');

const headers = {
Expand Down
4 changes: 2 additions & 2 deletions packages/helper-grammar-regex-collection/go.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ function singleImportRegExpBuilder(input) {
});
}

export default function(blobSource) {
export default function (blobSource) {
return []
.concat(
multiImportRegExpBuilder(blobSource),
singleImportRegExpBuilder(blobSource),
multiRequireRegExpBuilder(blobSource),
singleRequireRegExpBuilder(blobSource),
)
.filter(item => !!item);
.filter((item) => !!item);
}
12 changes: 6 additions & 6 deletions packages/helper-grammar-regex-collection/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ const fixtures = {
};

function fixturesIterator(fixturesList, next) {
fixturesList.forEach(statement => {
fixturesList.forEach((statement) => {
const text = Array.isArray(statement) ? statement[0] : statement;
const expected = Array.isArray(statement) ? statement[1] : null;

Expand All @@ -544,7 +544,7 @@ function addModifiedLines(valid) {
}

describe('helper-grammar-regex-collection', () => {
Object.keys(fixtures).forEach(grammar => {
Object.keys(fixtures).forEach((grammar) => {
const spec = fixtures[grammar];

const { invalid } = spec;
Expand All @@ -568,10 +568,10 @@ describe('helper-grammar-regex-collection', () => {
let match;
let result = [];

regexes(text).forEach(regex => {
regexes(text).forEach((regex) => {
// eslint-disable-next-line
while (match = regex.exec(text)) {
result = result.concat(match.filter(item => !!item).slice(1));
result = result.concat(match.filter((item) => !!item).slice(1));
}
});

Expand All @@ -581,9 +581,9 @@ describe('helper-grammar-regex-collection', () => {
});

describe('invalid', () => {
fixturesIterator(invalid, text => {
fixturesIterator(invalid, (text) => {
it(text, () => {
regexes(text).forEach(regex => {
regexes(text).forEach((regex) => {
assert.equal(regex.exec(text), null);
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/helper-insert-link/get-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ function getLineFromPos(str, pos, matchPartial, matchValue) {
return lines ? lines.length + offset : offset;
}

export default function(blobString, regex) {
export default function (blobString, regex) {
const lines = blobString.split('\n');

return [...blobString.matchAll(regex)]
.map(match => {
.map((match) => {
const matchPartial = match[0];
const matchValue = match[1];

Expand Down
4 changes: 2 additions & 2 deletions packages/helper-insert-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function injectUrl(node, value, startOffset, endOffset) {

findAndReplaceDOMText(node, {
find: textMatch,
replace: portion => {
replace: (portion) => {
if (el || !portion.text.includes(value)) {
return portion.text;
}
Expand All @@ -46,7 +46,7 @@ function injectUrl(node, value, startOffset, endOffset) {
return el;
}

export default function(blob, regex, plugin, meta = {}) {
export default function (blob, regex, plugin, meta = {}) {
if (!blob) {
throw new Error('must be called with a blob');
}
Expand Down
Loading

0 comments on commit ad77c34

Please sign in to comment.