jshint:简单的javascript文件中的“使用“严格使用”的功能形式”和“未定义文档”

时间:2018-10-14 21:38:52

标签: javascript jshint

我将它们捆绑在一起,因为我认为它们是相关的。 最简单的代码:

'use strict';
const x = document.querySelector('#score strong');

导致以下结果

"use the function form of use strict (W097)"
"document is not defined (W117)"

可能是错误或警告; W提出警告,但我不知道如何确定。

所以,另一个问题是:这些警告或错误,我该如何告诉自己?在哪里引用?

我使用的是Atom 1.31,我认为它是JSHint(无论如何-我对这一切都是陌生的)。我正在使用ES6-.jshintrc:

{
"esversion": 6
}

我应该如何指定全局严格使用?将其放在函数中以便全局使用意味着,将脚本的全部内容放入函数中。没有?是吗?

我该如何规避这个未定义的东西? 我尝试过

const document=this.document;
const document=global.document;
const document=window.document;

所有都会导致警告/错误(无论如何)。

因此,明确地说,我的问题是:

  1. 是这些警告或错误,我该如何告诉自己?

  2. 如何并且确实需要规避使用严格的规定?

  3. 我以及确实需要怎样规避文档未定义的东西?

1 个答案:

答案 0 :(得分:1)

您需要将strict option设置为首选全局val df = spark.read.option("multiLine", true).option("mode", "PERMISSIVE").json("/FileStore/tables/test.json") df.printSchema root |-- data: array (nullable = true) | |-- element: struct (containsNull = true) | | |-- created_on: string (nullable = true) | | |-- id: string (nullable = true) | | |-- links: struct (nullable = true) | | | |-- default: string (nullable = true) | | | |-- edit: string (nullable = true) | | | |-- publish: string (nullable = true) | | |-- team: string (nullable = true) import org.apache.spark.sql.functions.{col, explode} val df1= df.withColumn("data", explode(col("data"))) df1.printSchema root |-- data: struct (nullable = true) | |-- created_on: string (nullable = true) | |-- id: string (nullable = true) | |-- links: struct (nullable = true) | | |-- default: string (nullable = true) | | |-- edit: string (nullable = true) | | |-- publish: string (nullable = true) | |-- team: string (nullable = true) val df2 = df1.select("data.created_on","data.id","data.team","data.links") df2.show +-------------------+-------+------+--------------------+ | created_on| id| team| links| +-------------------+-------+------+--------------------+ |2018-10-09 02:55:51|4619623|452144|[https://some_def...| |2018-10-09 02:42:25|4619600|452144|[https://some_def...| +-------------------+-------+------+--------------------+ df2.write.partitionBy("id").json("FileStore/tables/test_part.json") val f = spark.read.json("/FileStore/tables/test_part.json/id=4619600") f.show +-------------------+--------------------+------+ | created_on| links| team| +-------------------+--------------------+------+ |2018-10-09 02:42:25|[https://some_def...|452144| +-------------------+--------------------+------+ val full = spark.read.json("/FileStore/tables/test_part.json") full.show +-------------------+--------------------+------+-------+ | created_on| links| team| id| +-------------------+--------------------+------+-------+ |2018-10-09 02:55:51|[https://some_def...|452144|4619623| |2018-10-09 02:42:25|[https://some_def...|452144|4619600| +-------------------+--------------------+------+-------+ ,并将browser option设置为告诉JSHint您的脚本以浏览器为目标。

.jshintrc

'use strict'

是的,代码开头的“ W”表示“警告”。

相关问题