-
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.
- Loading branch information
0 parents
commit 1dfdb90
Showing
19 changed files
with
11,756 additions
and
0 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,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
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,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "restricted", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
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,7 @@ | ||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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,25 @@ | ||
// @ts-check | ||
'use strict'; | ||
|
||
/** @type {import('eslint').ESLint.ConfigData} */ | ||
module.exports = { | ||
root: true, | ||
extends: ['eslint:recommended', 'plugin:eslint-plugin/recommended', 'plugin:node/recommended'], | ||
parserOptions: { | ||
ecmaVersion: 2022, | ||
sourceType: 'module', | ||
}, | ||
env: { | ||
node: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['tests/**/*.js'], | ||
env: { mocha: true }, | ||
}, | ||
], | ||
plugins: ['require-ts-check'], | ||
rules: { | ||
'require-ts-check/require-ts-check': 'error', | ||
}, | ||
}; |
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,21 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 7 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: 'pnpm' | ||
|
||
- run: pnpm install --frozen-lockfile | ||
- run: pnpm run lint && pnpm run test |
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,33 @@ | ||
name: Publish | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 7 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: 'pnpm' | ||
registry-url: https://registry.npmjs.org | ||
|
||
- run: pnpm install --frozen-lockfile | ||
- name: Create Release Pull Request or Publish | ||
id: changesets | ||
uses: changesets/action@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Publish | ||
run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
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 @@ | ||
node_modules |
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,6 @@ | ||
module.exports = { | ||
tabWidth: 2, | ||
printWidth: 120, | ||
singleQuote: true, | ||
trailingComma: 'es5', | ||
}; |
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 @@ | ||
{ | ||
"recommendations": ["EditorConfig.EditorConfig", "dbaeumer.vscode-eslint", "rvest.vs-code-prettier-eslint"] | ||
} |
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,19 @@ | ||
{ | ||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint", | ||
"editor.formatOnPaste": false, | ||
"editor.formatOnType": false, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnSaveMode": "file", | ||
"[javascript]": { | ||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint" | ||
}, | ||
"[json]": { | ||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint" | ||
}, | ||
"[md]": { | ||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint" | ||
} | ||
} |
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,9 @@ | ||
# eslint-plugin-require-ts-check | ||
|
||
## v0.0.1 | ||
|
||
Initial release | ||
|
||
### Patch changes | ||
|
||
- By default this plugin will include `.js` files and ignore the `node_modules` folder. |
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,95 @@ | ||
# eslint-plugin-require-ts-check | ||
|
||
Require @ts-check to be added in your javascript files | ||
|
||
## Table of contents | ||
|
||
- [Table of contents](#table-of-contents) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Supported Parameters](#supported-parameters) | ||
- [Contributing](#contributing) | ||
|
||
## Installation | ||
|
||
You'll first need to install [ESLint](https://eslint.org/): | ||
|
||
```sh | ||
npm i eslint --save-dev | ||
``` | ||
|
||
Next, install `eslint-plugin-require-ts-check`: | ||
|
||
```sh | ||
npm install eslint-plugin-require-ts-check --save-dev | ||
``` | ||
|
||
## Usage | ||
|
||
Add `eslint-plugin-require-ts-check` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix: | ||
|
||
```json | ||
{ | ||
"plugins": ["require-ts-check"] | ||
} | ||
``` | ||
|
||
Then configure the rules you want to use under the rules section. | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"require-ts-check/require-ts-check": "error" | ||
} | ||
} | ||
``` | ||
|
||
## Supported options | ||
|
||
This rule supports a combination of any of the following options: | ||
|
||
### include | ||
|
||
Specify the files that should be tested using this rule. This parameter uses the [Glob filename matching pattern](<https://en.wikipedia.org/wiki/Glob_(programming)>). | ||
|
||
Defaults to all javascript files: `[ "**/*.js" ]` | ||
|
||
#### `include` Usage | ||
|
||
```json | ||
"rules": { | ||
"require-ts-check/require-ts-check": ["error", { "include": ["**/my-files/*.*"] }] | ||
} | ||
``` | ||
|
||
### exclude | ||
|
||
Specify the files that this rule should ignore. This parameter uses the [Glob filename matching pattern](<https://en.wikipedia.org/wiki/Glob_(programming)>). | ||
|
||
Defaults to the `node_modules` folder: `[ "node_modules" ]` | ||
|
||
#### `exclude` Usage | ||
|
||
```json | ||
"rules": { | ||
"require-ts-check/require-ts-check": ["error", { "exclude": ["**/ignored-files/*.*"] }] | ||
} | ||
``` | ||
|
||
## Contributing | ||
|
||
1. Install VSCode recommended extensions. This is needed for formatting. | ||
|
||
In Mac: <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>: | ||
|
||
Others: <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>: | ||
|
||
Find "Extensions: Show recommended extensions" and install them | ||
|
||
Always format the code when saving | ||
|
||
2. Create a new changelog entry by running `pnpm changeset` and fill in the data | ||
3. Run tests `pnpm test` | ||
4. Run prettier `pnpm prettier` | ||
5. Run lint `pnpm lint` | ||
6. Push your changes and create a PR for your branch pointing to `main`. |
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,122 @@ | ||
# `require-ts-check` | ||
|
||
## Table of contents | ||
|
||
- [Options](#options) | ||
- [Examples](#examples) | ||
- [When Not To Use It](#when-not-to-use-it) | ||
|
||
Javascript files don't come with type checking enabled by default. In order to enable type checking to a javascript file | ||
we need to add the following single line comment to the top of the file: | ||
|
||
```js | ||
// @ts-check | ||
``` | ||
|
||
In order for this to enable type checking in the file, it needs to be added as a **single line comment** (`// ...`) (`/** */` JSDoc type | ||
comments don't work) and it needs to be added before any code declaration/statement (`import ...`, `const ...`, etc) | ||
|
||
This rule enforces that type checking is enabled on the file. Only `.js` files are evaluated. | ||
|
||
## Options | ||
|
||
This rule accepts some pattern matching options | ||
|
||
### `include` | ||
|
||
An array of [glob pattern](<https://en.wikipedia.org/wiki/Glob_(programming)>) strings. This will be the files in which the rule will be active. | ||
Partial glob path matching is enabled. | ||
|
||
Defaults to `['**/*.js']` | ||
|
||
### `exclude` | ||
|
||
An array of [glob pattern](<https://en.wikipedia.org/wiki/Glob_(programming)>) strings. This will be the files in which the rule will **not** be active | ||
This option takes precedence before the `include` one, meaning that if a file is matched by both patters, it will be ignored. | ||
Partial glob path matching is enabled. | ||
|
||
Defaults to `['node_modules']` | ||
|
||
## Examples | ||
|
||
### ✅ Correct | ||
|
||
The following examples are considered as valid: | ||
|
||
```js | ||
// @ts-check | ||
const foo = bar(); | ||
|
||
... | ||
|
||
// @ts-check this doesn't matter | ||
const foo = bar(); | ||
|
||
... | ||
|
||
// A comment | ||
/** Another comment */ | ||
// @ts-check | ||
// Final comment | ||
function foo() { | ||
console.log('bar'); | ||
}; | ||
|
||
... | ||
|
||
//@ts-check | ||
import foo from 'bar'; | ||
|
||
... | ||
|
||
// @Ts-ChEcK | ||
let foo; | ||
|
||
``` | ||
|
||
### ❌ Incorrect | ||
|
||
The following examples are considered as invalid | ||
|
||
```js | ||
const foo = bar(); | ||
// @ts-check <-- ERROR: Cannot be _below_ any code declaration | ||
|
||
|
||
... | ||
|
||
'use strict'; | ||
// @ts-check <- ERROR: Cannot be below expression statements | ||
const foo = bar(); | ||
|
||
... | ||
|
||
// invalid @ts-check <- ERROR: Cannot have any preceding characters | ||
function foo() { | ||
console.log('bar'); | ||
}; | ||
|
||
... | ||
|
||
/** @ts-check */ // <- ERROR: Cannot use JSDoc comments | ||
import foo from 'bar'; | ||
``` | ||
|
||
### Pattern matching options | ||
|
||
```js | ||
// Include only .js files from the entities folder | ||
'js-type-checking/require-ts-check': ['error', { include: ['**/entities/*.js'] }], | ||
|
||
// Exclude all paths matching 'models' | ||
'js-type-checking/require-ts-check': ['error', { exclude: ['models', 'node_modules'] }], | ||
|
||
// `exclude` takes precedence over `include`. All .js files will be included except for index.js | ||
'js-type-checking/require-ts-check': ['error', { include: ['**/*.js'], exclude: ['index.js'] }], | ||
``` | ||
|
||
For more examples, check the tests. | ||
|
||
## When Not To Use It | ||
|
||
If you don't like enabling type checking on Javascript files. |
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,19 @@ | ||
// @ts-check | ||
/** | ||
* @fileoverview Require @ts-check to be added to your files | ||
* @author Emiliano Delgadillo | ||
*/ | ||
'use strict'; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
|
||
const requireIndex = require('requireindex'); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Plugin Definition | ||
//------------------------------------------------------------------------------ | ||
|
||
// import all rules in lib/rules | ||
module.exports.rules = requireIndex(__dirname + '/rules'); |
Oops, something went wrong.