Skip to content

Commit

Permalink
Updated linting configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavberi committed Sep 21, 2024
1 parent 0d7ef2e commit 54ec3a3
Show file tree
Hide file tree
Showing 15 changed files with 251 additions and 235 deletions.
20 changes: 18 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"google"
],
"ignorePatterns": [
"lib/",
"Example/"
"lib/"
// "Example/"
],
"globals": {
"Atomics": "readonly",
Expand All @@ -33,6 +33,22 @@
"FunctionDeclaration": false
}
}
],
"quotes": [
"error",
"double"
],
"comma-dangle": [
"error",
"always-multiline"
],
"indent": [
"error",
2
],
"object-curly-spacing": [
"error",
"always"
]
},
"settings": {
Expand Down
2 changes: 1 addition & 1 deletion Example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
presets: ["babel-preset-expo"],
};
};
8 changes: 4 additions & 4 deletions Example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");

const defaultConfig = getDefaultConfig(__dirname);

const {
resolver: { sourceExts, assetExts },
resolver: { assetExts },
} = getDefaultConfig(__dirname);

const config = {
Expand All @@ -16,9 +16,9 @@ const config = {
// }),
// },
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
assetExts: assetExts.filter((ext) => ext !== "svg"),
// sourceExts: [...sourceExts, 'svg'],
},
};

module.exports = mergeConfig(defaultConfig, config);
module.exports = mergeConfig(defaultConfig, config);
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [['@babel/plugin-transform-private-methods', {loose: true}]],
presets: ["module:metro-react-native-babel-preset"],
plugins: [["@babel/plugin-transform-private-methods", { loose: true }]],
};
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
extends: ["@commitlint/config-conventional"],
};
80 changes: 40 additions & 40 deletions src/__tests__/UserAvatar.test.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
/* eslint max-len: 0 */

import 'react-native';
import {Image} from 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import "react-native";
import { Image } from "react-native";
import React from "react";
import renderer from "react-test-renderer";

import UserAvatar from '../';
import UserAvatar from "../";

it('should render <UserAvatar /> without anything, default values', () => {
it("should render <UserAvatar /> without anything, default values", () => {
const tree = renderer.create(<UserAvatar />).toJSON();
expect(tree).toMatchSnapshot();
});

it('should render <UserAvatar /> with name, without src, default values', () => {
it("should render <UserAvatar /> with name, without src, default values", () => {
const tree = renderer.create(<UserAvatar name="Bhav Beri" />).toJSON();
expect(tree).toMatchSnapshot();
});

it('should render <UserAvatar /> with name, with src', () => {
it("should render <UserAvatar /> with name, with src", () => {
jest.useFakeTimers();
const tree = renderer
.create(
<UserAvatar
name="Bhav Beri"
src="https://dummyimage.com/100x100/000/fff"
/>,
)
.toJSON();
.create(
<UserAvatar
name="Bhav Beri"
src="https://dummyimage.com/100x100/000/fff"
/>,
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it('should render <UserAvatar /> with name, if src is not an image', () => {
it("should render <UserAvatar /> with name, if src is not an image", () => {
jest.useFakeTimers();
const tree = renderer
.create(
<UserAvatar
name="Bhav Beri"
src="https://github.com/bhavberi/react-native-user-avatar/"
/>,
)
.toJSON();
.create(
<UserAvatar
name="Bhav Beri"
src="https://github.com/bhavberi/react-native-user-avatar/"
/>,
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it('should warn because size is not number', () => {
it("should warn because size is not number", () => {
const tree = renderer
.create(<UserAvatar name="Bhav Beri" size="100" />)
.toJSON();
.create(<UserAvatar name="Bhav Beri" size="100" />)
.toJSON();
expect(tree).toMatchSnapshot();
});

it('should render <UserAvatar /> with name, with custom component', () => {
it("should render <UserAvatar /> with name, with custom component", () => {
const tree = renderer
.create(
<UserAvatar
name="Bhav Beri"
component={
<Image
source={require('./images/rn_logo.png')}
style={{width: 50, height: 50}}
/>
}
size={100}
/>,
)
.toJSON();
.create(
<UserAvatar
name="Bhav Beri"
component={
<Image
source={require("./images/rn_logo.png")}
style={{ width: 50, height: 50 }}
/>
}
size={100}
/>,
)
.toJSON();
expect(tree).toMatchSnapshot();
});
Loading

0 comments on commit 54ec3a3

Please sign in to comment.