Skip to content

Commit

Permalink
main.js now passes lint tests, after manually describing
Browse files Browse the repository at this point in the history
the locations of the globals it depends upon.

The next steps are Azgaar#1 to turn main.js into a built module
(no code change), and later import a module into it;
and Azgaar#2 to get the module we want to import to pass linting.
  • Loading branch information
sberney committed Feb 6, 2020
1 parent 6644ddf commit 72429ba
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 3 deletions.
112 changes: 109 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,107 @@
const libraryGlobals = {
"d3": "readonly"
const globals = {
libraries: {
d3: 'readonly',
$: 'readonly',
PriorityQueue: 'readonly',
ThreeD: 'readonly',
Delaunator: 'readonly',
},
indexSelectors: {
alertMessage: 'readonly',
culturesSet: 'readonly',
densityInput: 'readonly',
heightExponentInput: 'readonly',
hideLabels: 'readonly',
latitudeInput: 'readonly',
latitudeOutput: 'readonly',
mapSizeInput: 'readonly',
mapSizeOutput: 'readonly',
mapHeightInput: 'readonly',
mapWidthInput: 'readonly',
onloadMap: 'readonly',
optionsSeed: 'readonly',
populationRate: 'readonly',
precInput: 'readonly',
temperatureEquatorInput: 'readonly',
temperaturePoleInput: 'readonly',
templateInput: 'readonly',
urbanization: 'readonly',
},
modules: {
BurgsAndStates: 'readonly',
Cultures: 'readonly',
HeightmapGenerator: 'readonly',
Names: 'readonly',
OceanLayers: 'readonly',
Religions: 'readonly',
Rivers: 'readonly',
Voronoi: 'readonly',
},
saveAndLoad: {
uploadMap: 'readonly',
},
utilities: {
P: 'readonly',
rn: 'readonly',
ra: 'readonly',
rw: 'readonly',
rand: 'readonly',
round: 'readonly',
getAdjective: 'readonly',
getPackPolygon: 'readonly',
getBoundaryPoints: 'readonly',
getJitteredGrid: 'readonly',
capitalize: 'readonly',
biased: 'readonly',
debounce: 'readonly',
getNextId: 'readonly',
normalize: 'readonly',
gauss: 'readonly',
link: 'readonly',
isLand: 'readonly',
convertTemperature: 'readonly',
parseError: 'readonly',
ldb: 'readonly', // localStorageDB
},
uiEditors: {
clearLegend: 'readonly',
closeDialogs: 'readonly',
unfog: 'readonly',
},
uiGeneral: {
clearMainTip: 'readonly',
getFriendlyHeight: 'readonly',
locked: 'readonly',
tip: 'readonly',
},
uiLayers: {
applyPreset: 'readonly',
drawBorders: 'readonly',
drawCoordinates: 'readonly',
drawStates: 'readonly',
restoreLayers: 'readonly',
},
uiMeasurers: {
addRuler: 'readonly',
drawScaleBar: 'readonly',
},
uiOptions: {
applyMapSize: 'readonly',
applyStoredOptions: 'readonly',
randomizeOptions: 'readonly',
},
uiStyle: {
applyStyleOnLoad: 'readonly',
},
uiWorldConfigurator: {
editWorld: 'readonly',
},
};

// flattens nested objects in 'globals' into a single object of key-value pairs.
const allGlobals = Object.keys(globals).reduce((gs, key) => Object.assign(gs, globals[key]), {});


module.exports = {
"env": {
"browser": true,
Expand All @@ -11,11 +111,17 @@ module.exports = {
"globals": Object.assign({
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
}, libraryGlobals),
}, allGlobals),
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"prefer-const": "off",
"no-inner-declarations": "warn",
"no-unused-vars": "warn",
"one-var": "off",
"no-bitwise": "off",
"no-useless-escape": "warn"
}
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"eslint-config-i-am-meticulous": "^11.0.0"
},
"scripts": {
"lint-main": "eslint main.js",
"lint": "eslint modules",
"lint-fix": "eslint modules --fix",
"test": "echo \"no tests yet\""
Expand Down

0 comments on commit 72429ba

Please sign in to comment.