|
1 |
| -# NPM Template |
| 1 | +# eslint-plugin-dabapps |
2 | 2 |
|
3 |
| -**A template for creating npm modules** |
| 3 | +**Custom DabApps ESLint rules** |
4 | 4 |
|
5 |
| -[](https://travis-ci.com/dabapps/npm-template) |
6 |
| - |
7 |
| -This repository exists to allow use to easily create TypeScript npm modules. |
8 |
| - |
9 |
| -Simply following the instructions below to create a duplicate of the repository, update the names and links, install your dependencies and write a thing. |
10 |
| - |
11 |
| -## Duplicating the repository |
12 |
| - |
13 |
| -Create a bare clone of the repository. |
| 5 | +## Installation |
14 | 6 |
|
15 | 7 | ```shell
|
16 |
| -git clone --bare https://github.com/dabapps/npm-template.git |
| 8 | +npm i eslint-plugin-dabapps -D |
17 | 9 | ```
|
18 | 10 |
|
19 |
| -Mirror-push to the new repository. |
| 11 | +## Config |
20 | 12 |
|
21 |
| -```shell |
22 |
| -cd old-repository.git |
23 |
| -git push --mirror https://github.com/dabapps/new-repository.git |
24 |
| -``` |
| 13 | +Include the plugin in your eslint config: |
25 | 14 |
|
26 |
| -Remove the temporary local repository you created in step 1. |
27 |
| - |
28 |
| -```shell |
29 |
| -cd .. |
30 |
| -rm -rf npm-template.git |
| 15 | +```json |
| 16 | +{ |
| 17 | + "plugins": ["dabapps"] |
| 18 | +} |
31 | 19 | ```
|
32 | 20 |
|
33 |
| -Yey, boring stuff done. |
34 |
| - |
35 |
| -## Update names and urls |
36 |
| - |
37 |
| -Okay, I lied... |
38 |
| - |
39 |
| -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. |
40 |
| - |
41 |
| -Your project MUST be named with the format `@dabapps/project-name` so that it will be published within the dabapps scope. |
42 |
| - |
43 |
| -This will allow it to be installed and imported with `@dabapps/project-name`. |
44 |
| - |
45 |
| -Gotta catch 'em all! |
46 |
| - |
47 |
| -## A note about exporting things |
48 |
| - |
49 |
| -Your module should (unless you have reason otherwise) export all of your stuff at the root level. |
50 |
| - |
51 |
| -This means that things should be exported from the `src/ts/index.ts`. |
52 |
| - |
53 |
| -You'll notice that, in this repository, the `index.ts` exports the default from a sub-module as a named export. |
54 |
| - |
55 |
| -I would recommend this as a standard. |
56 |
| - |
57 |
| -## Configure NPM so you can install this locally |
58 |
| - |
59 |
| -You will need an `NPM_TOKEN` in your environment to install this module. |
60 |
| - |
61 |
| -The token is available in 1password. |
| 21 | +Enable some rules: |
62 | 22 |
|
63 |
| -You will need to add this to your `.bashrc`, or `.bash_profile`, or whatever. |
64 |
| - |
65 |
| -You may need to source this before installing the module e.g. |
66 |
| - |
67 |
| -```shell |
68 |
| -source ~/.bash_profile |
| 23 | +```json |
| 24 | +{ |
| 25 | + "rules": { |
| 26 | + "dabapps/no-relative-parent-import": 2 |
| 27 | + } |
| 28 | +} |
69 | 29 | ```
|
70 | 30 |
|
71 |
| -## Configuring NPM on another project so your module can be installed |
72 |
| - |
73 |
| -You'll notice a `.npmrc` in the root of this repository. NOT THE NVMRC. |
74 |
| - |
75 |
| -In order to install your module in another project, this file should be added to the root of that project. |
76 |
| - |
77 |
| -## Configure Travis so it can run your tests and or install this module |
78 |
| - |
79 |
| -Travis also needs an `NPM_TOKEN` in order to run your tests, and to install this module in other projects. |
80 |
| - |
81 |
| -Open up the project's setting e.g. https://travis-ci.com/dabapps/phils-awesome-project/settings |
82 |
| - |
83 |
| -Add the `NPM_TOKEN` from 1password as an environment variable. |
84 |
| - |
85 |
| -## RELEASE ALL THE THINGS! |
86 |
| - |
87 |
| -In order to release a new version of your module you need to create a GitHub release. |
88 |
| - |
89 |
| -BEERS! Okay, now I've got your attention, there's a very important thing to do first (before beers). |
90 |
| - |
91 |
| -You need to update the version of your module in your `package.json`. |
92 |
| - |
93 |
| -Please follow the semver specification for versioning your module. |
94 |
| - |
95 |
| -https://semver.org/ |
96 |
| - |
97 |
| -Modules should not be `1.0.0` or greater until they are complete. |
98 |
| - |
99 |
| -Modules in development, or that are very new, should use the minor version number for major changes until a major version is released. |
100 |
| - |
101 |
| -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 |
102 |
| - |
103 |
| -Here you can create a new release and Travis will automatically publish this to NPM. |
104 |
| - |
105 |
| -YOU MUST use the same version as in your `package.json` for the GitHub release, but prefixed with `v`. |
106 |
| - |
107 |
| -E.g. when you change your `package.json` version to `0.1.0` your GitHub release will be version `v0.1.0`. |
108 |
| - |
109 |
| -## Have a beer |
| 31 | +## Rules |
110 | 32 |
|
111 |
| -Well done. You've released your first DabApps node module! Grab yourself a beer. |
| 33 | +### no-relative-parent-import |
112 | 34 |
|
113 |
| -No, I don't care that it's only 8:30am. |
| 35 | +Prevents the use of `../relative-parent` imports. |
0 commit comments