npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mrmartineau/scripts

v0.0.0

Published

Shareable configs

Downloads

4

Readme

⚡ @mrmartineau/scripts

Shareable config scripts

yarn add --dev @mrmartineau/scripts

Babel

To use this config, create an .babelrc file in the root of your package and add:

{
  "extends": "@mrmartineau/scripts/babel"
}

This babel config excludes some EcmaScript features, so you may need a polyfill for them:

https://polyfill.io/v3/polyfill.min.js?flags=gated&callback=init&features=default%2CArray.prototype.includes%2CArray.prototype.findIndex%2CArray.prototype.find%2CFunction.prototype.name

or

<script
  crossorigin="anonymous"
  src="https://polyfill.io/v3/polyfill.min.js?flags=gated&callback=init&features=default%2CArray.prototype.includes%2CArray.prototype.findIndex%2CArray.prototype.find%2CFunction.prototype.name"
></script>

ESLint

There are four eslint configs available:

  • Base: for general purpose usage
  • React: extends the base, for use with React
  • Typescript: extends the base, for use with Typescript
  • Typescript + React: extends the base, for use with Typescript and React

To use this config, create an .eslintrc file in the root of your package and reference one of the mentioned config options.

Base .eslintrc

{
  "extends": ["@mrmartineau/scripts/eslint"]
}

React .eslintrc

{
  "extends": ["@mrmartineau/scripts/eslint/react"]
}

Typescript .eslintrc

{
  "extends": ["@mrmartineau/scripts/eslint/typescript"]
}

Typescript and React .eslintrc

{
  "extends": ["@mrmartineau/scripts/eslint/typescript-react"]
}

Jest

This config assumes you're using jest, more specifically, that you use ts-jest.

To use this config, create an jest.config.js file in the root of your package and add:

Using the default config

module.exports = require('@mrmartineau/scripts/jest')

Overriding the default config

If you need to add or override this config, use this:

const jestConfig = require('@mrmartineau/scripts/jest')

module.exports = Object.assign(jestConfig, {
  // your overrides here
  testPathIgnorePatterns: ['/dist/', '/node_modules/']
})

Jest + Typescript

module.exports = require('@mrmartineau/scripts/jest/typescript')

Prettier

To use this config, create an .prettierrc.js file in the root of your package and add:

module.exports = require('@mrmartineau/scripts/prettier')

Rollup

At the moment, this config only provides the Rollup plugins that your package should use. See how it is used below:

To use this config, create an rollup.config.js file in the root of your package and add:

import { plugins } from '@mrmartineau/scripts/rollup'

import pkg from './package.json'

export default {
  input: 'src/index.ts',
  output: [
    {
      file: pkg.main,
      format: 'cjs',
      exports: 'named',
      sourcemap: true
    },
    {
      file: pkg.module,
      format: 'esm',
      exports: 'named',
      sourcemap: true
    }
  ],

  plugins
}

Add extra Rollup plugins

import { plugins } from '@mrmartineau/scripts/rollup'
import pkg from './package.json'

// Add this plugin
let graph = require('rollup-plugin-graph')
let graphOptions = { prune: true }

const newPlugins = plugins.push(graph(graphOptions))

export default {
  input: 'src/index.ts',
  output: [
    {
      file: pkg.main,
      format: 'cjs',
      exports: 'named',
      sourcemap: true
    },
    {
      file: pkg.module,
      format: 'esm',
      exports: 'named',
      sourcemap: true
    }
  ],

  plugins: newPlugins
}

Stylelint

To use this config, create an stylelint.config.js file in the root of your package and add:

module.exports = require('@mrmartineau/scripts/stylelint')

TSLint

There are two types of tslint configs available for use:

  • Base: for general purpose usage
  • React: enhanced for tslint, extends from the base one

To use this configuration you need to create a tslint.json file in the root of your package and reference one of the mentioned config options.

Base tslint.json

{
  "extends": ["@mrmartineau/scripts/tslint/base"]
}

React tslint.json

{
  "extends": ["@mrmartineau/scripts/tslint/react"]
}

TypeScript

tsconfig.json allows extensions via the extends key, but doesn't support module resolution (i.e. a node module), thus making it quite restrictive when it comes to referencing the path to a parent config file. Paths specified must be relative or absolute, absolute paths being of no use to us in the context of a shared code base.

Importing the shared config from ./node_modules/@mrmartineau/scripts is our only option.

Single package repo

To use this config, create an tsconfig.js file in the root of your repo and add:

{
  "extends": "./node_modules/@mrmartineau/scripts/tsconfig/tsconfig.base.json",
  ...
}

Mono repo

To use this config, create an tsconfig.js file in the root of your specific package (e.g. ./packages/?) and add:

{
  "extends": "../../node_modules/@mrmartineau/scripts/tsconfig/tsconfig.base.json",
  ...
}

Made by ZΛNDΞR ⚡