Skip to content

Commit

Permalink
fix: simplify eslist
Browse files Browse the repository at this point in the history
- use expo’s eslint-config-universe preset
- simplify eslint configuration
- include changes
  • Loading branch information
tyrauber committed Jul 15, 2024
1 parent 86c1379 commit d035f81
Show file tree
Hide file tree
Showing 42 changed files with 951 additions and 936 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

172 changes: 5 additions & 167 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,169 +1,7 @@
module.exports = {
root: true,
parser: '@babel/eslint-parser',
plugins: ['react', 'react-native', 'fp', 'import', 'prettier', 'jest'],
env: {
jest: true,
},
settings: {
react: {
version: require('./package.json').dependencies.react,
pragma: 'React',
},
'import/resolver': {
node: {
extensions: ['.js', '.jsx'],
},
},
'import/ignore': ['react-native'],
parserOptions: {
ecmaFeatures: {
jsx: true,
modules: true,
},
},
},
globals: {
fetch: true,
FormData: true,
GeoJSON: true,
requestAnimationFrame: true,
cancelAnimationFrame: true,
WebSocket: true,
__DEV__: true,
window: true,
document: true,
navigator: true,
XMLSerializer: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:jest/recommended',
'prettier',
'@react-native',
"root": true,
"extends": [
'universe/native'
],
rules: {
'react/no-deprecated': 'warn',
'react/no-string-refs': 'warn',
'import/named': [2],
'import/no-named-default': [0],
'import/order': [
'error',
{
groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
},
],
'import/exports-last': [0],
'import/no-useless-path-segments': [2],
camelcase: [0],
'no-console': [0],
'import/prefer-default-export': 'off',
'jsx-a11y/href-no-hash': 'off',
'react/prop-types': [2],
quotes: [2, 'single'],
'eol-last': [0],
'no-continue': [1],
'class-methods-use-this': [0],
'no-bitwise': [1],
'prefer-destructuring': [1],
'consistent-return': [0],
'no-warning-comments': [1],
'no-mixed-requires': [0],
'no-return-assign': 0,
'no-underscore-dangle': [0],
'no-await-in-loop': 0,
'no-restricted-syntax': 0,
'no-use-before-define': ['error', {functions: false}],
'no-unused-expressions': ['error', {allowTaggedTemplates: true}],
'no-plusplus': ['error', {allowForLoopAfterthoughts: true}],
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'all',
bracketSpacing: false,
},
],
'fp/no-mutating-methods': 'warn',
},
overrides: [
// Match TypeScript Files
// =================================
{
files: ['**/*.{ts,tsx}'],

// Global ESLint Settings
// =================================
env: {
jest: true,
es6: true,
browser: true,
node: true,
},
globals: {
__DEV__: true,
element: true,
by: true,
waitFor: true, // detox e2e
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
react: {
version: 'detect', // React version. "detect" automatically picks the version you have installed.
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
// default to latest and warns if missing
// It will default to "detect" in the future
},
},

// Parser Settings
parser: '@typescript-eslint/parser',
parserOptions: {
project: [
'./tsconfig.json',
'./example/tsconfig.json',
'./plugin/src/__tests__/tsconfig.eslint.json',
],
// Lint with Type Information
// https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md
tsconfigRootDir: __dirname,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
},
sourceType: 'module',
},

// Extend Other Configs
// =================================
extends: [
'plugin:@typescript-eslint/recommended',
'@react-native',
'eslint:recommended',
'plugin:react/recommended',
'prettier',
],
plugins: ['react', 'react-hooks', '@typescript-eslint', 'prettier'],
rules: {
// turn these one to check where all the return types are missing
// and where arguments of functions are not typed
'@typescript-eslint/explicit-function-return-type': ['error'],
'@typescript-eslint/explicit-module-boundary-types': ['error'],
'@typescript-eslint/no-unused-vars': ['error'],
'@typescript-eslint/no-explicit-any': 'off',
'no-unused-vars': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'react/prop-types': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
],
};
"ignorePatterns": ["node_modules/*", "*.js", "**/dist/*.js", "/plugin/build"]
}
14 changes: 7 additions & 7 deletions example/src/assets/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
declare module '*.jpg' {
const content: number
export default content
const content: number;
export default content;
}

declare module '*.png' {
const content: number
export default content
const content: number;
export default content;
}

declare module '*.json' {
const content: string
export default content
}
const content: string;
export default content;
}
3 changes: 1 addition & 2 deletions example/src/examples/Annotations/CustomCallout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, {FC, useState} from 'react';
import MapLibreGL, {SymbolLayerStyle} from '@maplibre/maplibre-react-native';
import {Feature} from '@turf/helpers/dist/js';
import React, {FC, useState, ReactElement} from 'react';
import {View, Text, ViewStyle, StyleProp, TextStyle} from 'react-native';
import {ReactElement} from 'react';

import exampleIcon from '../../assets/pin.png';
import sheet from '../../styles/sheet';
Expand Down
2 changes: 1 addition & 1 deletion example/src/examples/Map/ShowMap.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MapLibreGL from '@maplibre/maplibre-react-native';
import React, {useState, useEffect, ReactElement} from 'react';
import {Alert} from 'react-native';
import MapLibreGL from '@maplibre/maplibre-react-native';

import sheet from '../../styles/sheet';
import {onSortOptions} from '../../utils';
Expand Down
2 changes: 1 addition & 1 deletion example/src/examples/Map/ShowMapLocalStyle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MapLibreGL from '@maplibre/maplibre-react-native';
import React, {FC, useEffect} from 'react';
import {Alert} from 'react-native';
import MapLibreGL from '@maplibre/maplibre-react-native';

import sheet from '../../styles/sheet';
import Page from '../common/Page';
Expand Down
9 changes: 4 additions & 5 deletions example/src/examples/common/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {useNavigation, useRoute} from '@react-navigation/native';
import React, {ReactElement} from 'react';
import {View} from 'react-native';
import {useNavigation, useRoute} from '@react-navigation/native';

import sheet from '../../styles/sheet';
import colors from '../../styles/colors';

import MapHeader from './MapHeader';
import colors from '../../styles/colors';
import sheet from '../../styles/sheet';

interface PageProps {
children: ReactElement | ReactElement[];
Expand All @@ -21,7 +20,7 @@ const Page = ({children}: PageProps): ReactElement => {
<MapHeader
backgroundColor={colors.primary.pink}
statusBarColor={colors.primary.pinkDark}
statusBarTextTheme={'light-content'}
statusBarTextTheme="light-content"
label={label}
onBack={(): void => navigation.goBack()}
/>
Expand Down
4 changes: 2 additions & 2 deletions javascript/Maplibre.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {UserTrackingMode} from './components/Camera';

export * from './MLNModule';
export {
default as Camera,
Expand Down Expand Up @@ -58,8 +60,6 @@ export type {
LightLayerStyleProps as LightLayerStyle,
} from './utils/MaplibreStyles';

import {UserTrackingMode} from './components/Camera';

// types:
export enum StyleURL {
Default = 'https://demotiles.maplibre.org/style.json',
Expand Down
4 changes: 2 additions & 2 deletions javascript/components/BackgroundLayer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import {NativeModules, requireNativeComponent} from 'react-native';

import {BackgroundLayerStyleProps} from '../utils/MaplibreStyles';
import BaseProps from '../types/BaseProps';
import useAbstractLayer, {
BaseLayerProps,
NativeBaseProps,
} from '../hooks/useAbstractLayer';
import BaseProps from '../types/BaseProps';
import {BackgroundLayerStyleProps} from '../utils/MaplibreStyles';

const MapLibreGL = NativeModules.MLNModule;

Expand Down
8 changes: 4 additions & 4 deletions javascript/components/Camera.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {NativeModules, requireNativeComponent, ViewProps} from 'react-native';
import React, {
memo,
RefObject,
Expand All @@ -8,11 +7,12 @@ import React, {
useRef,
useCallback,
} from 'react';
import {NativeModules, requireNativeComponent, ViewProps} from 'react-native';

import {useNativeRef} from '../hooks/useNativeRef';
import {MaplibreGLEvent} from '../types';
import {toJSONString} from '../utils';
import * as geoUtils from '../utils/geoUtils';
import {MaplibreGLEvent} from '../types';
import {useNativeRef} from '../hooks/useNativeRef';

const MapLibreGL = NativeModules.MLNModule;

Expand Down Expand Up @@ -520,7 +520,7 @@ const Camera = memo(
sw: southWestCoordinates,
},
padding: pad,
animationDuration: animationDuration,
animationDuration,
animationMode: 'easeTo',
});
};
Expand Down
4 changes: 2 additions & 2 deletions javascript/components/CircleLayer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import {NativeModules, requireNativeComponent} from 'react-native';

import {CircleLayerStyleProps} from '../utils/MaplibreStyles';
import BaseProps from '../types/BaseProps';
import useAbstractLayer, {
BaseLayerProps,
NativeBaseProps,
} from '../hooks/useAbstractLayer';
import BaseProps from '../types/BaseProps';
import {CircleLayerStyleProps} from '../utils/MaplibreStyles';

const MapLibreGL = NativeModules.MLNModule;

Expand Down
4 changes: 2 additions & 2 deletions javascript/components/FillExtrusionLayer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import {NativeModules, requireNativeComponent} from 'react-native';

import {FillExtrusionLayerStyleProps} from '../utils/MaplibreStyles';
import BaseProps from '../types/BaseProps';
import useAbstractLayer, {
BaseLayerProps,
NativeBaseProps,
} from '../hooks/useAbstractLayer';
import BaseProps from '../types/BaseProps';
import {FillExtrusionLayerStyleProps} from '../utils/MaplibreStyles';

const MapLibreGL = NativeModules.MLNModule;

Expand Down
4 changes: 2 additions & 2 deletions javascript/components/FillLayer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import {NativeModules, requireNativeComponent} from 'react-native';

import {FillLayerStyleProps} from '../utils/MaplibreStyles';
import BaseProps from '../types/BaseProps';
import useAbstractLayer, {
BaseLayerProps,
NativeBaseProps,
} from '../hooks/useAbstractLayer';
import BaseProps from '../types/BaseProps';
import {FillLayerStyleProps} from '../utils/MaplibreStyles';

const MapLibreGL = NativeModules.MLNModule;

Expand Down
5 changes: 2 additions & 3 deletions javascript/components/HeadingIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, {ReactElement} from 'react';

import BaseProps from '../types/BaseProps';
import headingIcon from '../../assets/heading.png';

import SymbolLayer from './SymbolLayer';
import headingIcon from '../../assets/heading.png';
import BaseProps from '../types/BaseProps';

const style = {
iconImage: headingIcon,
Expand Down
4 changes: 2 additions & 2 deletions javascript/components/HeatmapLayer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import {NativeModules, requireNativeComponent} from 'react-native';

import {HeatmapLayerStyleProps} from '../utils/MaplibreStyles';
import BaseProps from '../types/BaseProps';
import useAbstractLayer, {
BaseLayerProps,
NativeBaseProps,
} from '../hooks/useAbstractLayer';
import BaseProps from '../types/BaseProps';
import {HeatmapLayerStyleProps} from '../utils/MaplibreStyles';

const MapLibreGL = NativeModules.MLNModule;

Expand Down
Loading

0 comments on commit d035f81

Please sign in to comment.