Skip to content

Commit 3b9c0de

Browse files
committed
Adjust rules based on trial
1 parent 428b848 commit 3b9c0de

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

src/typescript.rules.test.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ describe('semver for TypeScript rules - should those tests break, consider relea
1414
expect(computed).toMatchInlineSnapshot(`
1515
Object {
1616
"env": Object {
17+
"browser": true,
18+
"commonjs": true,
1719
"es6": true,
20+
"jest": true,
1821
"node": true,
1922
},
2023
"globals": Object {},
@@ -171,7 +174,7 @@ describe('semver for TypeScript rules - should those tests break, consider relea
171174
"error",
172175
],
173176
"@typescript-eslint/no-var-requires": Array [
174-
"error",
177+
0,
175178
],
176179
"@typescript-eslint/object-curly-spacing": Array [
177180
"off",
@@ -3004,4 +3007,42 @@ describe('semver for TypeScript rules - should those tests break, consider relea
30043007
}
30053008
`);
30063009
});
3010+
3011+
it('has stable overrides', () => {
3012+
/**
3013+
* Overrides are snapshotted directly because:
3014+
* - They aren’t computed in the base configuration (which snapshots the configuration for a `.js` file).
3015+
* - They’re only at the top level, so it’s enough to snapshot their top-level definition only.
3016+
*/
3017+
expect(config.overrides).toMatchInlineSnapshot(`
3018+
Array [
3019+
Object {
3020+
"files": Array [
3021+
"*.ts",
3022+
"*.tsx",
3023+
],
3024+
"rules": Object {
3025+
"constructor-super": "off",
3026+
"getter-return": "off",
3027+
"import/named": "off",
3028+
"import/no-unresolved": "off",
3029+
"no-const-assign": "off",
3030+
"no-dupe-args": "off",
3031+
"no-dupe-class-members": "off",
3032+
"no-dupe-keys": "off",
3033+
"no-func-assign": "off",
3034+
"no-new-symbol": "off",
3035+
"no-obj-calls": "off",
3036+
"no-redeclare": "off",
3037+
"no-this-before-super": "off",
3038+
"no-undef": "off",
3039+
"no-unreachable": "off",
3040+
"no-unsafe-negation": "off",
3041+
"react/require-default-props": 0,
3042+
"valid-typeof": "off",
3043+
},
3044+
},
3045+
]
3046+
`);
3047+
});
30073048
});

typescript.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ module.exports = {
273273
'node_modules/@types',
274274
],
275275
},
276+
env: {
277+
...base.env,
278+
},
276279
rules: {
277280
...base.rules,
278281
...airbnbTypeScript,
@@ -289,13 +292,18 @@ module.exports = {
289292
},
290293
],
291294
'react/jsx-filename-extension': [2, { extensions: ['.js', '.tsx'] }],
295+
// Disabled so we can lint Node files (Webpack, Vite, Jest) more easily.
296+
'@typescript-eslint/no-var-requires': 0,
292297
},
293298
overrides: [
294299
{
295-
// Copy from eslint-config-airbnb-typescript
296-
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/d30b7d2a41f3f2cf899cad3ed69e3b7eacbc7234/lib/shared.js#L256
297300
files: ['*.ts', '*.tsx'],
298301
rules: {
302+
// This is not needed in TypeScript, where `defaultProps` aren’t used,
303+
// and function default parameters are introspect-able by the type checker.
304+
'react/require-default-props': 0,
305+
// Copy from eslint-config-airbnb-typescript
306+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/d30b7d2a41f3f2cf899cad3ed69e3b7eacbc7234/lib/shared.js#L256
299307
// The following rules are enabled in Airbnb config, but are already checked (more thoroughly) by the TypeScript compiler
300308
// Some of the rules also fail in TypeScript files, for example: https://github.com/typescript-eslint/typescript-eslint/issues/662#issuecomment-507081586
301309
'constructor-super': 'off',

0 commit comments

Comments
 (0)