Skip to content

Commit

Permalink
chore: update eslint to v8 (#6491)
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-MikeS authored Apr 12, 2023
1 parent 2fe3171 commit 2d0075d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 9 deletions.
44 changes: 44 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:import/typescript',
],
rules: {
// https://eslint.org/docs/rules/
'no-fallthrough': 'off', // https://github.com/ionic-team/eslint-config/issues/7
'no-constant-condition': 'off',

// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/docs/rules
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-module-boundary-types': [
'error',
{ allowArgumentsExplicitlyTypedAsAny: true },
],

// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/docs/rules
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',

// https://github.com/benmosher/eslint-plugin-import
'import/first': 'error',
'import/order': [
'error',
{
'alphabetize': { order: 'asc', caseInsensitive: false },
'groups': [['builtin', 'external'], 'parent', ['sibling', 'index']],
'newlines-between': 'always',
},
],
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'import/no-mutable-exports': 'error',
},
};
2 changes: 1 addition & 1 deletion cli/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export async function checkAppName(
name: string,
): Promise<string | null> {
// We allow pretty much anything right now, have fun
if (!name || !name.length) {
if (!name?.length) {
return `Must provide an app name. For example: 'Spacebook'`;
}
return null;
Expand Down
4 changes: 2 additions & 2 deletions core/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const initBridge = (w: any): void => {
if (nav) {
nav.app = nav.app || {};
nav.app.exitApp = () => {
if (!cap.Plugins || !cap.Plugins.App) {
if (!cap.Plugins?.App) {
win.console.warn('App plugin not installed');
} else {
cap.nativeCallback('App', 'exitApp', {});
Expand All @@ -154,7 +154,7 @@ const initBridge = (w: any): void => {
} else if (eventName === 'backbutton' && cap.Plugins.App) {
// Add a dummy listener so Capacitor doesn't do the default
// back button action
if (!cap.Plugins || !cap.Plugins.App) {
if (!cap.Plugins?.App) {
win.console.warn('App plugin not installed');
} else {
cap.Plugins.App.addListener('backButton', () => {
Expand Down
2 changes: 1 addition & 1 deletion core/src/legacy/legacy-web-plugin-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const legacyRegisterWebPlugin = (
const config = webPlugin.config;
const Plugins = cap.Plugins;

if (!config || !config.name) {
if (!config?.name) {
// TODO: add link to upgrade guide
throw new Error(
`Capacitor WebPlugin is using the deprecated "registerWebPlugin()" function, but without the config. Please use "registerPlugin()" instead to register this web plugin."`,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
"version": "npm run sync-peer-dependencies"
},
"prettier": "@ionic/prettier-config",
"eslintConfig": {
"extends": "@ionic/eslint-config/recommended"
},
"devDependencies": {
"@ionic/eslint-config": "^0.3.0",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"@ionic/prettier-config": "~1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@types/tar": "^6.1.2",
"eslint": "~7.27.0",
"eslint": "~8.38.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.0",
"lerna": "^6.5.1",
"prettier": "~2.3.0",
"prettier-plugin-java": "~1.1.1",
Expand Down

0 comments on commit 2d0075d

Please sign in to comment.