nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 58d4e0565d020c70ecf39b720e183e7ce21668a9
parent c9376f49cf2060cfc38c84b2a6ffcc58d0724cf4
Author: Sergey Orlov <wladimirych@gmail.com>
Date:   Fri, 18 Sep 2020 14:47:28 +0200

eslint: force imports order for new code

Diffstat:
Meslint_rules/imports.js | 10+++++++++-
Meslint_rules/imports_relax_legacy.js | 1+
Mscripts/build.js | 12++++++------
Msrc/lib/leaflet.control.external-maps/index.js | 3++-
Msrc/lib/leaflet.control.search/index.js | 4++--
Msrc/lib/leaflet.control.search/providers/index.js | 4++--
Msrc/lib/leaflet.control.search/providers/links.js | 2+-
Msrc/lib/leaflet.control.search/providers/mapycz/index.js | 4++--
Msrc/lib/leaflet.control.search/providers/photon.js | 3++-
Msrc/lib/leaflet.map.sidebars/index.js | 1+
Msrc/secrets.js.template | 2+-
Mwebpack/webpack.config.js | 4++--
12 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/eslint_rules/imports.js b/eslint_rules/imports.js @@ -39,7 +39,15 @@ module.exports = { 'import/no-duplicates': 'error', // 'import/no-namespace': 'error', // checked, declined 'import/extensions': ['error', 'always', {js: 'never'}], - // 'import/order': 'error' // to be done + 'import/order': [ + 'error', + { + 'groups': [['builtin', 'external'], 'internal', ['parent', 'sibling', 'index'], 'object', 'unknown'], + 'pathGroups': [{pattern: '~/**', group: 'internal'}], + 'newlines-between': 'always', + 'alphabetize': {order: 'asc', caseInsensitive: true}, + }, + ], 'import/newline-after-import': 'error', // 'import/prefer-default-export': 'error', // checked, declined // 'import/max-dependencies': 'error', // checked, declined diff --git a/eslint_rules/imports_relax_legacy.js b/eslint_rules/imports_relax_legacy.js @@ -57,5 +57,6 @@ module.exports = { {missingExports: true, unusedExports: true, ignoreExports: [...topLevelFiles, ...filesMissingExport]}, ], 'import/no-unassigned-import': ['error', {allow: ['**/*.css', ...filesMissingExportForUnassigned]}], + 'import/order': 'off', }, }; diff --git a/scripts/build.js b/scripts/build.js @@ -1,17 +1,17 @@ 'use strict'; -const recursive = require('recursive-readdir'); -const fs = require('fs-extra'); -const gzipSize = require('gzip-size').sync; +const chalk = require('chalk'); const execSync = require('child_process').execSync; const filesize = require('filesize'); -const chalk = require('chalk'); +const fs = require('fs-extra'); +const gzipSize = require('gzip-size').sync; const path = require('path'); - -const errorExitStatus = 1; +const recursive = require('recursive-readdir'); const paths = require('../webpack/paths'); +const errorExitStatus = 1; + function getVersionFromGit() { const verCmd = 'echo -n ' + diff --git a/src/lib/leaflet.control.external-maps/index.js b/src/lib/leaflet.control.external-maps/index.js @@ -1,7 +1,8 @@ import L from 'leaflet'; -import {makeButton} from '~/lib/leaflet.control.commons'; + import Contextmenu from '~/lib/contextmenu'; import {ElevationProvider} from '~/lib/elevations'; +import {makeButton} from '~/lib/leaflet.control.commons'; import * as logging from '~/lib/logging'; import './style.css'; diff --git a/src/lib/leaflet.control.search/index.js b/src/lib/leaflet.control.search/index.js @@ -1,13 +1,13 @@ -import L from 'leaflet'; import ko from 'knockout'; +import L from 'leaflet'; import '~/lib/leaflet.placemark'; // eslint-disable-line import/no-unassigned-import import {stopContainerEvents} from '~/lib/leaflet.control.commons'; import '~/lib/leaflet.hashState/leaflet.hashState'; // eslint-disable-line import/no-unassigned-import +import controlTemplate from './control.html'; import {providers, magicProviders} from './providers'; import './style.css'; -import controlTemplate from './control.html'; ko.bindingHandlers.hasFocusNested = { init: function (element, valueAccessor) { diff --git a/src/lib/leaflet.control.search/providers/index.js b/src/lib/leaflet.control.search/providers/index.js @@ -1,7 +1,7 @@ +import {CoordinatesProvider} from './coordinates'; +import {LinksProvider} from './links'; import {MapyCzProvider} from './mapycz'; import {PhotonProvider} from './photon'; -import {LinksProvider} from './links'; -import {CoordinatesProvider} from './coordinates'; const providers = { mapycz: MapyCzProvider, diff --git a/src/lib/leaflet.control.search/providers/links.js b/src/lib/leaflet.control.search/providers/links.js @@ -1,7 +1,7 @@ import L from 'leaflet'; -import {fetch} from '~/lib/xhr-promise'; import urlViaCorsProxy from '~/lib/CORSProxy'; +import {fetch} from '~/lib/xhr-promise'; const MAX_ZOOM = 18; const MESSAGE_LINK_MALFORMED = 'Invalid coordinates in {name} link'; diff --git a/src/lib/leaflet.control.search/providers/mapycz/index.js b/src/lib/leaflet.control.search/providers/mapycz/index.js @@ -1,9 +1,9 @@ import L from 'leaflet'; -import {fetch} from '~/lib/xhr-promise'; + import * as logging from '~/lib/logging'; +import {fetch} from '~/lib/xhr-promise'; import {BaseProvider} from '../remoteBase'; - import _categories from './categories.csv'; import icons from './icons.json'; diff --git a/src/lib/leaflet.control.search/providers/photon.js b/src/lib/leaflet.control.search/providers/photon.js @@ -1,6 +1,7 @@ import L from 'leaflet'; -import {fetch} from '~/lib/xhr-promise'; + import * as logging from '~/lib/logging'; +import {fetch} from '~/lib/xhr-promise'; import {BaseProvider} from './remoteBase'; diff --git a/src/lib/leaflet.map.sidebars/index.js b/src/lib/leaflet.map.sidebars/index.js @@ -1,4 +1,5 @@ import L from 'leaflet'; + import './style.css'; import {onElementResize} from '~/lib/anyElementResizeEvent'; diff --git a/src/secrets.js.template b/src/secrets.js.template @@ -1,4 +1,4 @@ -secrets = { +const secrets = { bingKey: '0000000000000000000000000000000000000000000000000000000000000000', thunderforestKey: '00000000000000000000000000000000', sentryDSN: 'https://00000000000000000000000000000000@sentry.io/111111', diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js @@ -1,12 +1,12 @@ 'use strict'; -const Webpack = require('webpack'); const {CleanWebpackPlugin} = require('clean-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); -const StyleLintPlugin = require('stylelint-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const StyleLintPlugin = require('stylelint-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); +const Webpack = require('webpack'); const paths = require('./paths');