Unify the ESLint config (#3743)

Adding TypeScript to the frontend and a `.d.ts` file to `core` (see #3742) has multiplied out the different combinations of lint rules. ESLint has support for file-pattern-based overrides, which we've used in some places, but we've also maintained a separate eslintrc for `frontend/`.

This merges the config together, with the strategy of putting all the rules at the top level except where they conflict, and applying settings to exactly the files where they should apply.

This introduces a few new errors in the server but they are true positives – hoisting and lowercase class names – things we don't really need to be doing).
This commit is contained in:
Paul Melnikow
2019-07-22 15:06:38 -05:00
committed by GitHub
parent ecb85cef53
commit 28b8836595
9 changed files with 161 additions and 151 deletions

View File

@@ -22,14 +22,6 @@ function version(version) {
}
}
function downloadCount(downloads) {
return floorCount(downloads, 10, 100, 1000)
}
function coveragePercentage(percentage) {
return floorCount(percentage, 80, 90, 100)
}
function floorCount(value, yellow, yellowgreen, green) {
if (value <= 0) {
return 'red'
@@ -44,6 +36,14 @@ function floorCount(value, yellow, yellowgreen, green) {
}
}
function downloadCount(downloads) {
return floorCount(downloads, 10, 100, 1000)
}
function coveragePercentage(percentage) {
return floorCount(percentage, 80, 90, 100)
}
function letterScore(score) {
if (score === 'A') {
return 'brightgreen'

View File

@@ -2,7 +2,7 @@
const { schema, periodMap, BaseJsDelivrService } = require('./jsdelivr-base')
module.exports = class jsDelivrHitsGitHub extends BaseJsDelivrService {
module.exports = class JsDelivrHitsGitHub extends BaseJsDelivrService {
static get route() {
return {
base: 'jsdelivr/gh',

View File

@@ -2,7 +2,7 @@
const { schema, periodMap, BaseJsDelivrService } = require('./jsdelivr-base')
module.exports = class jsDelivrHitsNPM extends BaseJsDelivrService {
module.exports = class JsDelivrHitsNPM extends BaseJsDelivrService {
static get route() {
return {
base: 'jsdelivr/npm',

View File

@@ -11,6 +11,61 @@ const semver = require('semver')
const { addv } = require('./text-formatters')
const { version: versionColor } = require('./color-formatters')
function listCompare(a, b) {
const alen = a.length,
blen = b.length
for (let i = 0; i < alen; i++) {
if (a[i] < b[i]) {
return -1
} else if (a[i] > b[i]) {
return 1
}
}
return alen - blen
}
// Take string versions.
// -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
function compareDottedVersion(v1, v2) {
const parts1 = /([0-9.]+)(.*)$/.exec(v1)
const parts2 = /([0-9.]+)(.*)$/.exec(v2)
if (parts1 != null && parts2 != null) {
const numbers1 = parts1[1]
const numbers2 = parts2[1]
const distinguisher1 = parts1[2]
const distinguisher2 = parts2[2]
const numlist1 = numbers1.split('.').map(e => +e)
const numlist2 = numbers2.split('.').map(e => +e)
const cmp = listCompare(numlist1, numlist2)
if (cmp !== 0) {
return cmp
} else {
return distinguisher1 < distinguisher2
? -1
: distinguisher1 > distinguisher2
? 1
: 0
}
}
return v1 < v2 ? -1 : v1 > v2 ? 1 : 0
}
// Take a list of string versions.
// Return the latest, or undefined, if there are none.
function latestDottedVersion(versions) {
const len = versions.length
if (len === 0) {
return
}
let version = versions[0]
for (let i = 1; i < len; i++) {
if (compareDottedVersion(version, versions[i]) < 0) {
version = versions[i]
}
}
return version
}
// Given a list of versions (as strings), return the latest version.
// Return undefined if no version could be found.
function latest(versions, { pre = false } = {}) {
@@ -45,63 +100,6 @@ function latest(versions, { pre = false } = {}) {
return version
}
function listCompare(a, b) {
const alen = a.length,
blen = b.length
for (let i = 0; i < alen; i++) {
if (a[i] < b[i]) {
return -1
} else if (a[i] > b[i]) {
return 1
}
}
return alen - blen
}
// === Private helper functions ===
// Take a list of string versions.
// Return the latest, or undefined, if there are none.
function latestDottedVersion(versions) {
const len = versions.length
if (len === 0) {
return
}
let version = versions[0]
for (let i = 1; i < len; i++) {
if (compareDottedVersion(version, versions[i]) < 0) {
version = versions[i]
}
}
return version
}
// Take string versions.
// -1 if v1 < v2, 1 if v1 > v2, 0 otherwise.
function compareDottedVersion(v1, v2) {
const parts1 = /([0-9.]+)(.*)$/.exec(v1)
const parts2 = /([0-9.]+)(.*)$/.exec(v2)
if (parts1 != null && parts2 != null) {
const numbers1 = parts1[1]
const numbers2 = parts2[1]
const distinguisher1 = parts1[2]
const distinguisher2 = parts2[2]
const numlist1 = numbers1.split('.').map(e => +e)
const numlist2 = numbers2.split('.').map(e => +e)
const cmp = listCompare(numlist1, numlist2)
if (cmp !== 0) {
return cmp
} else {
return distinguisher1 < distinguisher2
? -1
: distinguisher1 > distinguisher2
? 1
: 0
}
}
return v1 < v2 ? -1 : v1 > v2 ? 1 : 0
}
// Slice the specified number of dotted parts from the given semver version.
// e.g. slice('2.4.7', 'minor') -> '2.4'
function slice(v, releaseType) {