Skip to content
This repository was archived by the owner on Jan 14, 2019. It is now read-only.

"use strict"/etc directives should be labeled as such #2

Closed
JamesHenry opened this issue Sep 22, 2018 · 3 comments
Closed

"use strict"/etc directives should be labeled as such #2

JamesHenry opened this issue Sep 22, 2018 · 3 comments

Comments

@JamesHenry
Copy link
Owner

It is now been part of the ESTree spec for a while: eslint/typescript-eslint-parser#267

Prettier is currently having to work around this

@armano2
Copy link
Contributor

armano2 commented Dec 20, 2018

@JamesHenry Fix for this is easy, but its not supported by babel:

    case SyntaxKind.ExpressionStatement: {
      Object.assign(result, {
        type: AST_NODE_TYPES.ExpressionStatement,
        expression: convertChild(node.expression)
      });
      if (
        parent &&
        (ts.isSourceFile(parent) ||
          (ts.isBlock(parent) &&
            parent.parent &&
            (ts.isMethodDeclaration(parent.parent) ||
              ts.isGetAccessorDeclaration(parent.parent) ||
              ts.isSetAccessorDeclaration(parent.parent) ||
              ts.isFunctionDeclaration(parent.parent) ||
              ts.isConstructorDeclaration(parent.parent)))) &&
        ts.isStringLiteral(node.expression) &&
        (result.expression as any).type === AST_NODE_TYPES.Literal
      ) {
        (result as any).directive = (result.expression as any).raw.slice(1, -1);
      }
      break;
    }

and i'm going to have to do disable alignment tests for:

/tests/fixtures/javascript/arrowFunctions/error-strict-default-param-eval.src.js
/tests/fixtures/javascript/arrowFunctions/error-strict-eval-return.src.js
/tests/fixtures/javascript/arrowFunctions/error-strict-eval.src.js
/tests/fixtures/javascript/arrowFunctions/error-strict-param-arguments.src.js
/tests/fixtures/javascript/arrowFunctions/error-strict-param-eval.src.js
/tests/fixtures/javascript/arrowFunctions/error-strict-param-names.src.js
/tests/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-arguments.src.js
/tests/fixtures/javascript/arrowFunctions/error-strict-param-no-paren-eval.src.js
/tests/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-properties.src.js
/tests/fixtures/javascript/objectLiteralDuplicateProperties/strict-duplicate-string-properties.src.js
/tests/fixtures/javascript/octalLiterals/strict-uppercase.src.js
/tests/fixtures/javascript/unicodeCodePointEscapes/basic-string-literal.src.js
/tests/fixtures/javascript/unicodeCodePointEscapes/complex-string-literal.src.js

@armano2
Copy link
Contributor

armano2 commented Dec 24, 2018

@JamesHenry should we implement this and turn off alignment tests?

@armano2
Copy link
Contributor

armano2 commented Dec 25, 2018

@JamesHenry nvm i found out that babel is supporting this, but we was stripping directives from code. i will implement this today

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants