Skip to content

Commit

Permalink
Upgrade to ESLint 9+ and flat config (Leaflet#9410)
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner authored Jul 27, 2024
1 parent 688033d commit 54f49b5
Show file tree
Hide file tree
Showing 16 changed files with 1,759 additions and 1,865 deletions.
80 changes: 0 additions & 80 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion build/integrity.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ssri from 'ssri';
// See: https://rollupjs.org/guide/en/#importing-packagejson
const {version} = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)));

const getIntegrity = async path => new Promise((resolve) => {
const getIntegrity = path => new Promise((resolve) => {
https.get(`https://unpkg.com/leaflet@${version}/dist/${path}`, (res) => {
ssri.fromStream(res, {algorithms: ['sha256']}).then(integrity => resolve(integrity.toString()));
});
Expand Down
5 changes: 0 additions & 5 deletions docs/.eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion docs/docs/js/docs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global hljs */
/* global hljs, L */
hljs.configure({tabReplace: ' '});
hljs.initHighlighting();

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/wms/wms-example1.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ title: WMS example
layers: 'TOPO-OSM-WMS'
}).addTo(map);

</script>
</script>
83 changes: 83 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import config from 'eslint-config-mourner';
import scriptTags from '@mapbox/eslint-plugin-script-tags';
import importPlugin from 'eslint-plugin-import-x';
import globals from 'globals';

export default [
...config,
{
files: ['*.js', '*.mjs', '*.cjs'],
},
{
ignores: [
'dist',
'docs/docs/highlight',
'docs/examples/choropleth/us-states.js',
'docs/examples/geojson/sample-geojson.js',
'docs/examples/map-panes/eu-countries.js',
'docs/examples/extending/extending-2-layers.md',
'docs/_posts/201*',
'docs/_site',
'coverage'
]
},
{
plugins: {
import: importPlugin
},
rules: {
'dot-notation': 'off',
'consistent-return': 'off',
'curly': 'error',
'no-unused-expressions': ['error', {allowShortCircuit: true}],
'no-unused-vars': ['error', {caughtErrors: 'none'}],

'import/extensions': ['error', 'ignorePackages'],

'@stylistic/js/indent': ['error', 'tab', {VariableDeclarator: 0, flatTernaryExpressions: true}],
'@stylistic/js/no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
'@stylistic/js/key-spacing': 'off',
'@stylistic/js/linebreak-style': ['off', 'unix'],
'@stylistic/js/spaced-comment': 'error',

// TODO: Re-enable the rules below and fix the linting issues.
'no-invalid-this': 'off',
'prefer-object-has-own': 'error',
'prefer-spread': 'off',
'no-new': 'off'
}
},
{
files: ['spec/**'],
languageOptions: {
globals: {...globals.mocha}
},
rules: {
'no-unused-expressions': 'off'
}
},
{
files: ['build/**'],
languageOptions: {
parserOptions: {
ecmaVersion: 2022
}
}
},
{
files: ['docs/**/*.md'],
plugins: {
scriptTags: {
processors: {md: scriptTags.processors['.md']}
}
},
processor: 'scriptTags/md',
rules: {
'no-unused-vars': 'off',
'@stylistic/js/eol-last': 'off'
},
languageOptions: {
globals: {L: false}
}
}
];
Loading

0 comments on commit 54f49b5

Please sign in to comment.