Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit b3f1dde

Browse files
authored
Merge pull request #1 from dabapps/setup-and-no-relative-parent-import-rule
Setup and no-relative-parent-import rule
2 parents 473a670 + bc28f43 commit b3f1dde

26 files changed

+4932
-2735
lines changed

.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["dabapps/commonjs", "dabapps/node"]
3+
}

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ install:
77

88
script:
99
- npm test
10-
- npm run dist

@types/module-name/index.d.ts

-1
This file was deleted.

@types/typings.d.ts

-1
This file was deleted.

LICENSE.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright (c) 2020, DabApps
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
8+
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.
9+
10+
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.
11+
12+
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.

README.md

+20-98
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,35 @@
1-
# NPM Template
1+
# eslint-plugin-dabapps
22

3-
**A template for creating npm modules**
3+
**Custom DabApps ESLint rules**
44

5-
[![Build Status](https://travis-ci.com/dabapps/npm-template.svg?token=YbH3f6uroz5f5q8RxDdW&branch=master)](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
146

157
```shell
16-
git clone --bare https://github.com/dabapps/npm-template.git
8+
npm i eslint-plugin-dabapps -D
179
```
1810

19-
Mirror-push to the new repository.
11+
## Config
2012

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:
2514

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+
}
3119
```
3220

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:
6222

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+
}
6929
```
7030

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
11032

111-
Well done. You've released your first DabApps node module! Grab yourself a beer.
33+
### no-relative-parent-import
11234

113-
No, I don't care that it's only 8:30am.
35+
Prevents the use of `../relative-parent` imports.

examples/less/index.less

-1
This file was deleted.

examples/ts/index.ts

-3
This file was deleted.

examples/ts/tsconfig.json

-3
This file was deleted.

jest.config.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ module.exports = {
99
statements: 100,
1010
},
1111
},
12-
transform: {
13-
'^.+\\.tsx?$': 'ts-jest',
14-
},
15-
testRegex: '(/tests/.*|\\.(test|spec))\\.(ts|tsx|js|jsx)$',
16-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
12+
testRegex: '(/tests/.*|\\.(test|spec))\\.(js|jsx)$',
13+
moduleFileExtensions: ['js', 'jsx'],
1714
testPathIgnorePatterns: [helpersPattern],
1815
coveragePathIgnorePatterns: [helpersPattern],
1916
};

0 commit comments

Comments
 (0)