Giter Club home page Giter Club logo

web-configs's Introduction

Web Configs

License: MIT

This repository contains common configurations for building web apps at Shopify.

Usage

This repo is managed as a monorepo that is composed of many npm packages, where each package has its own README and documentation describing usage.

Package Index

Name NPM Size
babel-preset npm version npm bundle size (minified + gzip)
browserslist-config npm version npm bundle size (minified + gzip)
eslint-plugin npm version npm bundle size (minified + gzip)
images npm version npm bundle size (minified + gzip)
postcss-plugin npm version npm bundle size (minified + gzip)
prettier-config npm version npm bundle size (minified + gzip)
stylelint-plugin npm version npm bundle size (minified + gzip)
typescript-configs npm version npm bundle size (minified + gzip)

Contribution

This repository has a CLA-Bot running which will ask contributors to sign a Contributor License Agreement (CLA).

Shopify has also adopted a Code of Conduct that we expect contributors to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Ways to contribute

There are many ways to contribute, some of which are:

  • Filing bug reports
  • Requesting new features or packages via an issue
  • Improving the existing codebase by picking up an issue, improving tests, or furthering documentation

Development

Getting Started

# Shopify Employee
dev clone web-configs
dev up

# External Contributor - To start working on the codebase, first fork the repo, then clone it
git clone [email protected]:{your-username}/web-configs.git # replace {your-username} with your GitHub handle
yarn # install project dependencies
What is dev?

dev is a tool to standardize a small set of common tasks across all projects at Shopify. If you're wondering how to execute the dev commands as an external contributor, you can see where they are defined in this project's dev.yml file.

Testing your changes in a local project

To try out your changes in another locally cloned project, you can use yarn tophat <package-name-without-@shopify-prefix> <relative-path-to-project>. Using this command rather than yarn link will set up a watcher let you make changes without needing to rerun any commands.

Example: To test my changes to @shopify/react-form-state in my local project named my-project, I would run yarn tophat react-form-state ../path/to/my-project.

More usage instructions on the tophat command can be found here.

Documentation

If your change affects the public API of any packages within this repository (i.e. adding or changing arguments to a function, adding a new function, changing the return value, etc), please ensure the documentation is updated, and a changelog is added to reflect this. Documentation is in the README.md files of each package. If further documentation is needed please communicate via a GitHub issue.

Testing

The packages in this repository are used in mission-critical production scenarios. As such, we do not merge any untested code.

To run the full test suite, simply run dev test or yarn test.

Releasing

The release process currently involves some manual steps to complete. Once your PR has been merged, our team will orchestrate when to cut a new release.

Note Version numbers in package.json files should never be altered manually. This will be done via scripts as part of the release process.

License

MIT ยฉ Shopify, see LICENSE.md for details.

web-configs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web-configs's Issues

Send a periodic web foundation newsletter

The Polaris one seems great for calling out recent changes and sending appreciation for contributors.

Some ideas for topics:

  • New libraries and major versions
  • New documentation
  • Sewing kit updates
  • Team working on
  • Updates about Shopify Web
  • Thanks to contributors
  • Call for help
  • Pretty header like Polaris

Add `prefer-polaris-component` for components that use a `polaris-next` when a `polaris` version exists

https://astexplorer.net/#/gist/a546003dbca6f7d2f1e581a93c590de8/7d22d9807cf1dc033f941c5932a7104c28562f16

// Component exists in Polaris. Import Modal Stack Button List from @shopify/polaris (at 8:1)
   import {Modal, Button, List, Stack} from '@shopify/polaris-next';
// ^

// Component exists in Polaris. Import Modal from @shopify/polaris (at 9:1)
   import {Modal, NewComponent, NewComponent2} from '@shopify/polaris-next';
// ^

Determine testing strategy for client entrypoints

I think the main difficulty here will be that the entrypoints currently have side-effects on being required. I'm not sure of a good way to handle that in tests.

The possibility has also been discussed that we should instead just strive to make them substantially simpler (mostly by moving stuff into the app component).

Investigate better ways to share between server and client

Right now, anything that is shared between them needs to be in app/*. This is annoying for things like utility functions, which could easily be shared with the server. It might be that this is only a problem because these things should be shared packages, but we should make sure that will actually be enough.

Add tests

Linting tests are easy to write (although they can take a bit of time!). They are needed if we want to continue distributing this config at scale while iterating on it.

In case someone wants to give it a go, here's an example of a test suite here (using Jest): https://github.com/salesforce-ux/stylelint-config-slds

Rule to prevent potentially unmounted setState

This is a pattern we see fairly often that will always bite us at some point: setting state after an async operation:

doSomething().then(() => this.setState({done: true}));

// or

await doSomething();
this.setState({done: true});

This is because, unless the operation is completely synchronous, the delay of getting to the setState could be enough for the component to have unmounted. We should warn about these unless they are nested in some kind of condition (this is probably a trickier flow analysis-requiring rule to write).

Add rule to prevent relying on constructor.name

I've run in two issues recently where we were relying on constructor.name to do things. See:

The problem is that since the JS is uglified, it didn't work in production while it worked in dev shops.

We have 2 options:

  1. Setting Uglify keep_fnames option to true
  2. Write a custom linter to prevent that

I'm for option 2. What do you think people?

cc @lemonmade

[Proposal] Add principle document for type safety

I propose the following, based on our seeming consensus on the web foundations team around type-safety:

  1. Principle doc -> Compile-time over run-time failures
  2. Decision doc -> Use TypeScript as our type-safety mechanism for web projects

Thoughts? @TheMallen @lemonmade

I'd be happy to contribute a PR with these docs

Add marketing preset

Problem

Marketing projects use different babel presets as seen here. Right now, this needs to be copied to different marketing projects.

Proposal

Add marketing specific configuration to babel-preset-shopify.

Syntax

{
  "babel": {
    "presets": ["shopify/marketing"]
  }
}

or

{
  "babel": {
    "presets": [
      ["shopify/web", {"type": "marketing"}]
    ]
  }
}

Add a way of checking the "health" of sections

There could be a number of checks:

  • Move our ESLint overrides down to the section level (document why this is the standard), and check for excessive overrides
  • Associate errors to sections within Bugsnag
  • Presence of a file that outlines the owner of a particular section

'no-catch-shadow' rule is deprecated

We have code for

'no-catch-shadow': 'error'

in our eslint config, but this rule is deprecated and throws an obscure error when argless catch clauses are used.

Since we don't need to support IE8, perhaps we can ๐Ÿ”ฅ this one? cc @lemonmade

Document best practices for tests

  • Single assertion per test
  • When to use custom matchers
  • How to deal with global mocks
  • Factories versus beforeEach/ afterEach
  • Mocking subcomponents
  • Triggering props
  • Patterns to avoid testing state

Add PR template

We have to be thorough when upgrading dependencies. In order to democratize this process, we should provide a clear contribution path for those (like me) who wish to help.

  • Mention steps / requirements for dependency updates
  • Provide a template for each added rule (e.g. following the same outline as below)
- **eslint-config-prettier:** [`v2.6.0...v2.9.0`](https://github.com/prettier/eslint-config-prettier/compare/v2.6.0...v2.9.0)
  - Added: The [implicit-arrow-linebreak] rule
  - Added: The [react/jsx-one-expression-per-line] rule.
  - Added: The [lines-around-comment] rule (as a [special
    rule][lines-around-comment-special]).
  - Added: The [no-unexpected-multiline] rule (as a [special
    rule][no-unexpected-multiline-special]).
  • Require a changelog update
  • For important/breaking changes: require the upgrade path to be documented

Do you see anything else? cc @GoodForOneFare @ismail-syed @lemonmade

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.