@alextheman/eslint-plugin 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
+
4
+ name: Node.js CI
5
+
6
+ on:
7
+ push:
8
+ branches: [ "main" ]
9
+ pull_request:
10
+ branches: [ "main" ]
11
+
12
+ jobs:
13
+ ci:
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ matrix:
19
+ node-version: [22.x]
20
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - name: Use Node.js ${{ matrix.node-version }}
25
+ uses: actions/setup-node@v4
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+ cache: 'npm'
29
+ - name: Setup package
30
+ run: |
31
+ npm ci
32
+ npm run build --if-present
33
+ - name: Run tests
34
+ run: npm test
35
+ - name: Run linting checks
36
+ run: npm run lint
@@ -0,0 +1,27 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ push:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ publish-npm:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version: 20
19
+ registry-url: https://registry.npmjs.org/
20
+ - name: Install dependencies
21
+ run: npm ci
22
+ - name: Build package
23
+ run: npm run build
24
+ - name: Publish to npm
25
+ run: npm publish --access public
26
+ env:
27
+ NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
@@ -0,0 +1,3 @@
1
+ npm run format
2
+ npm run lint
3
+ git update-index --again
@@ -0,0 +1,24 @@
1
+ import { RuleTester } from "@typescript-eslint/rule-tester";
2
+ import rules from "src/rules";
3
+
4
+ const ruleTester = new RuleTester({
5
+ languageOptions: { ecmaVersion: "latest" },
6
+ });
7
+
8
+ ruleTester.run("no-namespace-imports", rules["no-namespace-imports"], {
9
+ valid: [
10
+ {
11
+ code: 'import { useState } from "react"',
12
+ },
13
+ ],
14
+ invalid: [
15
+ {
16
+ code: 'import * as React from "react"',
17
+ errors: [
18
+ {
19
+ messageId: "message",
20
+ },
21
+ ],
22
+ },
23
+ ],
24
+ });
@@ -0,0 +1,3 @@
1
+ import alexBaseConfig from "@alextheman/eslint-config-typescript-base";
2
+
3
+ export default alexBaseConfig;
package/jest.config.js ADDED
@@ -0,0 +1,12 @@
1
+ import { createDefaultPreset } from "ts-jest";
2
+
3
+ const tsJestTransformCfg = createDefaultPreset().transform;
4
+
5
+ /** @type {import("jest").Config} **/
6
+ export default {
7
+ testEnvironment: "node",
8
+ transform: {
9
+ ...tsJestTransformCfg,
10
+ },
11
+ moduleDirectories: ["node_modules", "."]
12
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@alextheman/eslint-plugin",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "jest",
8
+ "format": "prettier --write --parser typescript 'src/**/*.ts' '__tests__/**/*.ts' && ESLINT_MODE=fix eslint --fix 'src/**/*.ts' '__tests__/**/*.ts'",
9
+ "lint": "ESLINT_MODE=lint eslint 'src/**/*.ts' '__tests__/**/*.ts' && prettier --check --parser typescript 'src/**/*.ts' '__tests__/**/*.ts'",
10
+ "update-dependencies": "npx npm-check-updates -u && npm install",
11
+ "prepare": "husky",
12
+ "build": "tsup"
13
+ },
14
+ "keywords": [],
15
+ "author": "",
16
+ "license": "ISC",
17
+ "type": "module",
18
+ "peerDependencies": {
19
+ "@typescript-eslint/eslint-plugin": "^8.36.0",
20
+ "@typescript-eslint/parser": "^8.36.0",
21
+ "eslint": "^9.31.0",
22
+ "eslint-import-resolver-typescript": "^4.4.4",
23
+ "eslint-plugin-import": "^2.32.0"
24
+ },
25
+ "devDependencies": {
26
+ "@alextheman/eslint-config-typescript-base": "^1.0.7",
27
+ "@types/eslint": "^9.6.1",
28
+ "@types/jest": "^30.0.0",
29
+ "@typescript-eslint/rule-tester": "^8.36.0",
30
+ "@typescript-eslint/utils": "^8.36.0",
31
+ "eslint": "^9.31.0",
32
+ "eslint-plugin-eslint-plugin": "^6.5.0",
33
+ "husky": "^9.1.7",
34
+ "jest": "^30.0.4",
35
+ "ts-jest": "^29.4.0",
36
+ "tsup": "^8.5.0",
37
+ "typescript": "^5.8.3"
38
+ }
39
+ }
@@ -0,0 +1,7 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+
3
+ const createRule = ESLintUtils.RuleCreator((ruleName) => {
4
+ return `https://github.com/AlexMan123456/eslint-plugin/${ruleName}`;
5
+ });
6
+
7
+ export default createRule;
package/src/index.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { name, version } from "package.json";
2
+ import rules from "src/rules";
3
+
4
+ const plugin = {
5
+ meta: {
6
+ name,
7
+ version,
8
+ namespace: "alextheman",
9
+ },
10
+ configs: {},
11
+ rules,
12
+ };
13
+
14
+ export default plugin;
@@ -0,0 +1,5 @@
1
+ import noNamespaceImports from "src/rules/no-namespace-imports";
2
+
3
+ export default {
4
+ "no-namespace-imports": noNamespaceImports,
5
+ };
@@ -0,0 +1,33 @@
1
+ import createRule from "src/createRule";
2
+
3
+ const noNamespaceImports = createRule({
4
+ name: "no-namespace-imports",
5
+ meta: {
6
+ docs: {
7
+ description: "Forbid the use of import *",
8
+ },
9
+ messages: {
10
+ message: "Import * is not allowed. Please use named imports instead.",
11
+ },
12
+ type: "suggestion",
13
+ schema: [],
14
+ },
15
+ defaultOptions: [],
16
+ create(context) {
17
+ return {
18
+ ImportDeclaration(node) {
19
+ if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
20
+ context.report({
21
+ node,
22
+ messageId: "message",
23
+ data: {
24
+ source: node.source,
25
+ },
26
+ });
27
+ }
28
+ },
29
+ };
30
+ },
31
+ });
32
+
33
+ export default noNamespaceImports;
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES6",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2024"],
6
+ "types": ["eslint"],
7
+ "module": "ESNext",
8
+ "skipLibCheck": true,
9
+ "baseUrl": ".",
10
+ "paths": {
11
+ "src/*": ["src/*"]
12
+ },
13
+ "esModuleInterop": true,
14
+
15
+ "moduleResolution": "bundler",
16
+ "resolveJsonModule": true,
17
+ "isolatedModules": true,
18
+ "outDir": "dist",
19
+
20
+ "strict": true,
21
+ "noUnusedLocals": true,
22
+ "noUnusedParameters": true,
23
+ "noFallthroughCasesInSwitch": true,
24
+ "declaration": true
25
+ },
26
+ "include": ["src", "__tests__"]
27
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "tsup";
2
+ import packageInfo from "./package.json"
3
+
4
+ export default defineConfig({
5
+ entry: ["src/index.ts"],
6
+ format: ["esm", "cjs"],
7
+ dts: true,
8
+ clean: true,
9
+ external: [
10
+ ...Object.keys(packageInfo.peerDependencies)
11
+ ]
12
+ });