mirror of https://github.com/microsoft/vscode.git
Fix eslint not linting our custom eslint rules
This commit is contained in:
parent
79abfa3cef
commit
6b3e9f6759
|
@ -37,4 +37,5 @@
|
|||
**/test/unit/assert.js
|
||||
**/test/automation/out/**
|
||||
**/typings/**
|
||||
**/.build/**
|
||||
!.vscode
|
||||
|
|
|
@ -51,7 +51,7 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
|
|||
node,
|
||||
messageId: 'amdX'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
['ImportExpression Literal']: checkImport,
|
||||
|
|
|
@ -19,7 +19,7 @@ export = new class DeclareServiceBrand implements eslint.Rule.RuleModule {
|
|||
node,
|
||||
message: `The '_serviceBrand'-property should not have a value`,
|
||||
fix: (fixer) => {
|
||||
return fixer.replaceText(node, 'declare _serviceBrand: undefined;')
|
||||
return fixer.replaceText(node, 'declare _serviceBrand: undefined;');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ export = new class EnsureNoDisposablesAreLeakedInTestSuite implements eslint.Rul
|
|||
|
||||
return {
|
||||
[`Program > ExpressionStatement > CallExpression[callee.name='suite']`]: (node: Node) => {
|
||||
const src = context.getSourceCode().getText(node)
|
||||
const src = context.getSourceCode().getText(node);
|
||||
if (!src.includes('ensureNoDisposablesAreLeakedInTestSuite(')) {
|
||||
context.report({
|
||||
node,
|
||||
|
|
|
@ -14,13 +14,13 @@ export = new class implements eslint.Rule.RuleModule {
|
|||
layerbreaker: 'You are only allowed to define limited top level functions.'
|
||||
},
|
||||
schema: {
|
||||
type: "array",
|
||||
type: 'array',
|
||||
items: {
|
||||
type: "object",
|
||||
type: 'object',
|
||||
additionalProperties: {
|
||||
type: "array",
|
||||
type: 'array',
|
||||
items: {
|
||||
type: "string"
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,6 @@ export = new class implements eslint.Rule.RuleModule {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,22 +14,22 @@ const VALID_USES = new Set<TSESTree.AST_NODE_TYPES | undefined>([
|
|||
export = new class MustUseResults implements eslint.Rule.RuleModule {
|
||||
readonly meta: eslint.Rule.RuleMetaData = {
|
||||
schema: false
|
||||
}
|
||||
};
|
||||
|
||||
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
|
||||
|
||||
const config = <{ message: string, functions: string[] }[]>context.options[0];
|
||||
const config = <{ message: string; functions: string[] }[]>context.options[0];
|
||||
const listener: eslint.Rule.RuleListener = {};
|
||||
|
||||
for (const { message, functions } of config) {
|
||||
for (const fn of functions) {
|
||||
const query = `CallExpression[callee.property.name='${fn}'], CallExpression[callee.name='${fn}']`
|
||||
const query = `CallExpression[callee.property.name='${fn}'], CallExpression[callee.name='${fn}']`;
|
||||
listener[query] = (node: any) => {
|
||||
const cast: TSESTree.CallExpression = node;
|
||||
if (!VALID_USES.has(cast.parent?.type)) {
|
||||
context.report({ node, message });
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ export = new class NoAsyncSuite implements eslint.Rule.RuleModule {
|
|||
return;
|
||||
}
|
||||
|
||||
const body = context.getSourceCode().getText(node)
|
||||
const body = context.getSourceCode().getText(node);
|
||||
|
||||
if (body.includes('super.dispose')) {
|
||||
return;
|
||||
|
|
|
@ -32,7 +32,7 @@ export = new class NoDangerousTypeAssertions implements eslint.Rule.RuleModule {
|
|||
|
||||
context.report({
|
||||
node,
|
||||
message: "Don't use type assertions for creating objects as this can hide type errors."
|
||||
message: `Don't use type assertions for creating objects as this can hide type errors.`
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -25,6 +25,6 @@ export = new class NoGlobalDocumentListener implements eslint.Rule.RuleModule {
|
|||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -16,13 +16,13 @@ export = new class implements eslint.Rule.RuleModule {
|
|||
layerbreaker: 'You are only allowed to import {{import}} from here using `import type ...`.'
|
||||
},
|
||||
schema: {
|
||||
type: "array",
|
||||
type: 'array',
|
||||
items: {
|
||||
type: "object",
|
||||
type: 'object',
|
||||
additionalProperties: {
|
||||
type: "array",
|
||||
type: 'array',
|
||||
items: {
|
||||
type: "string"
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,19 +26,19 @@ export = new class implements eslint.Rule.RuleModule {
|
|||
return;
|
||||
}
|
||||
|
||||
const classCtor = classDeclaration.body.body.find(node => node.type === 'MethodDefinition' && node.kind === 'constructor')
|
||||
const classCtor = classDeclaration.body.body.find(node => node.type === 'MethodDefinition' && node.kind === 'constructor');
|
||||
|
||||
if (!classCtor) {
|
||||
return;
|
||||
}
|
||||
|
||||
const name = classDeclaration.id.name;
|
||||
const valueText = context.sourceCode.getText(<any>propertyDefinition.value)
|
||||
const valueText = context.sourceCode.getText(<any>propertyDefinition.value);
|
||||
|
||||
if (valueText.includes(name + '.')) {
|
||||
|
||||
if (classCtor.value?.type === 'FunctionExpression' && !classCtor.value.params.find((param: any) => param.type === 'TSParameterProperty' && param.decorators?.length > 0)) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
context.report({
|
||||
|
|
|
@ -58,7 +58,7 @@ module.exports = {
|
|||
allowTernary = config.allowTernary || false,
|
||||
allowTaggedTemplates = config.allowTaggedTemplates || false;
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
|
||||
/**
|
||||
* @param node any node
|
||||
* @returns whether the given node structurally represents a directive
|
||||
|
@ -68,7 +68,7 @@ module.exports = {
|
|||
node.expression.type === 'Literal' && typeof node.expression.value === 'string';
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
|
||||
/**
|
||||
* @param predicate ([a] -> Boolean) the function used to make the determination
|
||||
* @param list the input list
|
||||
|
@ -83,7 +83,7 @@ module.exports = {
|
|||
return list.slice();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
|
||||
/**
|
||||
* @param node a Program or BlockStatement node
|
||||
* @returns the leading sequence of directive nodes in the given node's body
|
||||
|
@ -92,7 +92,7 @@ module.exports = {
|
|||
return takeWhile(looksLikeDirective, node.body);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
|
||||
/**
|
||||
* @param node any node
|
||||
* @param ancestors the given node's ancestors
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ export = new class ApiTypeDiscrimination implements eslint.Rule.RuleModule {
|
|||
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
|
||||
return {
|
||||
['TSPropertySignature[optional=false] TSTypeAnnotation TSLiteralType Literal']: (node: any) => {
|
||||
const raw = String((<TSESTree.Literal>node).raw)
|
||||
const raw = String((<TSESTree.Literal>node).raw);
|
||||
|
||||
if (/^('|").*\1$/.test(raw)) {
|
||||
|
||||
|
@ -29,6 +29,6 @@ export = new class ApiTypeDiscrimination implements eslint.Rule.RuleModule {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -206,6 +206,7 @@ module.exports.eslintFilter = [
|
|||
'**/*.cjs',
|
||||
'**/*.mjs',
|
||||
'**/*.ts',
|
||||
'.eslint-plugin-local/**/*.ts',
|
||||
...readFileSync(join(__dirname, '..', '.eslint-ignore'))
|
||||
.toString()
|
||||
.split(/\r\n|\n/)
|
||||
|
|
|
@ -24,7 +24,10 @@ const ignores = fs.readFileSync(path.join(__dirname, '.eslint-ignore'), 'utf8')
|
|||
export default tseslint.config(
|
||||
// Global ignores
|
||||
{
|
||||
ignores,
|
||||
ignores: [
|
||||
...ignores,
|
||||
'!**/.eslint-plugin-local/**/*'
|
||||
],
|
||||
},
|
||||
// All files (JS and TS)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue