eslint-plugin-require-use-server 0.0.0 → 1.0.7

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,29 @@
1
+ name: Publish Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ id-token: write # Required for OIDC
10
+ contents: read
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v7
17
+
18
+ - uses: pnpm/action-setup@v6
19
+ with:
20
+ version: 12
21
+
22
+ - uses: actions/setup-node@v7
23
+ with:
24
+ node-version: '24.21.0'
25
+ registry-url: 'https://registry.npmjs.org'
26
+ cache: 'pnpm'
27
+ - run: pnpm install --frozen-lockfile
28
+ - run: pnpm build
29
+ - run: pnpm publish # Or: npm stage publish
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ v24.21.0
package/.prettierrc ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "plugins": ["@trivago/prettier-plugin-sort-imports", "prettier-plugin-tailwindcss"],
3
+ "singleQuote": true,
4
+ "tabWidth": 4,
5
+ "useTabs": true,
6
+ "arrowParens": "avoid",
7
+ "jsxSingleQuote": false,
8
+ "experimentalTernaries": true,
9
+ "bracketSpacing": true,
10
+ "insertPragma": false,
11
+ "requirePragma": false,
12
+ "trailingComma": "all",
13
+ "semi": true,
14
+ "printWidth": 120,
15
+ "importOrder": ["^[./]"],
16
+ "importOrderSeparation": true,
17
+ "importOrderSortSpecifiers": true,
18
+ "importOrderSortByLength": "asc"
19
+ }
package/README.md CHANGED
@@ -1,45 +1,58 @@
1
- # eslint-plugin-require-use-server
1
+ # eslint-plugin-use-server-top-level
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ Custom ESLint rule to ensure specified files start with `use server`.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
5
+ ## Features
6
+ - Checks if the first code line of matched files is `'use server'` or `"use server"`.
7
+ - Skips leading comments and empty lines.
8
+ - Path matching is configurable via the `pathPattern` option.
6
9
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
10
+ ## Requirements
11
+ - ESLint 9 or 10 (flat config)
12
+ - Node.js `^20.19.0 || ^22.13.0 || >=24`
8
13
 
9
- ## Purpose
14
+ ## Installation
10
15
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `eslint-plugin-require-use-server`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
16
+ ```bash
17
+ npm install eslint-plugin-require-use-server --save-dev
18
+ ```
15
19
 
16
- ## What is OIDC Trusted Publishing?
20
+ ## Usage
17
21
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
22
+ 1. Import the plugin in your ESLint config (e.g. `eslint.config.mjs`):
19
23
 
20
- ## Setup Instructions
24
+ ```js
25
+ import useServerPlugin from '@leo-tools/eslint-plugin-use-server-top-level';
21
26
 
22
- To properly configure OIDC trusted publishing for this package:
27
+ export default [
28
+ {
29
+ plugins: {
30
+ 'use-server': useServerPlugin,
31
+ },
32
+ rules: {
33
+ // Configure the rule and specify the path pattern
34
+ 'use-server/require-use-server': ['error', { pathPattern: 'src/services/actions/.*\\.ts$' }],
35
+ },
36
+ },
37
+ ];
38
+ ```
23
39
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
40
+ 2. Run ESLint on your target files:
28
41
 
29
- ## DO NOT USE THIS PACKAGE
42
+ ```bash
43
+ eslint
44
+ ```
30
45
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
46
+ ## Options
47
+ - `pathPattern` (string): Regex pattern to match file paths. Only matched files will be checked.
36
48
 
37
- ## More Information
49
+ ## Example
50
+ If a file at `src/services/actions/foo.ts` does not start with `use server`, ESLint will report an error:
38
51
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
52
+ ```
53
+ Error: servers/actions/*.ts must start with 'use server'
54
+ ```
42
55
 
43
- ---
56
+ ## License
57
+ MIT
44
58
 
45
- **Maintained for OIDC setup purposes only**
package/package.json CHANGED
@@ -1,10 +1,29 @@
1
1
  {
2
2
  "name": "eslint-plugin-require-use-server",
3
- "version": "0.0.0",
4
- "description": "OIDC trusted publishing setup package for eslint-plugin-require-use-server",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
3
+ "version": "1.0.7",
4
+ "description": "",
5
+ "license": "ISC",
6
+ "author": "KLewin23",
7
+ "type": "commonjs",
8
+ "main": "index.js",
9
+ "repository": {
10
+ "url": "https://github.com/KLewin23/eslint-plugin-require-use-server"
11
+ },
12
+ "devDependencies": {
13
+ "@trivago/prettier-plugin-sort-imports": "^6.0.2",
14
+ "@types/eslint": "^9.6.1",
15
+ "cz-conventional-changelog": "^3.3.0",
16
+ "eslint": "^10.12.0",
17
+ "prettier": "^3.9.10",
18
+ "typescript": "^7.0.2"
19
+ },
20
+ "config": {
21
+ "commitizen": {
22
+ "path": "./node_modules/cz-conventional-changelog"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "build": "tsc",
27
+ "commit": "cz"
28
+ }
10
29
  }
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ import requireUseServer from "./require-use-server";
2
+
3
+ const plugin = {
4
+ meta: {
5
+ name: "require-use-server",
6
+ version: "1.0.7"
7
+ },
8
+ rules: {
9
+ "require-use-server": requireUseServer,
10
+ },
11
+ };
12
+
13
+ export default plugin
@@ -0,0 +1,47 @@
1
+ import { Rule } from 'eslint';
2
+
3
+ const rule: Rule.RuleModule = {
4
+ meta: {
5
+ type: 'problem',
6
+ docs: {
7
+ description: "Require 'use server' at the top of the file",
8
+ },
9
+ schema: [
10
+ {
11
+ type: 'object',
12
+ properties: {
13
+ pathPattern: { type: 'string' },
14
+ },
15
+ additionalProperties: false,
16
+ },
17
+ ],
18
+ defaultOptions: [{ pathPattern: 'src/.*\\.ts$' }],
19
+ messages: {
20
+ missingUseServer: "{{filename}} must start with 'use server'",
21
+ },
22
+ },
23
+ create: context => {
24
+ const options = context.options[0] || {};
25
+ const pathPattern = options.pathPattern || 'src/.*\\.ts$';
26
+ const filename = context.filename;
27
+ if (!new RegExp(pathPattern).test(filename)) return {};
28
+
29
+ return {
30
+ Program(node) {
31
+ const sourceCode = context.sourceCode;
32
+ const lines = sourceCode.getText().split(/\r?\n/);
33
+ const firstLine = lines[0] ?? '';
34
+
35
+ if (!firstLine.startsWith("'use server'")) {
36
+ context.report({
37
+ node,
38
+ messageId: 'missingUseServer',
39
+ data: { filename },
40
+ });
41
+ }
42
+ },
43
+ };
44
+ },
45
+ };
46
+
47
+ export = rule;
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2025",
4
+ "module": "nodenext",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "moduleResolution": "node16",
10
+ "esModuleInterop": true
11
+ }
12
+ }