diff --git a/.eslintrc.json b/.eslintrc.json index 3cbbb9c6d..287d5f1cc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,10 +1,14 @@ { + "extends": ["plugin:prettier/recommended"], "parser": "@typescript-eslint/parser", "parserOptions": { + "ecmaVersion": 2018, "sourceType": "module", - "ecmaVersion": 2015 + "parser": "@typescript-eslint/parser", + "project": "tsconfig.eslint.json", + "warnOnUnsupportedTypeScriptVersion": false }, - "plugins": ["@nativescript"], + "plugins": ["prettier", "@nativescript"], "rules": { "@nativescript/no-nativescript-angular-imports": "warn", "@nativescript/no-tns-core-modules-imports": "warn", diff --git a/packages/core/.eslintrc.json b/packages/core/.eslintrc.json index 9ef20ddd5..a11f3bf78 100644 --- a/packages/core/.eslintrc.json +++ b/packages/core/.eslintrc.json @@ -1,7 +1,7 @@ { - "extends": "../../.eslintrc", + "extends": "../../.eslintrc.json", "rules": {}, - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["!**/*", "**/node_modules/**/*", "**/__tests__/**/*"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/packages/core/accessibility/index.ios.ts b/packages/core/accessibility/index.ios.ts index 758a9fb11..74b1a4213 100644 --- a/packages/core/accessibility/index.ios.ts +++ b/packages/core/accessibility/index.ios.ts @@ -222,7 +222,6 @@ export function updateAccessibilityProperties(view: View): void { uiView.accessibilityTraits = a11yTraits; } -// eslint-disable-next-line @typescript-eslint/no-empty-function export const sendAccessibilityEvent = (): void => {}; export const updateContentDescription = (): string | null => null; diff --git a/packages/core/application/index.android.ts b/packages/core/application/index.android.ts index bcd29d0a2..5529bcfc5 100644 --- a/packages/core/application/index.android.ts +++ b/packages/core/application/index.android.ts @@ -4,7 +4,6 @@ import { AndroidActivityBackPressedEventData, AndroidActivityBundleEventData, An // TODO: explain why we need to this or remov it // Use requires to ensure order of imports is maintained -// eslint-disable-next-line @typescript-eslint/no-var-requires const appCommon = require('./application-common'); // First reexport so that app module is initialized. diff --git a/packages/core/application/index.ios.ts b/packages/core/application/index.ios.ts index cdaaf79c8..cf9e84751 100644 --- a/packages/core/application/index.ios.ts +++ b/packages/core/application/index.ios.ts @@ -4,7 +4,6 @@ import { ApplicationEventData, CssChangedEventData, LaunchEventData, LoadAppCSSE // TODO: explain why we need to this or remov it // Use requires to ensure order of imports is maintained -// eslint-disable-next-line @typescript-eslint/no-var-requires const { displayedEvent, exitEvent, getCssFileName, launchEvent, livesync, lowMemoryEvent, notify, on, orientationChanged, orientationChangedEvent, resumeEvent, setApplication, suspendEvent, systemAppearanceChanged, systemAppearanceChangedEvent } = require('./application-common'); // First reexport so that app module is initialized. export * from './application-common'; diff --git a/packages/core/config/config.interface.ts b/packages/core/config/config.interface.ts index e63c30b9a..81810dcf3 100644 --- a/packages/core/config/config.interface.ts +++ b/packages/core/config/config.interface.ts @@ -12,7 +12,6 @@ interface IConfigPlatform { discardUncaughtJsExceptions?: boolean; } -// eslint-disable-next-line @typescript-eslint/no-empty-interface interface IConfigIOS extends IConfigPlatform {} interface IConfigAndroid extends IConfigPlatform { diff --git a/packages/core/connectivity/index.android.ts b/packages/core/connectivity/index.android.ts index 0c9b29c56..b9e7ea544 100644 --- a/packages/core/connectivity/index.android.ts +++ b/packages/core/connectivity/index.android.ts @@ -30,7 +30,6 @@ function getActiveNetworkInfo(): android.net.NetworkInfo { } function getNetworkCapabilities() { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const connectivityManager: any = getConnectivityManager(); const network = connectivityManager.getActiveNetwork(); @@ -39,7 +38,6 @@ function getNetworkCapabilities() { return connectionType.none; } - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const NetworkCapabilities = (android as any).net.NetworkCapabilities; @@ -101,13 +99,11 @@ export function getConnectionType(): number { } function startMonitoringLegacy(connectionTypeChangedCallback) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars const onReceiveCallback = function onReceiveCallback(context: android.content.Context, intent: android.content.Intent) { const newConnectionType = getConnectionType(); connectionTypeChangedCallback(newConnectionType); }; const zoneCallback = zonedCallback(onReceiveCallback); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore androidApp.registerBroadcastReceiver(android.net.ConnectivityManager.CONNECTIVITY_ACTION, zoneCallback); } @@ -129,21 +125,18 @@ export function startMonitoring(connectionTypeChangedCallback: (newConnectionTyp if (!networkCallback) { @NativeClass class NetworkCallbackImpl extends ConnectivityManager.NetworkCallback { - // eslint-disable-next-line @typescript-eslint/no-unused-vars onAvailable(network: android.net.Network) { if (notifyCallback) { notifyCallback(); } } - // eslint-disable-next-line @typescript-eslint/no-unused-vars onCapabilitiesChanged(network: android.net.Network, networkCapabilities: android.net.NetworkCapabilities) { if (notifyCallback) { notifyCallback(); } } - // eslint-disable-next-line @typescript-eslint/no-unused-vars onLost(network) { if (notifyCallback) { notifyCallback(); @@ -169,7 +162,6 @@ export function startMonitoring(connectionTypeChangedCallback: (newConnectionTyp export function stopMonitoring(): void { if (android.os.Build.VERSION.SDK_INT >= 28) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const manager = getConnectivityManager(); if (manager && callback) { diff --git a/packages/core/debugger/devtools-elements.common.ts b/packages/core/debugger/devtools-elements.common.ts index 91171ff38..6859ab4c1 100644 --- a/packages/core/debugger/devtools-elements.common.ts +++ b/packages/core/debugger/devtools-elements.common.ts @@ -6,13 +6,11 @@ import { getNodeById } from './dom-node'; import { mainThreadify } from '../utils'; // Use lazy requires for core modules -// eslint-disable-next-line @typescript-eslint/no-var-requires const getAppRootView = () => require('../application').getRootView(); let unsetValue; function unsetViewValue(view, name) { if (!unsetValue) { - // eslint-disable-next-line @typescript-eslint/no-var-requires unsetValue = require('../ui/core/properties').unsetValue; } diff --git a/packages/core/debugger/dom-node.ts b/packages/core/debugger/dom-node.ts index d77d693b5..21d4909e9 100644 --- a/packages/core/debugger/dom-node.ts +++ b/packages/core/debugger/dom-node.ts @@ -14,11 +14,8 @@ function lazy(action: () => T): () => T { return () => _value || (_value = action()); } -// eslint-disable-next-line @typescript-eslint/no-var-requires const percentLengthToStringLazy = lazy<(length) => string>(() => require('../ui/styling/style-properties').PercentLength.convertToString); -// eslint-disable-next-line @typescript-eslint/no-var-requires const getSetPropertiesLazy = lazy<(view: ViewBase) => [string, any][]>(() => require('../ui/core/properties').getSetProperties); -// eslint-disable-next-line @typescript-eslint/no-var-requires const getComputedCssValuesLazy = lazy<(view: ViewBase) => [string, any][]>(() => require('../ui/core/properties').getComputedCssValues); export function registerInspectorEvents(inspector: InspectorEvents) { diff --git a/packages/core/debugger/webinspector-css.ios.ts b/packages/core/debugger/webinspector-css.ios.ts index 623cb8e2e..bd02bde6b 100644 --- a/packages/core/debugger/webinspector-css.ios.ts +++ b/packages/core/debugger/webinspector-css.ios.ts @@ -1,5 +1,4 @@ import * as inspectorCommandTypes from './InspectorBackendCommands.ios'; -// eslint-disable-next-line @typescript-eslint/no-var-requires const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands'); import * as debuggerDomains from '.'; diff --git a/packages/core/debugger/webinspector-dom.ios.ts b/packages/core/debugger/webinspector-dom.ios.ts index 7becd39d4..302d67a3b 100644 --- a/packages/core/debugger/webinspector-dom.ios.ts +++ b/packages/core/debugger/webinspector-dom.ios.ts @@ -1,5 +1,4 @@ import * as inspectorCommandTypes from './InspectorBackendCommands.ios'; -// eslint-disable-next-line @typescript-eslint/no-var-requires const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands'); import * as debuggerDomains from '.'; diff --git a/packages/core/debugger/webinspector-network.ios.ts b/packages/core/debugger/webinspector-network.ios.ts index 4cbf14932..c82d6ee78 100644 --- a/packages/core/debugger/webinspector-network.ios.ts +++ b/packages/core/debugger/webinspector-network.ios.ts @@ -1,5 +1,4 @@ import * as inspectorCommandTypes from './InspectorBackendCommands.ios'; -// eslint-disable-next-line @typescript-eslint/no-var-requires const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands'); import * as debuggerDomains from '.'; diff --git a/packages/core/globals/index.ts b/packages/core/globals/index.ts index cdc7645dd..95d6fc2b5 100644 --- a/packages/core/globals/index.ts +++ b/packages/core/globals/index.ts @@ -1,5 +1,4 @@ import * as tslibType from 'tslib'; -// eslint-disable-next-line @typescript-eslint/no-var-requires const tslib: typeof tslibType = require('tslib'); import { Observable } from '../data/observable'; import { trace as profilingTrace, time, uptime, level as profilingLevel } from '../profiling'; diff --git a/packages/core/profiling/index.ts b/packages/core/profiling/index.ts index 8bd3c1def..927dd18f2 100644 --- a/packages/core/profiling/index.ts +++ b/packages/core/profiling/index.ts @@ -160,7 +160,6 @@ export function enable(mode: InstrumentationMode = 'counters') { } try { - // eslint-disable-next-line @typescript-eslint/no-var-requires const appConfig = require('~/package.json'); if (appConfig && appConfig.profiling) { enable(appConfig.profiling); diff --git a/packages/core/ui/builder/component-builder/index.ts b/packages/core/ui/builder/component-builder/index.ts index 9ea01678d..14943cd36 100644 --- a/packages/core/ui/builder/component-builder/index.ts +++ b/packages/core/ui/builder/component-builder/index.ts @@ -95,7 +95,6 @@ const createComponentInstance = profile('createComponentInstance', (elementName: // Create instance of the component. instance = new instanceType(); } catch (ex) { - // eslint-disable-next-line @typescript-eslint/no-var-requires const debug: typeof debugModule = require('../../../utils/debug'); throw new debug.ScopeError(ex, "Module '" + (resolvedModuleName || elementName) + "' not found for element '" + (namespace ? namespace + ':' : '') + elementName + "'."); } diff --git a/packages/core/ui/core/bindable/index.ts b/packages/core/ui/core/bindable/index.ts index 640563737..316a18099 100644 --- a/packages/core/ui/core/bindable/index.ts +++ b/packages/core/ui/core/bindable/index.ts @@ -10,7 +10,6 @@ import { escapeRegexSymbols } from '../../../utils'; import { Trace } from '../../../trace'; import * as types from '../../../utils/types'; import * as bindableResources from './bindable-resources'; -// eslint-disable-next-line @typescript-eslint/no-var-requires const polymerExpressions = require('../../../js-libs/polymer-expressions'); import { PolymerExpressions } from '../../../js-libs/polymer-expressions'; diff --git a/packages/core/ui/date-picker/date-picker-common.ts b/packages/core/ui/date-picker/date-picker-common.ts index de41507b1..166e14059 100644 --- a/packages/core/ui/date-picker/date-picker-common.ts +++ b/packages/core/ui/date-picker/date-picker-common.ts @@ -67,4 +67,4 @@ export const iosPreferredDatePickerStyleProperty = new Property parseInt(v), }); -iosPreferredDatePickerStyleProperty.register(DatePickerBase); \ No newline at end of file +iosPreferredDatePickerStyleProperty.register(DatePickerBase); diff --git a/packages/core/ui/dialogs/dialogs-common.ts b/packages/core/ui/dialogs/dialogs-common.ts index 5fc160d16..03ee42171 100644 --- a/packages/core/ui/dialogs/dialogs-common.ts +++ b/packages/core/ui/dialogs/dialogs-common.ts @@ -268,7 +268,6 @@ let textField: View; export function getButtonColors(): { color: Color; backgroundColor: Color } { if (!button) { - // eslint-disable-next-line @typescript-eslint/no-var-requires const Button = require('../button').Button; button = new Button(); if (global.isIOS) { @@ -288,7 +287,6 @@ export function getButtonColors(): { color: Color; backgroundColor: Color } { export function getLabelColor(): Color { if (!label) { - // eslint-disable-next-line @typescript-eslint/no-var-requires const Label = require('../label').Label; label = new Label(); if (global.isIOS) { @@ -306,7 +304,6 @@ export function getLabelColor(): Color { export function getTextFieldColor(): Color { if (!textField) { - // eslint-disable-next-line @typescript-eslint/no-var-requires const TextField = require('../text-field').TextField; textField = new TextField(); if (global.isIOS) { diff --git a/packages/core/ui/frame/activity.android.ts b/packages/core/ui/frame/activity.android.ts index bbcc0c7d0..6c7fdead1 100644 --- a/packages/core/ui/frame/activity.android.ts +++ b/packages/core/ui/frame/activity.android.ts @@ -1,6 +1,5 @@ import '../../globals'; import { setActivityCallbacks, AndroidActivityCallbacks } from '.'; -// eslint-disable-next-line @typescript-eslint/no-var-requires const appModule = require('../../application'); /** diff --git a/packages/core/ui/frame/frame-common.ts b/packages/core/ui/frame/frame-common.ts index c4fe18679..64a82c684 100644 --- a/packages/core/ui/frame/frame-common.ts +++ b/packages/core/ui/frame/frame-common.ts @@ -289,7 +289,6 @@ export class FrameBase extends CustomLayoutView { } private isNestedWithin(parentFrameCandidate: FrameBase): boolean { - // eslint-disable-next-line @typescript-eslint/no-this-alias let frameAncestor: FrameBase = this; while (frameAncestor) { frameAncestor = getAncestor(frameAncestor, FrameBase); diff --git a/packages/core/ui/frame/index.android.ts b/packages/core/ui/frame/index.android.ts index ccfc3a918..ec8cf4671 100644 --- a/packages/core/ui/frame/index.android.ts +++ b/packages/core/ui/frame/index.android.ts @@ -39,7 +39,6 @@ let fragmentId = -1; export let moduleLoaded: boolean; if (global && global.__inspector) { - // eslint-disable-next-line @typescript-eslint/no-var-requires const devtools = require('../../debugger/devtools-elements'); devtools.attachDOMInspectorEventCallbacks(global.__inspector); devtools.attachDOMInspectorCommandCallbacks(global.__inspector); diff --git a/packages/core/ui/styling/style-scope.ts b/packages/core/ui/styling/style-scope.ts index 3107c8031..55b848362 100644 --- a/packages/core/ui/styling/style-scope.ts +++ b/packages/core/ui/styling/style-scope.ts @@ -33,7 +33,6 @@ function ensureCssAnimationParserModule() { let parser: 'rework' | 'nativescript' | 'css-tree' = 'css-tree'; try { - // eslint-disable-next-line @typescript-eslint/no-var-requires const appConfig = require('~/package.json'); if (appConfig) { if (appConfig.cssParser === 'rework') { diff --git a/packages/core/ui/time-picker/index.d.ts b/packages/core/ui/time-picker/index.d.ts index 4801589d6..a0c1273fe 100644 --- a/packages/core/ui/time-picker/index.d.ts +++ b/packages/core/ui/time-picker/index.d.ts @@ -77,4 +77,4 @@ export const minMinuteProperty: Property; export const timeProperty: Property; export const minuteIntervalProperty: Property; -export const iosPreferredDatePickerStyleProperty: Property; \ No newline at end of file +export const iosPreferredDatePickerStyleProperty: Property; diff --git a/packages/core/xml/index.ts b/packages/core/xml/index.ts index e4dbe775b..180c3469b 100644 --- a/packages/core/xml/index.ts +++ b/packages/core/xml/index.ts @@ -2,7 +2,6 @@ // https://github.com/NativeScript/nativescript-dev-webpack/issues/932 import * as definition from '.'; -// eslint-disable-next-line @typescript-eslint/no-var-requires const easysax = require('../js-libs/easysax'); import { EasySAXParser } from '../js-libs/easysax'; diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 000000000..5d8f21e45 --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "include": ["packages/**/*"] +}