Skip to content

Instantly share code, notes, and snippets.

View nathan-hyan's full-sized avatar
🏠
Working from home

Exequiel Mleziva nathan-hyan

🏠
Working from home
View GitHub Profile
@nathan-hyan
nathan-hyan / .prettierrc
Last active June 28, 2024 17:51
How to install ESLint with the new flat configuration + Prettier without dying
{
"useTabs": false,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": true,
"trailingComma": "es5",
"endOfLine": "lf"
}
@nathan-hyan
nathan-hyan / useQuery.ts
Last active November 10, 2023 19:37
useQuery hook
import { useMemo } from 'react';
import { useLocation } from 'react-router-dom';
export function useQuery<T = Record<string, string | number | undefined>>() {
const { search } = useLocation();
const searchParams = useMemo(() => new URLSearchParams(search), [search]);
let result: Partial<T> = {} as T;
@nathan-hyan
nathan-hyan / flex_mixin.scss
Created August 15, 2023 14:46
Mixin for applying flex
@mixin flex($justify: center, $align: center, $direction: row) {
display: flex;
flex-direction: $direction;
align-items: $align;
justify-content: $justify;
}
@nathan-hyan
nathan-hyan / .stylelintrc.json
Last active January 16, 2023 18:09
Personal configuration for Stylelint
{
"defaultSeverity": "warning",
"extends": [
"stylelint-config-standard-scss",
"stylelint-config-prettier-scss",
"stylelint-config-rational-order"
],
"ignoreFiles": ["**/*.js", "**/*.ts", "**/*.tsx", "**/*.jsx", "**/*.html"],
"rules": {
"order/properties-order": [[], { "severity": "warning" }],
@nathan-hyan
nathan-hyan / index.test.tsx
Created November 29, 2022 14:50
localStorage test configuration
describe('testing localStorage', () => {
// This following snippet is from https://amitd.co/code/testing/spying-on-localstorage-in-jest
// Thank you so much Amit Dhamu for this implementation
jest.spyOn(Object.getPrototypeOf(window.localStorage), 'setItem');
Object.setPrototypeOf(window.localStorage.setItem, jest.fn());
it('saves to localStorage when clicked on button', () => {
render(<Component />);
@nathan-hyan
nathan-hyan / .eslintrc.js
Last active November 15, 2022 18:57
Current eslint config
module.exports = {
env: {
browser: true,
es2021: true,
jest: true, // Enable if testing is used on the project
},
extends: ['plugin:react/recommended', 'plugin:import/recommended', 'airbnb'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
@nathan-hyan
nathan-hyan / responsive_mixin.scss
Last active November 15, 2022 18:30
SCSS Responsive Mixin
// Shout out to YouTube channel "FrontDev" for this mixin
// that makes responsive so much easier to work with. You can check out the full tutorial on
// his video here: https://www.youtube.com/watch?v=1334bFDilgk&ab_channel=FrontDev
// Put your breakpoints here
$available-breakpoints: (
sm: 540px,
md: 768px,
lg: 1024px
);