Skip to content

Commit 2304351

Browse files
committed
checkpoint
1 parent b7bf6d0 commit 2304351

21 files changed

+2708
-3588
lines changed

.eslintrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
20.19.0

.oxlintrc.json

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
{
2+
"ignore": [
3+
"**/*.coffee",
4+
"**/*.css",
5+
"**/*.hbs",
6+
"**/*.json",
7+
"**/*.less",
8+
"**/*.scss",
9+
"**/*.svg",
10+
"dist/**",
11+
"node_modules/**"
12+
],
13+
"project": [
14+
"./apps/desktop/tsconfig.json",
15+
"./apps/web/tsconfig.json",
16+
"./shared/tsconfig.lint.json"
17+
],
18+
"rules": {
19+
"correctness/no-array-constructor": "error",
20+
"correctness/no-class-assign": "error",
21+
"correctness/no-cond-assign": "error",
22+
"correctness/no-const-assign": "error",
23+
"correctness/no-constant-condition": "warn",
24+
"correctness/no-control-regex": "error",
25+
"correctness/no-debugger": "error",
26+
"correctness/no-dupe-args": "error",
27+
"correctness/no-dupe-class-members": "error",
28+
"correctness/no-dupe-keys": "error",
29+
"correctness/no-duplicate-case": "error",
30+
"correctness/no-empty-character-class": "error",
31+
"correctness/no-empty-pattern": "error",
32+
"correctness/no-ex-assign": "error",
33+
"correctness/no-func-assign": "error",
34+
"correctness/no-invalid-regexp": "error",
35+
"correctness/no-irregular-whitespace": "error",
36+
"correctness/no-obj-calls": "error",
37+
"correctness/no-octal": "error",
38+
"correctness/no-prototype-builtins": "error",
39+
"correctness/no-regex-spaces": "error",
40+
"correctness/no-self-assign": "error",
41+
"correctness/no-sparse-arrays": "error",
42+
"correctness/no-template-curly-in-string": "error",
43+
"correctness/no-this-before-super": "error",
44+
"correctness/no-undef": "error",
45+
"correctness/no-unreachable": "error",
46+
"correctness/no-unsafe-finally": "error",
47+
"correctness/no-unsafe-negation": "error",
48+
"correctness/require-yield": "error",
49+
"correctness/use-isnan": "error",
50+
"correctness/valid-typeof": "error",
51+
"performance/no-new-buffer": "error",
52+
"style/camelcase": [
53+
"error",
54+
{
55+
"properties": "never"
56+
}
57+
],
58+
"style/capitalized-comments": "off",
59+
"style/comma-dangle": ["error", "never"],
60+
"style/eqeqeq": [
61+
"error",
62+
"always",
63+
{
64+
"null": "ignore"
65+
}
66+
],
67+
"style/linebreak-style": ["error", "unix"],
68+
"style/new-cap": [
69+
"error",
70+
{
71+
"capIsNew": false,
72+
"newIsCap": true
73+
}
74+
],
75+
"style/no-bitwise": "error",
76+
"style/no-continue": "error",
77+
"style/no-else-return": "error",
78+
"style/no-lonely-if": "error",
79+
"style/no-multi-assign": ["error"],
80+
"style/no-new-object": "error",
81+
"style/no-param-reassign": ["warn", { "props": false }],
82+
"style/no-plusplus": [
83+
"error",
84+
{
85+
"allowForLoopAfterthoughts": true
86+
}
87+
],
88+
"style/no-unneeded-ternary": [
89+
"error",
90+
{
91+
"defaultAssignment": false
92+
}
93+
],
94+
"style/no-var": "error",
95+
"style/object-shorthand": [
96+
"error",
97+
"always",
98+
{
99+
"avoidQuotes": true,
100+
"ignoreConstructors": false
101+
}
102+
],
103+
"style/one-var": ["error", "never"],
104+
"style/operator-assignment": ["error", "always"],
105+
"style/prefer-const": [
106+
"error",
107+
{
108+
"destructuring": "any",
109+
"ignoreReadBeforeAssign": true
110+
}
111+
],
112+
"style/prefer-destructuring": [
113+
"warn",
114+
{
115+
"array": false,
116+
"object": true
117+
}
118+
],
119+
"style/prefer-numeric-literals": "error",
120+
"style/prefer-rest-params": "error",
121+
"style/prefer-spread": "error",
122+
"style/prefer-template": "error",
123+
"style/radix": "error",
124+
"style/spaced-comment": ["error", "always"],
125+
"style/strict": "error",
126+
"style/symbol-description": "error",
127+
"style/vars-on-top": "error",
128+
"style/yoda": "error",
129+
"suspicious/no-await-in-loop": "error",
130+
"suspicious/no-compare-neg-zero": "error",
131+
"suspicious/no-empty": ["error", { "allowEmptyCatch": true }],
132+
"suspicious/no-empty-function": [
133+
"error",
134+
{
135+
"allow": ["arrowFunctions", "functions", "methods"]
136+
}
137+
],
138+
"suspicious/no-eval": "error",
139+
"suspicious/no-extend-native": "error",
140+
"suspicious/no-extra-bind": "error",
141+
"suspicious/no-extra-boolean-cast": "error",
142+
"suspicious/no-fallthrough": "error",
143+
"suspicious/no-global-assign": "error",
144+
"suspicious/no-implied-eval": "error",
145+
"suspicious/no-inner-declarations": "error",
146+
"suspicious/no-iterator": "error",
147+
"suspicious/no-labels": "error",
148+
"suspicious/no-lone-blocks": "error",
149+
"suspicious/no-loop-func": "error",
150+
"suspicious/no-multi-str": "error",
151+
"suspicious/no-new": "error",
152+
"suspicious/no-new-func": "error",
153+
"suspicious/no-new-wrappers": "error",
154+
"suspicious/no-octal-escape": "error",
155+
"suspicious/no-return-assign": "error",
156+
"suspicious/no-return-await": "error",
157+
"suspicious/no-script-url": "error",
158+
"suspicious/no-self-compare": "error",
159+
"suspicious/no-sequences": "error",
160+
"suspicious/no-throw-literal": "error",
161+
"suspicious/no-unmodified-loop-condition": "off",
162+
"suspicious/no-unused-expressions": [
163+
"error",
164+
{
165+
"allowShortCircuit": true,
166+
"allowTernary": false
167+
}
168+
],
169+
"suspicious/no-unused-labels": "error",
170+
"suspicious/no-useless-concat": "error",
171+
"suspicious/no-useless-constructor": "error",
172+
"suspicious/no-useless-escape": "error",
173+
"suspicious/no-useless-return": "error",
174+
"suspicious/no-void": "off",
175+
"suspicious/no-with": "error",
176+
"unicorn/no-new-array": "off",
177+
"unicorn/no-useless-fallback-in-spread": "off",
178+
"react/rules-of-hooks": "error",
179+
"react/exhaustive-deps": "warn"
180+
},
181+
"typescript": true
182+
}

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"plugins": ["."]
2+
"plugins": ["./lib/index.js"]
33
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ This plugin adds support for `package.json` files used within NPM modules.
2020

2121
## Requirements
2222

23-
`prettier-plugin-package` is an evergreen module. 🌲 This module requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+), and `prettier` v2.0.0+.
23+
`prettier-plugin-package` is an evergreen module. 🌲 This module requires an [LTS](https://github.com/nodejs/Release) Node version (v20.19.0+), and `prettier` v3.0.0+.
2424

2525
For Prettier v1.x support, please use `prettier-plugin-package@0.3.1`.
26+
For Prettier v2.x support, please use `prettier-plugin-package@1.4.0`.
2627

2728
## Install
2829

codecov.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

commitlint.config.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

lib/index.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
The above copyright notice and this permission notice shall be
99
included in all copies or substantial portions of this Source Code Form.
1010
*/
11-
const { parsers } = require('prettier/parser-babel');
12-
13-
const { dependencies } = require('./rules/dependencies');
14-
const { engines } = require('./rules/engines');
15-
const { files } = require('./rules/files');
16-
const { scripts } = require('./rules/scripts');
17-
const { sort } = require('./rules/sort');
18-
19-
const { 'json-stringify': parser } = parsers;
11+
import babelParsers from "prettier/plugins/babel";
12+
import estreeParsers from "prettier/plugins/estree";
13+
import prettier from "prettier";
14+
15+
import { dependencies } from "./rules/dependencies.js";
16+
import { engines } from "./rules/engines.js";
17+
import { files } from "./rules/files.js";
18+
import { scripts } from "./rules/scripts.js";
19+
import { sort } from "./rules/sort.js";
20+
21+
const { parsers } = babelParsers;
22+
const { "json-stringify": parser } = parsers;
2023
const { parse } = parser;
2124
const rePkg = /package\.json$/;
2225

@@ -30,23 +33,31 @@ const format = (properties) => {
3033
return props;
3134
};
3235

33-
module.exports = {
34-
name: 'prettier-plugin-package',
36+
const plugin = {
37+
name: "prettier-plugin-package",
3538
parsers: {
36-
'json-stringify': {
39+
"json-stringify": {
3740
...parser,
38-
parse(...args) {
39-
const [, , options] = args;
41+
async parse(text, options) {
4042
const { filepath } = options;
41-
const ast = parse(...args);
43+
const ast = parse(text, options);
4244

4345
if (rePkg.test(filepath)) {
4446
const { properties, node } = ast;
4547
ast.properties = format(properties || node.properties);
4648
}
4749

50+
const formattedText = await prettier.format(text, {
51+
parser: "json-stringify",
52+
plugins: [babelParsers, estreeParsers],
53+
});
54+
console.log("Formatted text:", formattedText);
55+
4856
return ast;
49-
}
50-
}
51-
}
57+
},
58+
astFormat: "estree-json",
59+
},
60+
},
5261
};
62+
63+
export default plugin;

lib/rules/dependencies.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ const process = (props) =>
3737
return prop;
3838
});
3939

40-
module.exports = { dependencies: process };
40+
export { process as dependencies };

lib/rules/engines.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ const process = (props) => {
2525
return props;
2626
};
2727

28-
module.exports = { engines: process };
28+
export { process as engines};

0 commit comments

Comments
 (0)