Enable the ESLint no-var rule globally

A significant portion of the code-base has now been converted to use `let`/`const`, rather than `var`, hence it should be possible to simply enable the ESLint `no-var` rule globally.
This way we can ensure that new code won't accidentally use `var`, and it also removes the need to manually enable the rule in various folders.

Obviously it makes sense to continue the efforts to replace `var`, but that should probably happen on a file and/or folder basis.

Please note that this patch excludes the following code:
 - The `extensions/` folder, since that seemed easiest for now (and I don't know exactly what the support situation is for the Chromium-extension).

 - The entire `external/` folder is ignored, since most of it's currently excluded from linting.
   For the code that isn't imported from elsewhere (and should be ignored), we should probably (at some point) bring the code up to the same linting/formatting standard as the rest of the code-base.

 - Various files in the `test/` folder are ignored, as necessary, since the way that a lot of this code is loaded will require some care (or perhaps larger re-factoring) when removing `var` usage.
This commit is contained in:
Jonas Jenwald 2021-03-13 15:51:44 +01:00
parent 17c0bf0473
commit 5b5061afa8
22 changed files with 22 additions and 36 deletions

View File

@ -7,7 +7,7 @@ external/webL10n/
external/cmapscompress/ external/cmapscompress/
external/builder/fixtures/ external/builder/fixtures/
external/builder/fixtures_esprima/ external/builder/fixtures_esprima/
external/quickjs/quickjs-eval.js external/quickjs/
src/shared/cffStandardStrings.js src/shared/cffStandardStrings.js
src/shared/fonts_utils.js src/shared/fonts_utils.js
test/tmp/ test/tmp/

View File

@ -197,7 +197,7 @@
"no-useless-computed-key": "error", "no-useless-computed-key": "error",
"no-useless-constructor": "error", "no-useless-constructor": "error",
"no-useless-rename": "error", "no-useless-rename": "error",
"no-var": "off", "no-var": "error",
"object-shorthand": ["error", "always", { "object-shorthand": ["error", "always", {
"avoidQuotes": true, "avoidQuotes": true,
}], }],

View File

@ -8,9 +8,4 @@
"pdfjsLib": false, "pdfjsLib": false,
"pdfjsViewer": false, "pdfjsViewer": false,
}, },
"rules": {
// ECMAScript 6
"no-var": "error",
},
} }

View File

@ -17,6 +17,7 @@
"rules": { "rules": {
"mozilla/import-globals": "error", "mozilla/import-globals": "error",
"no-var": "off",
"object-shorthand": "off", "object-shorthand": "off",
}, },
} }

View File

@ -16,6 +16,7 @@
"rules": { "rules": {
// Items different from the mozilla/recommended configuration. // Items different from the mozilla/recommended configuration.
"no-var": "off",
// Other rules mozilla/recommended hasn't enabled yet. // Other rules mozilla/recommended hasn't enabled yet.
"no-shadow": "error", "no-shadow": "error",

5
external/.eslintrc vendored
View File

@ -6,4 +6,9 @@
"env": { "env": {
"node": true, "node": true,
}, },
"rules": {
// ECMAScript 6
"no-var": "off",
},
} }

View File

@ -13,7 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
/* eslint-env node */ /* eslint-env node */
/* eslint no-var: error */
/* globals target */ /* globals target */
"use strict"; "use strict";

View File

@ -1,10 +0,0 @@
{
"extends": [
"../.eslintrc"
],
"rules": {
// ECMAScript 6
"no-var": "error",
},
}

View File

@ -4,7 +4,7 @@
}, },
"extends": [ "extends": [
"../.eslintrc" "../../.eslintrc"
], ],
"env": { "env": {

View File

@ -4,7 +4,7 @@
}, },
"extends": [ "extends": [
"../.eslintrc" "../../.eslintrc"
], ],
"env": { "env": {

View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
"use strict"; "use strict";

View File

@ -1,3 +1,5 @@
/* eslint-disable no-var */
const fs = require("fs"); const fs = require("fs");
const crypto = require("crypto"); const crypto = require("crypto");
const execSync = require("child_process").execSync; const execSync = require("child_process").execSync;

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
"use strict"; "use strict";

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
"use strict"; "use strict";

View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
/* globals pdfjsLib, pdfjsViewer */ /* globals pdfjsLib, pdfjsViewer */
"use strict"; "use strict";

View File

@ -1,10 +0,0 @@
{
"extends": [
"../.eslintrc"
],
"rules": {
// ECMAScript 6
"no-var": "error",
},
}

View File

@ -1,3 +1,5 @@
/* eslint-disable no-var */
"use strict"; "use strict";
var fs = require("fs"); var fs = require("fs");

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
"use strict"; "use strict";

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
"use strict"; "use strict";

View File

@ -6,8 +6,5 @@
"rules": { "rules": {
// Plugins // Plugins
"import/no-unresolved": ["error", { "ignore": ["pdfjs/"] }], "import/no-unresolved": ["error", { "ignore": ["pdfjs/"] }],
// ECMAScript 6
"no-var": "error",
}, },
} }

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
"use strict"; "use strict";

View File

@ -6,8 +6,5 @@
"rules": { "rules": {
// Plugins // Plugins
"import/no-unresolved": ["error", { "ignore": ["pdfjs-lib"]}], "import/no-unresolved": ["error", { "ignore": ["pdfjs-lib"]}],
// ECMAScript 6
"no-var": "error",
}, },
} }