This repository has been archived by the owner on Mar 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dabapps/setup-and-no-relative-parent-impor…
…t-rule Setup and no-relative-parent-import rule
- Loading branch information
Showing
26 changed files
with
4,932 additions
and
2,735 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["dabapps/commonjs", "dabapps/node"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ install: | |
|
||
script: | ||
- npm test | ||
- npm run dist |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Copyright (c) 2020, DabApps | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,35 @@ | ||
# NPM Template | ||
# eslint-plugin-dabapps | ||
|
||
**A template for creating npm modules** | ||
**Custom DabApps ESLint rules** | ||
|
||
[](https://travis-ci.com/dabapps/npm-template) | ||
|
||
This repository exists to allow use to easily create TypeScript npm modules. | ||
|
||
Simply following the instructions below to create a duplicate of the repository, update the names and links, install your dependencies and write a thing. | ||
|
||
## Duplicating the repository | ||
|
||
Create a bare clone of the repository. | ||
## Installation | ||
|
||
```shell | ||
git clone --bare https://github.com/dabapps/npm-template.git | ||
npm i eslint-plugin-dabapps -D | ||
``` | ||
|
||
Mirror-push to the new repository. | ||
## Config | ||
|
||
```shell | ||
cd old-repository.git | ||
git push --mirror https://github.com/dabapps/new-repository.git | ||
``` | ||
Include the plugin in your eslint config: | ||
|
||
Remove the temporary local repository you created in step 1. | ||
|
||
```shell | ||
cd .. | ||
rm -rf npm-template.git | ||
```json | ||
{ | ||
"plugins": ["dabapps"] | ||
} | ||
``` | ||
|
||
Yey, boring stuff done. | ||
|
||
## Update names and urls | ||
|
||
Okay, I lied... | ||
|
||
There are a bunch of places on the `package.json`, `README.md`, etc that should be updated with your project's name, description, GitHub urls, Travis status badge etc. | ||
|
||
Your project MUST be named with the format `@dabapps/project-name` so that it will be published within the dabapps scope. | ||
|
||
This will allow it to be installed and imported with `@dabapps/project-name`. | ||
|
||
Gotta catch 'em all! | ||
|
||
## A note about exporting things | ||
|
||
Your module should (unless you have reason otherwise) export all of your stuff at the root level. | ||
|
||
This means that things should be exported from the `src/ts/index.ts`. | ||
|
||
You'll notice that, in this repository, the `index.ts` exports the default from a sub-module as a named export. | ||
|
||
I would recommend this as a standard. | ||
|
||
## Configure NPM so you can install this locally | ||
|
||
You will need an `NPM_TOKEN` in your environment to install this module. | ||
|
||
The token is available in 1password. | ||
Enable some rules: | ||
|
||
You will need to add this to your `.bashrc`, or `.bash_profile`, or whatever. | ||
|
||
You may need to source this before installing the module e.g. | ||
|
||
```shell | ||
source ~/.bash_profile | ||
```json | ||
{ | ||
"rules": { | ||
"dabapps/no-relative-parent-import": 2 | ||
} | ||
} | ||
``` | ||
|
||
## Configuring NPM on another project so your module can be installed | ||
|
||
You'll notice a `.npmrc` in the root of this repository. NOT THE NVMRC. | ||
|
||
In order to install your module in another project, this file should be added to the root of that project. | ||
|
||
## Configure Travis so it can run your tests and or install this module | ||
|
||
Travis also needs an `NPM_TOKEN` in order to run your tests, and to install this module in other projects. | ||
|
||
Open up the project's setting e.g. https://travis-ci.com/dabapps/phils-awesome-project/settings | ||
|
||
Add the `NPM_TOKEN` from 1password as an environment variable. | ||
|
||
## RELEASE ALL THE THINGS! | ||
|
||
In order to release a new version of your module you need to create a GitHub release. | ||
|
||
BEERS! Okay, now I've got your attention, there's a very important thing to do first (before beers). | ||
|
||
You need to update the version of your module in your `package.json`. | ||
|
||
Please follow the semver specification for versioning your module. | ||
|
||
https://semver.org/ | ||
|
||
Modules should not be `1.0.0` or greater until they are complete. | ||
|
||
Modules in development, or that are very new, should use the minor version number for major changes until a major version is released. | ||
|
||
Once you've updated your `package.json` you can head over to the releases page for your project e.g. https://github.com/dabapps/phils-terrible-project/releases | ||
|
||
Here you can create a new release and Travis will automatically publish this to NPM. | ||
|
||
YOU MUST use the same version as in your `package.json` for the GitHub release, but prefixed with `v`. | ||
|
||
E.g. when you change your `package.json` version to `0.1.0` your GitHub release will be version `v0.1.0`. | ||
|
||
## Have a beer | ||
## Rules | ||
|
||
Well done. You've released your first DabApps node module! Grab yourself a beer. | ||
### no-relative-parent-import | ||
|
||
No, I don't care that it's only 8:30am. | ||
Prevents the use of `../relative-parent` imports. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.