Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Dependencies and build outputs
node_modules
bazel-*
dist
tmp

# Test fixture projects (mock dataform project fixtures)
tests/api/projects/
tests/integration/bigquery_project/
tests/integration/property_graph_project/
67 changes: 58 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,53 @@
/**
* ESLint config for the Dataform CLI & Core repo.
*
* Scope: currently only used to enforce sandbox-safety rules in `core/`.
* The rest of the codebase is still linted by tslint (see tslint.json).
* Add ESLint rules here only when they need capabilities tslint 5.17 cannot
* express (per-file `overrides`, per-message text, AST rules, etc.).
* ESLint config for the Dataform repository.
*/
module.exports = {
root: true,
ignorePatterns: [
'bazel-*',
'node_modules',
'tests/api/projects/**',
'tests/integration/*_project/**',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
env: {
es2020: true,
node: true,
},
rules: {
'prefer-const': 'error',
'no-var': 'error',
'no-debugger': 'error',
'no-duplicate-imports': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'curly': 'error',
'eqeqeq': ['error', 'smart'],
'no-unused-expressions': 'error',
'no-console': 'error',
'no-eval': 'error',
'no-throw-literal': 'error',
'radix': 'error',
'no-cond-assign': 'error',
'no-unsafe-finally': 'error',
'no-caller': 'error',
'use-isnan': 'error',
'no-self-assign': 'error',
'no-shadow-restricted-names': 'error',
'ordered-imports': 'error',
'no-new-func': 'error',
},
overrides: [
{
// JIT compiler dynamically creates executable functions in the V8 sandbox
files: ['core/jit_compiler.ts'],
rules: {
'no-new-func': 'off',
},
},
{
// core/ runs inside the V8 compilation sandbox — no Node built-ins.
files: ['core/**/*.ts'],
Expand All @@ -22,11 +56,26 @@ module.exports = {
},
},
{
// Tests under core/ run on the host Node runtime, not in the sandbox,
// so they may legitimately use fs, path, etc. for fixture setup.
files: ['core/**/*_test.ts', 'core/**/*.test.ts'],
// Ambient declarations for webpack internals
files: ['core/utils.ts', 'core/workflow_settings.ts'],
rules: {
'no-var': 'off',
},
},
{
// Tests, testing helpers, examples, CLI console wrapper, VSCode extension, and common promises logger may use console
files: [
'**/*_test.ts',
'**/*.test.ts',
'testing/**/*.ts',
'examples/**/*.ts',
'cli/console.ts',
'vscode/**/*.ts',
'common/promises/index.ts',
],
rules: {
'no-node-builtins': 'off',
'no-console': 'off',
},
},
],
Expand Down
12 changes: 7 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ nodejs_binary(
)

nodejs_binary(
name = "tslint",
name = "eslint",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note on nodejs_binary(name = "eslint", ...):
Running bazel run //:eslint -- --rulesdir eslint-rules '**/*.ts' executes inside Bazel's sandbox runfiles directory, where repository source **/*.ts files are not present. Invoking through @npm//eslint/bin:eslint via ./scripts/lint works as expected and mirrors how TSLint was previously run.

data = [
"@npm//tslint",
],
entry_point = "@npm//:node_modules/tslint/bin/tslint",
templated_args = ["--node_options=--preserve-symlinks"],
".eslintrc.js",
".eslintignore",
"@npm//@typescript-eslint/parser",
"@npm//eslint",
] + glob(["eslint-rules/**"]),
entry_point = "@npm//:node_modules/eslint/bin/eslint.js",
)

load("@bazel_gazelle//:def.bzl", "gazelle")
Expand Down
6 changes: 0 additions & 6 deletions cli/api/commands/tslint.json

This file was deleted.

6 changes: 0 additions & 6 deletions cli/api/dbadapters/tslint.json

This file was deleted.

1 change: 0 additions & 1 deletion cli/index_compile_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ SELECT 1 as id
schema: "dataform"
},
query:
// tslint:disable-next-line:tsr-detect-sql-literal-injection
`\nSELECT\n *\nFROM (\n SELECT\n id,\n COUNT(1) AS index_row_count\n FROM \`${INTEGRATION_TEST_PROJECT}.dataform.example_table\`\n GROUP BY id\n ) AS data\nWHERE index_row_count > 1\n`,
target: {
database: INTEGRATION_TEST_PROJECT,
Expand Down
6 changes: 0 additions & 6 deletions cli/index_run_e2e_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ select 1 as \${dataform.projectConfig.vars.testVar2}
);

if (runResult.exitCode !== 0 || runResult.stdout.trim().length === 0) {
// tslint:disable-next-line:no-console
console.error("GOLDEN PATH FAILED. STDERR:", runResult.stderr);
}
expect(runResult.exitCode).equals(0);
Expand All @@ -130,7 +129,6 @@ select 1 as \${dataform.projectConfig.vars.testVar2}
tasks: [
{
statement:
// tslint:disable-next-line:tsr-detect-sql-literal-injection
`create or replace table \`${INTEGRATION_TEST_PROJECT}.dataform.example\` as \n\nselect 1 as testValue2`,
type: "statement"
}
Expand Down Expand Up @@ -204,7 +202,6 @@ SELECT 1 as id
tasks: [
{
statement:
// tslint:disable-next-line:tsr-detect-sql-literal-injection
`create or replace table \`${INTEGRATION_TEST_PROJECT}.dataform.example_table\` as \n\nSELECT 1 as id`,
type: "statement"
}
Expand Down Expand Up @@ -255,7 +252,6 @@ SELECT 1 as id
);

if (runResult.exitCode !== 0 || runResult.stdout.trim().length === 0) {
// tslint:disable-next-line:no-console
console.error("ASSERTIONS TEST FAILED. STDERR:", runResult.stderr);
}
expect(runResult.exitCode).equals(0);
Expand All @@ -278,7 +274,6 @@ SELECT 1 as id
);

if (runResult.exitCode !== 0 || runResult.stdout.trim().length === 0) {
// tslint:disable-next-line:no-console
console.error("ASSERTIONS TEST FAILED. STDERR:", runResult.stderr);
}
expect(runResult.exitCode).equals(0);
Expand All @@ -303,7 +298,6 @@ SELECT 1 as id
);

if (runResult.exitCode !== 0 || runResult.stdout.trim().length === 0) {
// tslint:disable-next-line:no-console
console.error("ASSERTIONS TEST FAILED. STDERR:", runResult.stderr);
}
expect(runResult.exitCode).equals(0);
Expand Down
1 change: 0 additions & 1 deletion cli/index_test_base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { execFile, ExecFileOptions } from "child_process";
import * as fs from "fs-extra";
import { dump as dumpYaml, load as loadYaml } from "js-yaml";
Expand Down
2 changes: 0 additions & 2 deletions cli/tests/jit/jit_run_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,12 @@ suite("run", () => {
const [executedSql] = capture(mockAdapter.execute).last();
// For BigQuery, it should be an 'insert into' because no uniqueKey was specified.
// We check for substrings without trailing spaces to avoid exact whitespace mismatches.
// tslint:disable: tsr-detect-sql-literal-injection
expect(executedSql).to.equal(
"insert into `db.sch.incremental_jit` \n" +
"(`t`) \n" +
"select `t` \n" +
"from (SELECT 'inc' as t) as insertions"
);
// tslint:enable: tsr-detect-sql-literal-injection
});

test("JiT compilation with RPC calls (ListTables, GetTable, DeleteTable)", async () => {
Expand Down
6 changes: 0 additions & 6 deletions cli/tslint.json

This file was deleted.

1 change: 0 additions & 1 deletion common/promises/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export function runAsyncIgnoringErrors(promise: Promise<any>) {
// tslint:disable-next-line: no-console
promise.catch(e => console.error(`runAsyncIgnoringErrors caught error: ${e}`));
}

Expand Down
1 change: 0 additions & 1 deletion common/strings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export function timingSafeEqual(a: string, b: string) {
}

for (let i = 0; i < a.length; i++) {
// tslint:disable-next-line: no-bitwise
result |= a.charCodeAt(i) ^ b.charCodeAt(i);
}

Expand Down
1 change: 0 additions & 1 deletion core/actions/assertion_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import { dump as dumpYaml } from "js-yaml";
Expand Down
1 change: 0 additions & 1 deletion core/actions/data_preparation_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import { dump as dumpYaml, load as loadYaml } from "js-yaml";
Expand Down
1 change: 0 additions & 1 deletion core/actions/declaration_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import * as path from "path";
Expand Down
1 change: 0 additions & 1 deletion core/actions/filename_override_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import * as path from "path";
Expand Down
1 change: 0 additions & 1 deletion core/actions/incremental_table_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import * as path from "path";
Expand Down
1 change: 0 additions & 1 deletion core/actions/index_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import * as path from "path";
Expand Down
1 change: 0 additions & 1 deletion core/actions/notebook_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import * as path from "path";
Expand Down
1 change: 0 additions & 1 deletion core/actions/operation_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import * as path from "path";
Expand Down
1 change: 0 additions & 1 deletion core/actions/table_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import * as path from "path";
Expand Down
1 change: 0 additions & 1 deletion core/actions/test_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import * as path from "path";
Expand Down
1 change: 0 additions & 1 deletion core/actions/view_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import * as path from "path";
Expand Down
6 changes: 0 additions & 6 deletions core/compilation_sql/tslint.json

This file was deleted.

1 change: 0 additions & 1 deletion core/jit_compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { dataform } from "df/protos/ts";
function makeMainBody<Context, T>(code: string): (jctx: JitContext<Context>) => Promise<T> {
return (
jctx => {
// tslint:disable-next-line: tsr-detect-eval-with-expression
const body = new Function(
"jctx", `const mainAsync = ${code};\nreturn mainAsync(jctx);`
) as (jctx: JitContext<Context>) => Promise<T>;
Expand Down
4 changes: 0 additions & 4 deletions core/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ function loadActionConfigsFile(
): dataform.ActionConfigs {
let actionConfigsAsJson = {};
try {
// tslint:disable-next-line: tsr-detect-non-literal-require
actionConfigsAsJson = nativeRequire(actionConfigsPath).asJson;
} catch (e) {
session.compileError(e, actionConfigsPath);
Expand Down Expand Up @@ -252,7 +251,6 @@ function loadPropertyGraphs(session: Session, filePaths: string[]) {
const graphPath = graphPaths[0];
let configAsJson: any;
try {
// tslint:disable-next-line: tsr-detect-non-literal-require
configAsJson = snakeToCamelKeys(nativeRequire(graphPath).asJson);
} catch (e) {
session.compileError(e, graphPath);
Expand Down Expand Up @@ -313,7 +311,6 @@ function dataformCompile(compileRequest: dataform.ICompileExecutionRequest, sess
.filter(path => Path.fileExtension(path) === "js")
.forEach(includePath => {
try {
// tslint:disable-next-line: tsr-detect-non-literal-require
topLevelIncludes[Path.basename(includePath)] = nativeRequire(includePath);
} catch (e) {
session.compileError(e, includePath);
Expand Down Expand Up @@ -341,7 +338,6 @@ function dataformCompile(compileRequest: dataform.ICompileExecutionRequest, sess
.sort()
.forEach(definitionPath => {
try {
// tslint:disable-next-line: tsr-detect-non-literal-require
nativeRequire(definitionPath);
} catch (e) {
session.compileError(e, definitionPath);
Expand Down
1 change: 0 additions & 1 deletion core/main_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable tsr-detect-non-literal-fs-filename
import { expect } from "chai";
import * as fs from "fs-extra";
import { dump as dumpYaml } from "js-yaml";
Expand Down
1 change: 0 additions & 1 deletion core/workflow_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ function verifyWorkflowSettingsAsJson(workflowSettingsAsJson: object): dataform.

function maybeRequire(file: string): any {
try {
// tslint:disable-next-line: tsr-detect-non-literal-require
return nativeRequire(file);
} catch (e) {
if (e instanceof SyntaxError || e instanceof YAMLException) {
Expand Down
Loading
Loading