Skip to content

Commit 215e768

Browse files
chore: rewrite eslint plugin in typescript (#96)
* chore: rewrite eslint plugin in typescript * fix: build before lint step because it is required for doc generation * docs: add build step in docs on how to generate eslint docs * fix: add dist to eslintignore * chore: remove eslint plugin node and use typescript eslint plugin * chore: add eslint prettier plugin
1 parent 6f9925b commit 215e768

25 files changed

Lines changed: 909 additions & 326 deletions

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
- name: Install dependencies
2424
run: yarn --immutable
2525

26+
- name: Build
27+
run: yarn build
28+
2629
- name: Set up .npmrc file
2730
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
2831

.github/workflows/quality-eslint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
- name: Install dependencies
3737
run: yarn --frozen-lockfile
3838

39+
- name: Build
40+
run: yarn build
41+
3942
- name: Linter
4043
run: yarn lint
4144

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules/
1+
node_modules/
2+
dist

packages/eslint-plugin/.eslint-doc-generatorrc.js

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import prettier from "prettier";
2+
import type { GenerateOptions } from "eslint-doc-generator";
3+
4+
const config: GenerateOptions = {
5+
postprocess: (content, path) =>
6+
prettier.format(content, { parser: "markdown" }),
7+
urlRuleDoc: (path) =>
8+
`https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/docs/rules/${path}.md`,
9+
};
10+
11+
export default config;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist

packages/eslint-plugin/.eslintrc.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ module.exports = {
55
extends: [
66
"eslint:recommended",
77
"plugin:eslint-plugin/recommended",
8-
"plugin:node/recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:prettier/recommended",
910
],
11+
parser: "@typescript-eslint/parser",
12+
plugins: ["@typescript-eslint"],
1013
rules: {
1114
"eslint-plugin/require-meta-docs-description": [
1215
2,
@@ -24,11 +27,5 @@ module.exports = {
2427
env: {
2528
node: true,
2629
},
27-
overrides: [
28-
{
29-
files: ["tests/**/*.js"],
30-
env: { mocha: true },
31-
},
32-
],
3330
ignorePatterns: ["example-app"],
3431
};

packages/eslint-plugin/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Creating new rules is quite simple:
103103
1. Update the README and run the tests:
104104
105105
```bash
106+
yarn build
106107
yarn update:eslint-docs
107108
yarn lint
108109
yarn test
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { Config } from "jest";
2+
3+
const config: Config = {
4+
verbose: true,
5+
preset: "ts-jest",
6+
testEnvironment: "node",
7+
transform: {
8+
"^.+\\.tsx?$": "ts-jest",
9+
},
10+
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
11+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
12+
};
13+
14+
export default config;

packages/eslint-plugin/lib/configs/a11y.js renamed to packages/eslint-plugin/lib/configs/a11y.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
// @ts-check
2-
"use strict";
1+
import { defineConfig } from "eslint-define-config";
32

4-
const { defineConfig } = require("eslint-define-config");
5-
6-
module.exports = defineConfig({
3+
export const a11yconfig = defineConfig({
74
extends: ["plugin:react-native-a11y/all"],
85
rules: {
96
"react-native-a11y/has-accessibility-hint": "off",

0 commit comments

Comments
 (0)