@cedarjs/eslint-config 5.0.4-next.167 → 5.0.4
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 +36 -7
- package/dist/index.d.mts +1 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +144 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/shared.d.mts +2 -3
- package/dist/shared.d.mts.map +1 -1
- package/dist/shared.d.ts +144 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.js +142 -0
- package/index.mjs +2 -3
- package/package.json +30 -10
- package/shared.js +202 -0
- package/shared.mjs +1 -6
package/index.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// This is the ESLint configuration used by Cedar projects.
|
|
2
|
+
// Shared eslint config (projects and framework) is located in ./shared.js
|
|
3
|
+
// Framework main config is in monorepo root ./eslint.config.js
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
getCommonPlugins,
|
|
7
|
+
getApiSideDefaultBabelConfig,
|
|
8
|
+
getWebSideDefaultBabelConfig,
|
|
9
|
+
} = require('@cedarjs/babel-config')
|
|
10
|
+
const { getConfig, isTypeScriptProject } = require('@cedarjs/project-config')
|
|
11
|
+
|
|
12
|
+
const config = getConfig()
|
|
13
|
+
|
|
14
|
+
const getProjectBabelOptions = () => {
|
|
15
|
+
// We can't nest the web overrides inside the overrides block
|
|
16
|
+
// So we just take it out and put it as a separate item
|
|
17
|
+
// Ignoring overrides, as I don't think it has any impact on linting
|
|
18
|
+
const { overrides: _webOverrides, ...otherWebConfig } =
|
|
19
|
+
getWebSideDefaultBabelConfig({
|
|
20
|
+
// We have to enable certain presets like `@babel/preset-react` for JavaScript projects
|
|
21
|
+
forJavaScriptLinting: !isTypeScriptProject(),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const { overrides: _apiOverrides, ...otherApiConfig } =
|
|
25
|
+
getApiSideDefaultBabelConfig()
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
plugins: getCommonPlugins(),
|
|
29
|
+
overrides: [
|
|
30
|
+
{
|
|
31
|
+
test: ['./api/', './scripts/'],
|
|
32
|
+
...otherApiConfig,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
test: ['./web/'],
|
|
36
|
+
...otherWebConfig,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const plugins = []
|
|
43
|
+
const rules = {}
|
|
44
|
+
|
|
45
|
+
// Add react compiler plugin & rules if enabled
|
|
46
|
+
const reactCompilerEnabled =
|
|
47
|
+
config.experimental?.reactCompiler?.enabled ?? false
|
|
48
|
+
if (reactCompilerEnabled) {
|
|
49
|
+
plugins.push('react-compiler')
|
|
50
|
+
rules['react-compiler/react-compiler'] = 2
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
extends: [
|
|
55
|
+
'./shared.js',
|
|
56
|
+
config.web.a11y && 'plugin:jsx-a11y/recommended',
|
|
57
|
+
].filter(Boolean),
|
|
58
|
+
// This is merged with `ignorePatterns` in shared.js
|
|
59
|
+
ignorePatterns: ['!.storybook/'],
|
|
60
|
+
parserOptions: {
|
|
61
|
+
requireConfigFile: false,
|
|
62
|
+
babelOptions: getProjectBabelOptions(),
|
|
63
|
+
},
|
|
64
|
+
plugins,
|
|
65
|
+
rules,
|
|
66
|
+
overrides: [
|
|
67
|
+
{
|
|
68
|
+
files: ['web/src/Routes.js', 'web/src/Routes.jsx', 'web/src/Routes.tsx'],
|
|
69
|
+
rules: {
|
|
70
|
+
'no-undef': 'off',
|
|
71
|
+
'jsx-a11y/aria-role': [
|
|
72
|
+
2,
|
|
73
|
+
{
|
|
74
|
+
ignoreNonDOM: true,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
'@cedarjs/unsupported-route-components': 'error',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
// `api` side
|
|
81
|
+
{
|
|
82
|
+
files: 'api/src/**',
|
|
83
|
+
env: {
|
|
84
|
+
node: true,
|
|
85
|
+
es6: true,
|
|
86
|
+
},
|
|
87
|
+
globals: {
|
|
88
|
+
gql: 'readonly',
|
|
89
|
+
context: 'readonly',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
files: ['api/src/services/**/*.ts'],
|
|
94
|
+
plugins: ['@cedarjs'],
|
|
95
|
+
rules: {
|
|
96
|
+
'@cedarjs/service-type-annotations': 'off',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
files: ['api/db/seed.js', 'scripts/**'],
|
|
101
|
+
env: {
|
|
102
|
+
node: true,
|
|
103
|
+
commonjs: true,
|
|
104
|
+
},
|
|
105
|
+
globals: {
|
|
106
|
+
Promise: 'readonly',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
// `web` side
|
|
110
|
+
{
|
|
111
|
+
files: 'web/src/**',
|
|
112
|
+
env: {
|
|
113
|
+
browser: true,
|
|
114
|
+
es6: true,
|
|
115
|
+
'shared-node-browser': true,
|
|
116
|
+
},
|
|
117
|
+
globals: {
|
|
118
|
+
React: 'readonly',
|
|
119
|
+
gql: 'readonly',
|
|
120
|
+
process: 'readonly',
|
|
121
|
+
require: 'readonly',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
// Test, stories, scenarios, and mock files
|
|
125
|
+
{
|
|
126
|
+
files: [
|
|
127
|
+
'*.test.*',
|
|
128
|
+
'**/__mocks__/**',
|
|
129
|
+
'*.scenarios.*',
|
|
130
|
+
'*.stories.*',
|
|
131
|
+
'*.mock.*',
|
|
132
|
+
],
|
|
133
|
+
globals: {
|
|
134
|
+
mockGraphQLQuery: 'readonly',
|
|
135
|
+
mockGraphQLMutation: 'readonly',
|
|
136
|
+
mockCurrentUser: 'readonly',
|
|
137
|
+
scenario: 'readonly',
|
|
138
|
+
defineScenario: 'readonly',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
}
|
package/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'
|
|
|
6
6
|
import globals from 'globals'
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
+
getCommonPlugins,
|
|
9
10
|
getApiSideDefaultBabelConfig,
|
|
10
11
|
getWebSideDefaultBabelConfig,
|
|
11
12
|
} from '@cedarjs/babel-config'
|
|
@@ -15,11 +16,9 @@ import { getConfig, isTypeScriptProject } from '@cedarjs/project-config'
|
|
|
15
16
|
import sharedConfigs from './shared.mjs'
|
|
16
17
|
|
|
17
18
|
// Note: This config is async to support getConfig()
|
|
18
|
-
/** @returns {Promise<import('eslint').Linter.FlatConfig[]>} */
|
|
19
19
|
export default async function createConfig() {
|
|
20
20
|
const config = await getConfig()
|
|
21
21
|
|
|
22
|
-
/** @returns {import('@babel/core').TransformOptions} */
|
|
23
22
|
const getProjectBabelOptions = () => {
|
|
24
23
|
// We can't nest the web overrides inside the overrides block
|
|
25
24
|
// So we just take it out and put it as a separate item
|
|
@@ -34,7 +33,7 @@ export default async function createConfig() {
|
|
|
34
33
|
getApiSideDefaultBabelConfig()
|
|
35
34
|
|
|
36
35
|
return {
|
|
37
|
-
plugins:
|
|
36
|
+
plugins: getCommonPlugins(),
|
|
38
37
|
overrides: [
|
|
39
38
|
{
|
|
40
39
|
test: ['./api/', './scripts/'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/eslint-config",
|
|
3
|
-
"version": "5.0.4
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -9,17 +9,31 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"default": "./index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./index.js"
|
|
19
|
+
}
|
|
14
20
|
},
|
|
15
21
|
"./shared": {
|
|
16
|
-
"
|
|
17
|
-
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/shared.d.mts",
|
|
24
|
+
"default": "./shared.mjs"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/shared.d.ts",
|
|
28
|
+
"default": "./shared.js"
|
|
29
|
+
}
|
|
18
30
|
}
|
|
19
31
|
},
|
|
20
|
-
"types": "./dist/index.d.
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
21
33
|
"files": [
|
|
34
|
+
"index.js",
|
|
22
35
|
"index.mjs",
|
|
36
|
+
"shared.js",
|
|
23
37
|
"shared.mjs",
|
|
24
38
|
"dist"
|
|
25
39
|
],
|
|
@@ -32,13 +46,18 @@
|
|
|
32
46
|
"@babel/core": "^7.26.10",
|
|
33
47
|
"@babel/eslint-parser": "7.29.7",
|
|
34
48
|
"@babel/eslint-plugin": "7.29.7",
|
|
35
|
-
"@cedarjs/babel-config": "5.0.4
|
|
36
|
-
"@cedarjs/eslint-plugin": "5.0.4
|
|
37
|
-
"@cedarjs/
|
|
49
|
+
"@cedarjs/babel-config": "5.0.4",
|
|
50
|
+
"@cedarjs/eslint-plugin": "5.0.4",
|
|
51
|
+
"@cedarjs/internal": "5.0.4",
|
|
52
|
+
"@cedarjs/project-config": "5.0.4",
|
|
38
53
|
"@eslint/js": "8.57.1",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "8.60.1",
|
|
55
|
+
"@typescript-eslint/parser": "8.60.1",
|
|
39
56
|
"eslint": "8.57.1",
|
|
40
57
|
"eslint-config-prettier": "10.1.8",
|
|
41
|
-
"eslint-
|
|
58
|
+
"eslint-import-resolver-babel-module": "5.3.2",
|
|
59
|
+
"eslint-plugin-babel": "5.3.1",
|
|
60
|
+
"eslint-plugin-import-x": "4.16.2",
|
|
42
61
|
"eslint-plugin-jest-dom": "5.5.0",
|
|
43
62
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
44
63
|
"eslint-plugin-prettier": "5.5.6",
|
|
@@ -48,6 +67,7 @@
|
|
|
48
67
|
"typescript-eslint": "8.60.1"
|
|
49
68
|
},
|
|
50
69
|
"devDependencies": {
|
|
70
|
+
"@babel/cli": "7.29.7",
|
|
51
71
|
"typescript": "5.9.3"
|
|
52
72
|
},
|
|
53
73
|
"peerDependencies": {
|
package/shared.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// This ESLint configuration is shared between the Redwood framework,
|
|
2
|
+
// and Redwood projects.
|
|
3
|
+
//
|
|
4
|
+
// Our ESLint configuration is a mixture between ESLint's recommended
|
|
5
|
+
// rules [^1], React's recommended rules [^2], and a bit of our own stylistic
|
|
6
|
+
// flair:
|
|
7
|
+
// - no semicolons
|
|
8
|
+
// - comma dangle when multiline
|
|
9
|
+
// - single quotes
|
|
10
|
+
// - always use parenthesis around arrow functions
|
|
11
|
+
// - enforced import sorting
|
|
12
|
+
//
|
|
13
|
+
// [^1] https://eslint.org/docs/rules/
|
|
14
|
+
// [^2] https://www.npmjs.com/package/eslint-plugin-react#list-of-supported-rules
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
extends: [
|
|
18
|
+
'eslint:recommended',
|
|
19
|
+
'plugin:react/recommended',
|
|
20
|
+
'plugin:prettier/recommended',
|
|
21
|
+
'plugin:jest-dom/recommended',
|
|
22
|
+
],
|
|
23
|
+
// @NOTE parserOptions defined separately for project and framework
|
|
24
|
+
parser: '@babel/eslint-parser',
|
|
25
|
+
plugins: [
|
|
26
|
+
'prettier',
|
|
27
|
+
'@babel',
|
|
28
|
+
'import-x',
|
|
29
|
+
'jsx-a11y',
|
|
30
|
+
'react',
|
|
31
|
+
'react-hooks',
|
|
32
|
+
'jest-dom',
|
|
33
|
+
'@cedarjs',
|
|
34
|
+
],
|
|
35
|
+
// In addition to this, eslint also has some implicit ignore patterns, like
|
|
36
|
+
// `node_modules`.
|
|
37
|
+
// See https://eslint.org/docs/latest/use/configure/ignore-deprecated
|
|
38
|
+
ignorePatterns: ['dist'],
|
|
39
|
+
settings: {
|
|
40
|
+
react: {
|
|
41
|
+
version: 'detect',
|
|
42
|
+
},
|
|
43
|
+
// For the import/order rule. Configures how it tells if an import is "internal" or not.
|
|
44
|
+
// An "internal" import is basically just one that's aliased.
|
|
45
|
+
//
|
|
46
|
+
// See...
|
|
47
|
+
// - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#groups-array
|
|
48
|
+
// - https://github.com/import-js/eslint-plugin-import/blob/main/README.md#importinternal-regex
|
|
49
|
+
'import-x/internal-regex': '^src/',
|
|
50
|
+
},
|
|
51
|
+
rules: {
|
|
52
|
+
'@cedarjs/process-env-computed': 'error',
|
|
53
|
+
'prettier/prettier': 'warn',
|
|
54
|
+
'no-console': 'off',
|
|
55
|
+
'prefer-object-spread': 'warn',
|
|
56
|
+
'prefer-spread': 'warn',
|
|
57
|
+
'no-unused-expressions': [
|
|
58
|
+
'error',
|
|
59
|
+
{ allowShortCircuit: true, allowTernary: true },
|
|
60
|
+
],
|
|
61
|
+
'no-useless-escape': 'off',
|
|
62
|
+
camelcase: ['warn', { properties: 'never' }],
|
|
63
|
+
'no-new': 'warn',
|
|
64
|
+
'new-cap': ['error', { newIsCap: true, capIsNew: false }],
|
|
65
|
+
'no-unused-vars': [
|
|
66
|
+
'error',
|
|
67
|
+
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
|
|
68
|
+
],
|
|
69
|
+
// React rules
|
|
70
|
+
'react/prop-types': 'off',
|
|
71
|
+
'react/display-name': 'off',
|
|
72
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
73
|
+
'import-x/order': [
|
|
74
|
+
'error',
|
|
75
|
+
{
|
|
76
|
+
'newlines-between': 'always',
|
|
77
|
+
// We set this to an empty array to override the default value, which is `['builtin', 'external', 'object']`.
|
|
78
|
+
// Judging by the number of issues on the repo, this option seems to be notoriously tricky to understand.
|
|
79
|
+
// From what I can tell, if the value of this is `['builtin']` that means it won't sort builtins.
|
|
80
|
+
// But we have a rule for builtins below (react), so that's not what we want.
|
|
81
|
+
//
|
|
82
|
+
// See...
|
|
83
|
+
// - https://github.com/import-js/eslint-plugin-import/pull/1570
|
|
84
|
+
// - https://github.com/import-js/eslint-plugin-import/issues/1565
|
|
85
|
+
pathGroupsExcludedImportTypes: [],
|
|
86
|
+
// Only doing this to add internal. The order here maters.
|
|
87
|
+
// See https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#groups-array
|
|
88
|
+
groups: [
|
|
89
|
+
'builtin',
|
|
90
|
+
'external',
|
|
91
|
+
'internal',
|
|
92
|
+
'parent',
|
|
93
|
+
'sibling',
|
|
94
|
+
'index',
|
|
95
|
+
],
|
|
96
|
+
pathGroups: [
|
|
97
|
+
{
|
|
98
|
+
pattern: 'react',
|
|
99
|
+
group: 'builtin',
|
|
100
|
+
position: 'after',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
pattern: '@cedarjs/**',
|
|
104
|
+
group: 'external',
|
|
105
|
+
position: 'after',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
// Matches...
|
|
109
|
+
// - src/directives/**/*.{js,ts}
|
|
110
|
+
// - src/services/**/*.{js,ts}
|
|
111
|
+
// - src/graphql/**/*.sdl.{js,ts}
|
|
112
|
+
//
|
|
113
|
+
// Uses https://github.com/isaacs/minimatch under the hood
|
|
114
|
+
// See https://github.com/isaacs/node-glob#glob-primer for syntax
|
|
115
|
+
pattern: 'src/*/**/*.?(sdl.){js,ts}',
|
|
116
|
+
patternOptions: {
|
|
117
|
+
nobrace: true,
|
|
118
|
+
noglobstar: true,
|
|
119
|
+
},
|
|
120
|
+
group: 'internal',
|
|
121
|
+
position: 'before',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
alphabetize: {
|
|
125
|
+
order: 'asc',
|
|
126
|
+
caseInsensitive: true,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
'no-restricted-imports': [
|
|
131
|
+
'error',
|
|
132
|
+
{
|
|
133
|
+
patterns: [
|
|
134
|
+
{
|
|
135
|
+
group: ['$api/*'],
|
|
136
|
+
message:
|
|
137
|
+
'Importing from $api is only supported in *.routeHooks.{js,ts} files',
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
overrides: [
|
|
144
|
+
{
|
|
145
|
+
files: ['*.tsx', '*.js', '*.jsx'],
|
|
146
|
+
excludedFiles: ['api/src/**'],
|
|
147
|
+
rules: {
|
|
148
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
files: ['*.ts', '*.tsx'],
|
|
153
|
+
parser: '@typescript-eslint/parser',
|
|
154
|
+
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
|
|
155
|
+
rules: {
|
|
156
|
+
// TODO: look into enabling these eventually
|
|
157
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
158
|
+
'@typescript-eslint/prefer-function-type': 'off',
|
|
159
|
+
|
|
160
|
+
// Specific 'recommended' rules we alter
|
|
161
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
162
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
163
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
164
|
+
'@typescript-eslint/no-unused-vars': [
|
|
165
|
+
'error',
|
|
166
|
+
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
files: ['*.test.*', '**/__mocks__/**'],
|
|
172
|
+
env: {
|
|
173
|
+
node: true,
|
|
174
|
+
es6: true,
|
|
175
|
+
commonjs: true,
|
|
176
|
+
jest: true,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
files: [
|
|
181
|
+
'.babelrc.js',
|
|
182
|
+
'babel.config.js',
|
|
183
|
+
'.eslintrc.js',
|
|
184
|
+
'*.config.js',
|
|
185
|
+
'*.config.cjs',
|
|
186
|
+
'jest.setup.js',
|
|
187
|
+
],
|
|
188
|
+
env: {
|
|
189
|
+
node: true,
|
|
190
|
+
commonjs: true,
|
|
191
|
+
jest: true,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
files: [
|
|
196
|
+
'web/src/**/*.routeHooks.{js,ts}',
|
|
197
|
+
'web/src/entry.server.{jsx,tsx}',
|
|
198
|
+
],
|
|
199
|
+
rules: { 'no-restricted-imports': 'off' },
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
}
|
package/shared.mjs
CHANGED
|
@@ -26,10 +26,7 @@ import tseslint from 'typescript-eslint'
|
|
|
26
26
|
|
|
27
27
|
import cedarjsPlugin from '@cedarjs/eslint-plugin'
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
// otherwise the JSDoc below wouldn't attach it's type info properly
|
|
31
|
-
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
32
|
-
const sharedConfigs = [
|
|
29
|
+
export default [
|
|
33
30
|
// Base recommended config
|
|
34
31
|
js.configs.recommended,
|
|
35
32
|
|
|
@@ -273,5 +270,3 @@ const sharedConfigs = [
|
|
|
273
270
|
},
|
|
274
271
|
},
|
|
275
272
|
]
|
|
276
|
-
|
|
277
|
-
export default sharedConfigs
|