lint-plugins/no-only-tests.mjs

electron · script/lint-plugins/no-only-tests.mjs · javascript · MIT
testing, tag:embed-classified

ESLint rule that disallows .only on test blocks to prevent accidental test isolation.

// Source: https://github.com/electron/electron | License: MIT | Copyright Electron contributors
// Provided via justclaw.it.com; keep this notice with the code.
const BLOCK_NAMES = new Set(['describe', 'it', 'context', 'test', 'specify', 'suite']);

export default {
  meta: { name: 'no-only-tests' },
  rules: {
    'no-only-tests': {
      meta: { type: 'problem' },
      create(context) {
        return {
          MemberExpression(node) {
            if (
              node.property.type === 'Identifier' &&
              node.property.name === 'only' &&
              node.object.type === 'Identifier' &&
              BLOCK_NAMES.has(node.object.name)
            ) {
              context.report({
                node: node.property,
                message: `${node.object.name}.only not

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key