eslint-plugin-require-use-server 1.0.8 → 1.0.10
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.
- package/README.md +2 -2
- package/dist/index.d.ts +10 -0
- package/dist/index.js +8 -7
- package/dist/require-use-server.d.ts +3 -0
- package/dist/require-use-server.js +46 -0
- package/package.json +5 -1
- package/.github/workflows/publish.yml +0 -29
- package/.nvmrc +0 -1
- package/.prettierrc +0 -19
- package/src/index.ts +0 -13
- package/src/require-use-server.ts +0 -47
- package/tsconfig.json +0 -12
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# eslint-plugin-use-server
|
|
1
|
+
# eslint-plugin-require-use-server
|
|
2
2
|
|
|
3
3
|
Custom ESLint rule to ensure specified files start with `use server`.
|
|
4
4
|
|
|
@@ -22,7 +22,7 @@ npm install eslint-plugin-require-use-server --save-dev
|
|
|
22
22
|
1. Import the plugin in your ESLint config (e.g. `eslint.config.mjs`):
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
|
-
import useServerPlugin from '
|
|
25
|
+
import useServerPlugin from 'eslint-plugin-require-use-server';
|
|
26
26
|
|
|
27
27
|
export default [
|
|
28
28
|
{
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const require_use_server_1 =
|
|
3
|
+
const require_use_server_1 = require("./require-use-server");
|
|
4
|
+
const { name, version } =
|
|
5
|
+
// `import`ing here would bypass the TSConfig's `"rootDir": "src"`
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
7
|
+
require('../package.json');
|
|
7
8
|
const plugin = {
|
|
8
9
|
meta: {
|
|
9
|
-
name
|
|
10
|
-
version
|
|
10
|
+
name,
|
|
11
|
+
version,
|
|
11
12
|
},
|
|
12
13
|
rules: {
|
|
13
|
-
|
|
14
|
+
'require-use-server': require_use_server_1.requireUseServer,
|
|
14
15
|
},
|
|
15
16
|
};
|
|
16
17
|
exports.default = plugin;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireUseServer = void 0;
|
|
4
|
+
const requireUseServer = {
|
|
5
|
+
meta: {
|
|
6
|
+
type: 'problem',
|
|
7
|
+
docs: {
|
|
8
|
+
description: "Require 'use server' at the top of the file",
|
|
9
|
+
},
|
|
10
|
+
schema: [
|
|
11
|
+
{
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
pathPattern: { type: 'string' },
|
|
15
|
+
},
|
|
16
|
+
additionalProperties: false,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
defaultOptions: [{ pathPattern: 'src/.*\\.ts$' }],
|
|
20
|
+
messages: {
|
|
21
|
+
missingUseServer: "{{filename}} must start with 'use server'",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
create: context => {
|
|
25
|
+
const options = context.options[0] || {};
|
|
26
|
+
const pathPattern = options.pathPattern || 'src/.*\\.ts$';
|
|
27
|
+
const filename = context.filename;
|
|
28
|
+
if (!new RegExp(pathPattern).test(filename))
|
|
29
|
+
return {};
|
|
30
|
+
return {
|
|
31
|
+
Program(node) {
|
|
32
|
+
const sourceCode = context.sourceCode;
|
|
33
|
+
const lines = sourceCode.getText().split(/\r?\n/);
|
|
34
|
+
const firstLine = lines[0] ?? '';
|
|
35
|
+
if (!firstLine.startsWith("'use server'")) {
|
|
36
|
+
context.report({
|
|
37
|
+
node,
|
|
38
|
+
messageId: 'missingUseServer',
|
|
39
|
+
data: { filename },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
exports.requireUseServer = requireUseServer;
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-require-use-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "KLewin23",
|
|
7
7
|
"type": "commonjs",
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
9
12
|
"repository": {
|
|
10
13
|
"url": "https://github.com/KLewin23/eslint-plugin-require-use-server"
|
|
11
14
|
},
|
|
12
15
|
"devDependencies": {
|
|
13
16
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
14
17
|
"@types/eslint": "^9.6.1",
|
|
18
|
+
"@types/node": "^26.6.5",
|
|
15
19
|
"cz-conventional-changelog": "^3.3.0",
|
|
16
20
|
"eslint": "^10.12.0",
|
|
17
21
|
"prettier": "^3.9.10",
|
|
@@ -1,29 +0,0 @@
|
|
|
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
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v24.21.0
|
package/.prettierrc
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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/src/index.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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;
|